typescript 4.5.0-dev.20210923 → 4.5.0-dev.20210927

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -670,7 +670,7 @@ declare namespace ts {
670
670
  readonly parent: Declaration;
671
671
  readonly expression: Expression;
672
672
  }
673
- export interface PrivateIdentifier extends Node {
673
+ export interface PrivateIdentifier extends PrimaryExpression {
674
674
  readonly kind: SyntaxKind.PrivateIdentifier;
675
675
  readonly escapedText: __String;
676
676
  }
@@ -2030,6 +2030,18 @@ declare namespace ts {
2030
2030
  */
2031
2031
  hasNoDefaultLib: boolean;
2032
2032
  languageVersion: ScriptTarget;
2033
+ /**
2034
+ * When `module` is `Node12` or `NodeNext`, this field controls whether the
2035
+ * source file in question is an ESNext-output-format file, or a CommonJS-output-format
2036
+ * module. This is derived by the module resolver as it looks up the file, since
2037
+ * it is derived from either the file extension of the module, or the containing
2038
+ * `package.json` context, and affects both checking and emit.
2039
+ *
2040
+ * It is _public_ so that (pre)transformers can set this field,
2041
+ * since it switches the builtin `node` module transform. Generally speaking, if unset,
2042
+ * the field is treated as though it is `ModuleKind.CommonJS`.
2043
+ */
2044
+ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
2033
2045
  }
2034
2046
  export interface Bundle extends Node {
2035
2047
  readonly kind: SyntaxKind.Bundle;
@@ -2847,7 +2859,9 @@ declare namespace ts {
2847
2859
  }
2848
2860
  export enum ModuleResolutionKind {
2849
2861
  Classic = 1,
2850
- NodeJs = 2
2862
+ NodeJs = 2,
2863
+ Node12 = 3,
2864
+ NodeNext = 99
2851
2865
  }
2852
2866
  export interface PluginImport {
2853
2867
  name: string;
@@ -3009,7 +3023,9 @@ declare namespace ts {
3009
3023
  System = 4,
3010
3024
  ES2015 = 5,
3011
3025
  ES2020 = 6,
3012
- ESNext = 99
3026
+ ESNext = 99,
3027
+ Node12 = 100,
3028
+ NodeNext = 199
3013
3029
  }
3014
3030
  export enum JsxEmit {
3015
3031
  None = 0,
@@ -3155,7 +3171,13 @@ declare namespace ts {
3155
3171
  Js = ".js",
3156
3172
  Jsx = ".jsx",
3157
3173
  Json = ".json",
3158
- TsBuildInfo = ".tsbuildinfo"
3174
+ TsBuildInfo = ".tsbuildinfo",
3175
+ Mjs = ".mjs",
3176
+ Mts = ".mts",
3177
+ Dmts = ".d.mts",
3178
+ Cjs = ".cjs",
3179
+ Cts = ".cts",
3180
+ Dcts = ".d.cts"
3159
3181
  }
3160
3182
  export interface ResolvedModuleWithFailedLookupLocations {
3161
3183
  readonly resolvedModule: ResolvedModuleFull | undefined;
@@ -3183,7 +3205,11 @@ declare namespace ts {
3183
3205
  useCaseSensitiveFileNames(): boolean;
3184
3206
  getNewLine(): string;
3185
3207
  readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[];
3186
- resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
3208
+ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
3209
+ /**
3210
+ * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
3211
+ */
3212
+ getModuleResolutionCache?(): ModuleResolutionCache | undefined;
3187
3213
  /**
3188
3214
  * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
3189
3215
  */
@@ -4830,12 +4856,20 @@ declare namespace ts {
4830
4856
  export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[];
4831
4857
  export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>, PackageJsonInfoCache {
4832
4858
  }
4859
+ export interface ModeAwareCache<T> {
4860
+ get(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): T | undefined;
4861
+ set(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, value: T): this;
4862
+ delete(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): this;
4863
+ has(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): boolean;
4864
+ forEach(cb: (elem: T, key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) => void): void;
4865
+ size(): number;
4866
+ }
4833
4867
  /**
4834
4868
  * Cached resolutions per containing directory.
4835
4869
  * This assumes that any module id will have the same resolution for sibling files located in the same folder.
4836
4870
  */
4837
4871
  export interface PerDirectoryResolutionCache<T> {
4838
- getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<T>;
4872
+ getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): ModeAwareCache<T>;
4839
4873
  clear(): void;
4840
4874
  /**
4841
4875
  * Updates with the current compilerOptions the cache will operate with.
@@ -4851,7 +4885,7 @@ declare namespace ts {
4851
4885
  * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive.
4852
4886
  */
4853
4887
  export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache {
4854
- getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
4888
+ getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache;
4855
4889
  }
4856
4890
  export interface PackageJsonInfoCache {
4857
4891
  clear(): void;
@@ -4862,8 +4896,8 @@ declare namespace ts {
4862
4896
  }
4863
4897
  export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache;
4864
4898
  export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache;
4865
- export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined;
4866
- export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
4899
+ export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
4900
+ export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations;
4867
4901
  export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
4868
4902
  export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
4869
4903
  export {};
@@ -4974,6 +5008,17 @@ declare namespace ts {
4974
5008
  export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
4975
5009
  export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
4976
5010
  export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
5011
+ /**
5012
+ * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
5013
+ * `options` parameter.
5014
+ *
5015
+ * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
5016
+ * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
5017
+ * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
5018
+ * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
5019
+ * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
5020
+ */
5021
+ export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined;
4977
5022
  /**
4978
5023
  * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
4979
5024
  * that represent a compilation unit.
@@ -5218,7 +5263,7 @@ declare namespace ts {
5218
5263
  /** If provided is used to get the environment variable */
5219
5264
  getEnvironmentVariable?(name: string): string | undefined;
5220
5265
  /** If provided, used to resolve the module names, otherwise typescript's default module resolution */
5221
- resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
5266
+ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5222
5267
  /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
5223
5268
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
5224
5269
  }
@@ -5608,8 +5653,8 @@ declare namespace ts {
5608
5653
  realpath?(path: string): string;
5609
5654
  fileExists?(path: string): boolean;
5610
5655
  getTypeRootsVersion?(): number;
5611
- resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
5612
- getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
5656
+ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5657
+ getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
5613
5658
  resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[];
5614
5659
  getDirectories?(directoryName: string): string[];
5615
5660
  /**
@@ -6557,7 +6602,13 @@ declare namespace ts {
6557
6602
  tsxModifier = ".tsx",
6558
6603
  jsModifier = ".js",
6559
6604
  jsxModifier = ".jsx",
6560
- jsonModifier = ".json"
6605
+ jsonModifier = ".json",
6606
+ dmtsModifier = ".d.mts",
6607
+ mtsModifier = ".mts",
6608
+ mjsModifier = ".mjs",
6609
+ dctsModifier = ".d.cts",
6610
+ ctsModifier = ".cts",
6611
+ cjsModifier = ".cjs"
6561
6612
  }
6562
6613
  enum ClassificationTypeNames {
6563
6614
  comment = "comment",
@@ -9795,8 +9846,8 @@ declare namespace ts.server {
9795
9846
  readFile(fileName: string): string | undefined;
9796
9847
  writeFile(fileName: string, content: string): void;
9797
9848
  fileExists(file: string): boolean;
9798
- resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference): (ResolvedModuleFull | undefined)[];
9799
- getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
9849
+ resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModuleFull | undefined)[];
9850
+ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
9800
9851
  resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[];
9801
9852
  directoryExists(path: string): boolean;
9802
9853
  getDirectories(path: string): string[];