typescript 4.7.0-dev.20220309 → 4.7.0-dev.20220312

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.
@@ -424,6 +424,7 @@ declare namespace ts {
424
424
  JSDocFunctionType = 316,
425
425
  JSDocVariadicType = 317,
426
426
  JSDocNamepathType = 318,
427
+ /** @deprecated Use SyntaxKind.JSDoc */
427
428
  JSDocComment = 319,
428
429
  JSDocText = 320,
429
430
  JSDocTypeLiteral = 321,
@@ -491,6 +492,7 @@ declare namespace ts {
491
492
  LastJSDocNode = 346,
492
493
  FirstJSDocTagNode = 326,
493
494
  LastJSDocTagNode = 346,
495
+ JSDoc = 319
494
496
  }
495
497
  export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
496
498
  export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -1820,7 +1822,7 @@ declare namespace ts {
1820
1822
  }
1821
1823
  export type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType;
1822
1824
  export interface JSDoc extends Node {
1823
- readonly kind: SyntaxKind.JSDocComment;
1825
+ readonly kind: SyntaxKind.JSDoc;
1824
1826
  readonly parent: HasJSDoc;
1825
1827
  readonly tags?: NodeArray<JSDocTag>;
1826
1828
  readonly comment?: string | NodeArray<JSDocComment>;
@@ -2886,6 +2888,20 @@ declare namespace ts {
2886
2888
  Node12 = 3,
2887
2889
  NodeNext = 99
2888
2890
  }
2891
+ export enum ModuleDetectionKind {
2892
+ /**
2893
+ * Files with imports, exports and/or import.meta are considered modules
2894
+ */
2895
+ Legacy = 1,
2896
+ /**
2897
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+
2898
+ */
2899
+ Auto = 2,
2900
+ /**
2901
+ * Consider all non-declaration files modules, regardless of present syntax
2902
+ */
2903
+ Force = 3
2904
+ }
2889
2905
  export interface PluginImport {
2890
2906
  name: string;
2891
2907
  }
@@ -2957,6 +2973,7 @@ declare namespace ts {
2957
2973
  maxNodeModuleJsDepth?: number;
2958
2974
  module?: ModuleKind;
2959
2975
  moduleResolution?: ModuleResolutionKind;
2976
+ moduleDetection?: ModuleDetectionKind;
2960
2977
  newLine?: NewLineKind;
2961
2978
  noEmit?: boolean;
2962
2979
  noEmitHelpers?: boolean;
@@ -3144,6 +3161,13 @@ declare namespace ts {
3144
3161
  getDirectories?(path: string): string[];
3145
3162
  useCaseSensitiveFileNames?: boolean | (() => boolean);
3146
3163
  }
3164
+ /**
3165
+ * Used by services to specify the minimum host area required to set up source files under any compilation settings
3166
+ */
3167
+ export interface MinimalResolutionCacheHost extends ModuleResolutionHost {
3168
+ getCompilationSettings(): CompilerOptions;
3169
+ getCompilerHost?(): CompilerHost | undefined;
3170
+ }
3147
3171
  /**
3148
3172
  * Represents the result of module resolution.
3149
3173
  * Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off.
@@ -3219,8 +3243,8 @@ declare namespace ts {
3219
3243
  readonly failedLookupLocations: string[];
3220
3244
  }
3221
3245
  export interface CompilerHost extends ModuleResolutionHost {
3222
- getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
3223
- getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
3246
+ getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
3247
+ getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
3224
3248
  getCancellationToken?(): CancellationToken;
3225
3249
  getDefaultLibFileName(options: CompilerOptions): string;
3226
3250
  getDefaultLibLocation?(): string;
@@ -4774,7 +4798,22 @@ declare namespace ts {
4774
4798
  * that they appear in the source code. The language service depends on this property to locate nodes by position.
4775
4799
  */
4776
4800
  export function forEachChild<T>(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined;
4777
- export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
4801
+ export interface CreateSourceFileOptions {
4802
+ languageVersion: ScriptTarget;
4803
+ /**
4804
+ * Controls the format the file is detected as - this can be derived from only the path
4805
+ * and files on disk, but needs to be done with a module resolution cache in scope to be performant.
4806
+ * This is usually `undefined` for compilations that do not have `moduleResolution` values of `node12` or `nodenext`.
4807
+ */
4808
+ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS;
4809
+ /**
4810
+ * Controls how module-y-ness is set for the given file. Usually the result of calling
4811
+ * `getSetExternalModuleIndicator` on a valid `CompilerOptions` object. If not present, the default
4812
+ * check specified by `isFileProbablyExternalModule` will be used to set the field.
4813
+ */
4814
+ setExternalModuleIndicator?: (file: SourceFile) => void;
4815
+ }
4816
+ export function createSourceFile(fileName: string, sourceText: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile;
4778
4817
  export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined;
4779
4818
  /**
4780
4819
  * Parse json text into SyntaxTree and return node and parse errors if any
@@ -5674,7 +5713,7 @@ declare namespace ts {
5674
5713
  set(response: CompletionInfo): void;
5675
5714
  clear(): void;
5676
5715
  }
5677
- interface LanguageServiceHost extends GetEffectiveTypeRootsHost {
5716
+ interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalResolutionCacheHost {
5678
5717
  getCompilationSettings(): CompilerOptions;
5679
5718
  getNewLine?(): string;
5680
5719
  getProjectVersion?(): string;
@@ -5692,9 +5731,9 @@ declare namespace ts {
5692
5731
  error?(s: string): void;
5693
5732
  useCaseSensitiveFileNames?(): boolean;
5694
5733
  readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[];
5695
- readFile?(path: string, encoding?: string): string | undefined;
5696
5734
  realpath?(path: string): string;
5697
- fileExists?(path: string): boolean;
5735
+ readFile(path: string, encoding?: string): string | undefined;
5736
+ fileExists(path: string): boolean;
5698
5737
  getTypeRootsVersion?(): number;
5699
5738
  resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5700
5739
  getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined;
@@ -6746,30 +6785,36 @@ declare namespace ts {
6746
6785
  * the SourceFile if was not found in the registry.
6747
6786
  *
6748
6787
  * @param fileName The name of the file requested
6749
- * @param compilationSettings Some compilation settings like target affects the
6788
+ * @param compilationSettingsOrHost Some compilation settings like target affects the
6750
6789
  * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
6751
- * multiple copies of the same file for different compilation settings.
6790
+ * multiple copies of the same file for different compilation settings. A minimal
6791
+ * resolution cache is needed to fully define a source file's shape when
6792
+ * the compilation settings include `module: node12`+, so providing a cache host
6793
+ * object should be preferred. A common host is a language service `ConfiguredProject`.
6752
6794
  * @param scriptSnapshot Text of the file. Only used if the file was not found
6753
6795
  * in the registry and a new one was created.
6754
6796
  * @param version Current version of the file. Only used if the file was not found
6755
6797
  * in the registry and a new one was created.
6756
6798
  */
6757
- acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6758
- acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6799
+ acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6800
+ acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6759
6801
  /**
6760
6802
  * Request an updated version of an already existing SourceFile with a given fileName
6761
6803
  * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
6762
6804
  * to get an updated SourceFile.
6763
6805
  *
6764
6806
  * @param fileName The name of the file requested
6765
- * @param compilationSettings Some compilation settings like target affects the
6807
+ * @param compilationSettingsOrHost Some compilation settings like target affects the
6766
6808
  * shape of a the resulting SourceFile. This allows the DocumentRegistry to store
6767
- * multiple copies of the same file for different compilation settings.
6809
+ * multiple copies of the same file for different compilation settings. A minimal
6810
+ * resolution cache is needed to fully define a source file's shape when
6811
+ * the compilation settings include `module: node12`+, so providing a cache host
6812
+ * object should be preferred. A common host is a language service `ConfiguredProject`.
6768
6813
  * @param scriptSnapshot Text of the file.
6769
6814
  * @param version Current version of the file.
6770
6815
  */
6771
- updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6772
- updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6816
+ updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6817
+ updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile;
6773
6818
  getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
6774
6819
  /**
6775
6820
  * Informs the DocumentRegistry that a file is not needed any longer.
@@ -6831,7 +6876,7 @@ declare namespace ts {
6831
6876
  function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string;
6832
6877
  function getDefaultCompilerOptions(): CompilerOptions;
6833
6878
  function getSupportedCodeFixes(): string[];
6834
- function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
6879
+ function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTargetOrOptions: ScriptTarget | CreateSourceFileOptions, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile;
6835
6880
  function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile;
6836
6881
  function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnlyOrLanguageServiceMode?: boolean | LanguageServiceMode): LanguageService;
6837
6882
  /**