typescript 5.3.3 → 5.4.2

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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/lib/cancellationToken.js +0 -1
  3. package/lib/cs/diagnosticMessages.generated.json +1 -1
  4. package/lib/de/diagnosticMessages.generated.json +1 -1
  5. package/lib/es/diagnosticMessages.generated.json +1 -1
  6. package/lib/fr/diagnosticMessages.generated.json +1 -1
  7. package/lib/it/diagnosticMessages.generated.json +1 -1
  8. package/lib/ja/diagnosticMessages.generated.json +1 -1
  9. package/lib/ko/diagnosticMessages.generated.json +1 -1
  10. package/lib/lib.dom.asynciterable.d.ts +28 -0
  11. package/lib/lib.dom.d.ts +363 -153
  12. package/lib/lib.dom.iterable.d.ts +35 -28
  13. package/lib/lib.es2016.d.ts +1 -0
  14. package/lib/lib.es2016.intl.d.ts +31 -0
  15. package/lib/lib.es2018.full.d.ts +1 -0
  16. package/lib/lib.es2018.intl.d.ts +6 -5
  17. package/lib/lib.es2019.full.d.ts +1 -0
  18. package/lib/lib.es2020.full.d.ts +1 -0
  19. package/lib/lib.es2020.intl.d.ts +36 -16
  20. package/lib/lib.es2020.string.d.ts +15 -1
  21. package/lib/lib.es2021.full.d.ts +1 -0
  22. package/lib/lib.es2021.intl.d.ts +2 -2
  23. package/lib/lib.es2022.full.d.ts +1 -0
  24. package/lib/lib.es2022.intl.d.ts +2 -2
  25. package/lib/lib.es2023.full.d.ts +1 -0
  26. package/lib/lib.es5.d.ts +21 -6
  27. package/lib/lib.esnext.collection.d.ts +29 -0
  28. package/lib/lib.esnext.d.ts +3 -0
  29. package/lib/lib.esnext.disposable.d.ts +1 -1
  30. package/lib/lib.esnext.full.d.ts +1 -0
  31. package/lib/lib.esnext.object.d.ts +29 -0
  32. package/lib/lib.esnext.promise.d.ts +35 -0
  33. package/lib/lib.webworker.asynciterable.d.ts +28 -0
  34. package/lib/lib.webworker.d.ts +202 -111
  35. package/lib/lib.webworker.iterable.d.ts +29 -28
  36. package/lib/pl/diagnosticMessages.generated.json +1 -1
  37. package/lib/pt-br/diagnosticMessages.generated.json +1 -1
  38. package/lib/ru/diagnosticMessages.generated.json +1 -1
  39. package/lib/tr/diagnosticMessages.generated.json +1 -1
  40. package/lib/tsc.js +2685 -1330
  41. package/lib/tsserver.js +4611 -2423
  42. package/lib/typescript.d.ts +95 -30
  43. package/lib/typescript.js +4568 -2219
  44. package/lib/typingsInstaller.js +501 -218
  45. package/lib/zh-cn/diagnosticMessages.generated.json +1 -1
  46. package/lib/zh-tw/diagnosticMessages.generated.json +1 -1
  47. package/package.json +28 -29
@@ -49,9 +49,11 @@ declare namespace ts {
49
49
  readonly fileName: Path;
50
50
  readonly packageName: string;
51
51
  readonly projectRootPath: Path;
52
+ readonly id: number;
52
53
  }
53
54
  interface PackageInstalledResponse extends ProjectResponse {
54
55
  readonly kind: ActionPackageInstalled;
56
+ readonly id: number;
55
57
  readonly success: boolean;
56
58
  readonly message: string;
57
59
  }
@@ -203,7 +205,7 @@ declare namespace ts {
203
205
  /**
204
206
  * Request to reload the project structure for all the opened files
205
207
  */
206
- interface ReloadProjectsRequest extends Message {
208
+ interface ReloadProjectsRequest extends Request {
207
209
  command: CommandTypes.ReloadProjects;
208
210
  }
209
211
  /**
@@ -1085,6 +1087,7 @@ declare namespace ts {
1085
1087
  displayName: string;
1086
1088
  /**
1087
1089
  * Full display name of item to be renamed.
1090
+ * If item to be renamed is a file, then this is the original text of the module specifer
1088
1091
  */
1089
1092
  fullDisplayName: string;
1090
1093
  /**
@@ -2930,6 +2933,13 @@ declare namespace ts {
2930
2933
  * Default: `false`
2931
2934
  */
2932
2935
  readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
2936
+ /**
2937
+ * Indicates where named type-only imports should sort. "inline" sorts named imports without regard to if the import is
2938
+ * type-only.
2939
+ *
2940
+ * Default: `last`
2941
+ */
2942
+ readonly organizeImportsTypeOrder?: "last" | "first" | "inline";
2933
2943
  /**
2934
2944
  * Indicates whether {@link ReferencesResponseItem.lineText} is supported.
2935
2945
  */
@@ -3026,10 +3036,18 @@ declare namespace ts {
3026
3036
  ES6 = "ES6",
3027
3037
  ES2015 = "ES2015",
3028
3038
  ESNext = "ESNext",
3039
+ Node16 = "Node16",
3040
+ NodeNext = "NodeNext",
3041
+ Preserve = "Preserve",
3029
3042
  }
3030
3043
  enum ModuleResolutionKind {
3031
3044
  Classic = "Classic",
3045
+ /** @deprecated Renamed to `Node10` */
3032
3046
  Node = "Node",
3047
+ Node10 = "Node10",
3048
+ Node16 = "Node16",
3049
+ NodeNext = "NodeNext",
3050
+ Bundler = "Bundler",
3033
3051
  }
3034
3052
  enum NewLineKind {
3035
3053
  Crlf = "Crlf",
@@ -3314,18 +3332,6 @@ declare namespace ts {
3314
3332
  * Last version that was reported.
3315
3333
  */
3316
3334
  private lastReportedVersion;
3317
- /**
3318
- * Current project's program version. (incremented everytime new program is created that is not complete reuse from the old one)
3319
- * This property is changed in 'updateGraph' based on the set of files in program
3320
- */
3321
- private projectProgramVersion;
3322
- /**
3323
- * Current version of the project state. It is changed when:
3324
- * - new root file was added/removed
3325
- * - edit happen in some file that is currently included in the project.
3326
- * This property is different from projectStructureVersion since in most cases edits don't affect set of files in the project
3327
- */
3328
- private projectStateVersion;
3329
3335
  protected projectErrors: Diagnostic[] | undefined;
3330
3336
  protected isInitialLoadPending: () => boolean;
3331
3337
  private readonly cancellationToken;
@@ -3900,6 +3906,7 @@ declare namespace ts {
3900
3906
  private static escapeFilenameForRegex;
3901
3907
  resetSafeList(): void;
3902
3908
  applySafeList(proj: protocol.ExternalProject): NormalizedPath[];
3909
+ private applySafeListWorker;
3903
3910
  openExternalProject(proj: protocol.ExternalProject): void;
3904
3911
  hasDeferredExtension(): boolean;
3905
3912
  private enableRequestedPluginsAsync;
@@ -4132,7 +4139,7 @@ declare namespace ts {
4132
4139
  responseRequired?: boolean;
4133
4140
  }
4134
4141
  }
4135
- const versionMajorMinor = "5.3";
4142
+ const versionMajorMinor = "5.4";
4136
4143
  /** The version of the TypeScript compiler release */
4137
4144
  const version: string;
4138
4145
  /**
@@ -6650,6 +6657,22 @@ declare namespace ts {
6650
6657
  };
6651
6658
  isSourceFileFromExternalLibrary(file: SourceFile): boolean;
6652
6659
  isSourceFileDefaultLibrary(file: SourceFile): boolean;
6660
+ /**
6661
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
6662
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
6663
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
6664
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
6665
+ * impact on module resolution, emit, or type checking.
6666
+ */
6667
+ getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
6668
+ /**
6669
+ * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
6670
+ * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
6671
+ * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
6672
+ * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
6673
+ * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
6674
+ */
6675
+ getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
6653
6676
  getProjectReferences(): readonly ProjectReference[] | undefined;
6654
6677
  getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
6655
6678
  }
@@ -6829,6 +6852,20 @@ declare namespace ts {
6829
6852
  * is `never`. Instead, use `type.flags & TypeFlags.Never`.
6830
6853
  */
6831
6854
  getNeverType(): Type;
6855
+ /**
6856
+ * Returns true if the "source" type is assignable to the "target" type.
6857
+ *
6858
+ * ```ts
6859
+ * declare const abcLiteral: ts.Type; // Type of "abc"
6860
+ * declare const stringType: ts.Type; // Type of string
6861
+ *
6862
+ * isTypeAssignableTo(abcLiteral, abcLiteral); // true; "abc" is assignable to "abc"
6863
+ * isTypeAssignableTo(abcLiteral, stringType); // true; "abc" is assignable to string
6864
+ * isTypeAssignableTo(stringType, abcLiteral); // false; string is not assignable to "abc"
6865
+ * isTypeAssignableTo(stringType, stringType); // true; string is assignable to string
6866
+ * ```
6867
+ */
6868
+ isTypeAssignableTo(source: Type, target: Type): boolean;
6832
6869
  /**
6833
6870
  * True if this type is the `Array` or `ReadonlyArray` type from lib.d.ts.
6834
6871
  * This function will _not_ return true if passed a type which
@@ -6844,6 +6881,7 @@ declare namespace ts {
6844
6881
  * True if this type is assignable to `ReadonlyArray<any>`.
6845
6882
  */
6846
6883
  isArrayLikeType(type: Type): boolean;
6884
+ resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
6847
6885
  getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
6848
6886
  /**
6849
6887
  * Depending on the operation performed, it may be appropriate to throw away the checker
@@ -6889,6 +6927,7 @@ declare namespace ts {
6889
6927
  None = 0,
6890
6928
  NoTruncation = 1,
6891
6929
  WriteArrayAsGenericType = 2,
6930
+ GenerateNamesForShadowedTypeParams = 4,
6892
6931
  UseStructuralFallback = 8,
6893
6932
  WriteTypeArgumentsOfSignature = 32,
6894
6933
  UseFullyQualifiedType = 64,
@@ -6908,7 +6947,7 @@ declare namespace ts {
6908
6947
  InElementType = 2097152,
6909
6948
  InFirstTypeArgument = 4194304,
6910
6949
  InTypeAlias = 8388608,
6911
- NodeBuilderFlagsMask = 848330091,
6950
+ NodeBuilderFlagsMask = 848330095,
6912
6951
  }
6913
6952
  enum SymbolFormatFlags {
6914
6953
  None = 0,
@@ -6982,6 +7021,7 @@ declare namespace ts {
6982
7021
  Transient = 33554432,
6983
7022
  Assignment = 67108864,
6984
7023
  ModuleExports = 134217728,
7024
+ All = -1,
6985
7025
  Enum = 384,
6986
7026
  Variable = 3,
6987
7027
  Value = 111551,
@@ -7050,6 +7090,8 @@ declare namespace ts {
7050
7090
  ExportEquals = "export=",
7051
7091
  Default = "default",
7052
7092
  This = "this",
7093
+ InstantiationExpression = "__instantiationExpression",
7094
+ ImportAttributes = "__importAttributes",
7053
7095
  }
7054
7096
  /**
7055
7097
  * This represents a string whose leading underscore have been escaped by adding extra leading underscores.
@@ -7614,6 +7656,7 @@ declare namespace ts {
7614
7656
  ESNext = 99,
7615
7657
  Node16 = 100,
7616
7658
  NodeNext = 199,
7659
+ Preserve = 200,
7617
7660
  }
7618
7661
  enum JsxEmit {
7619
7662
  None = 0,
@@ -7892,6 +7935,7 @@ declare namespace ts {
7892
7935
  Unspecified = 4,
7893
7936
  EmbeddedStatement = 5,
7894
7937
  JsxAttributeValue = 6,
7938
+ ImportTypeNodeAttributes = 7,
7895
7939
  }
7896
7940
  enum OuterExpressionKinds {
7897
7941
  Parentheses = 1,
@@ -8764,6 +8808,7 @@ declare namespace ts {
8764
8808
  readonly organizeImportsNumericCollation?: boolean;
8765
8809
  readonly organizeImportsAccentCollation?: boolean;
8766
8810
  readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
8811
+ readonly organizeImportsTypeOrder?: "first" | "last" | "inline";
8767
8812
  readonly excludeLibrarySymbolsInNavTo?: boolean;
8768
8813
  }
8769
8814
  /** Represents a bigint literal value without requiring bigint support */
@@ -9169,6 +9214,7 @@ declare namespace ts {
9169
9214
  function isForInitializer(node: Node): node is ForInitializer;
9170
9215
  function isModuleBody(node: Node): node is ModuleBody;
9171
9216
  function isNamedImportBindings(node: Node): node is NamedImportBindings;
9217
+ function isDeclarationStatement(node: Node): node is DeclarationStatement;
9172
9218
  function isStatement(node: Node): node is Statement;
9173
9219
  function isModuleReference(node: Node): node is ModuleReference;
9174
9220
  function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression;
@@ -9188,11 +9234,13 @@ declare namespace ts {
9188
9234
  function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain;
9189
9235
  function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean;
9190
9236
  function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean;
9237
+ function isInternalDeclaration(node: Node, sourceFile?: SourceFile): boolean;
9191
9238
  const unchangedTextChangeRange: TextChangeRange;
9192
9239
  type ParameterPropertyDeclaration = ParameterDeclaration & {
9193
9240
  parent: ConstructorDeclaration;
9194
9241
  name: Identifier;
9195
9242
  };
9243
+ function isPartOfTypeNode(node: Node): boolean;
9196
9244
  /**
9197
9245
  * This function checks multiple locations for JSDoc comments that apply to a host node.
9198
9246
  * At each location, the whole comment may apply to the node, or only a specific tag in
@@ -9831,7 +9879,7 @@ declare namespace ts {
9831
9879
  * @param visitor The callback used to visit each child.
9832
9880
  * @param context A lexical environment context for the visitor.
9833
9881
  */
9834
- function visitEachChild<T extends Node>(node: T, visitor: Visitor, context: TransformationContext): T;
9882
+ function visitEachChild<T extends Node>(node: T, visitor: Visitor, context: TransformationContext | undefined): T;
9835
9883
  /**
9836
9884
  * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place.
9837
9885
  *
@@ -9839,7 +9887,7 @@ declare namespace ts {
9839
9887
  * @param visitor The callback used to visit each child.
9840
9888
  * @param context A lexical environment context for the visitor.
9841
9889
  */
9842
- function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
9890
+ function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
9843
9891
  function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined;
9844
9892
  function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
9845
9893
  function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer;
@@ -9870,37 +9918,50 @@ declare namespace ts {
9870
9918
  */
9871
9919
  function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode;
9872
9920
  /**
9873
- * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
9874
- * defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
9875
- * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
9921
+ * Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
9922
+ * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
9923
+ * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
9924
+ * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
9925
+ * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
9926
+ * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
9876
9927
  * @param file File to fetch the resolution mode within
9877
9928
  * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
9929
+ * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
9930
+ * should be the options of the referenced project, not the referencing project.
9878
9931
  */
9879
- function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
9932
+ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
9880
9933
  /**
9881
- * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
9882
- * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
9883
- * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
9884
- * `moduleResolution` is `node16`+.
9934
+ * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
9935
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
9936
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
9937
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
9938
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
9939
+ * impact on module resolution, emit, or type checking.
9885
9940
  * @param file The file the import or import-like reference is contained within
9886
9941
  * @param usage The module reference string
9942
+ * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
9943
+ * should be the options of the referenced project, not the referencing project.
9887
9944
  * @returns The final resolution mode of the import
9888
9945
  */
9889
- function getModeForUsageLocation(file: {
9890
- impliedNodeFormat?: ResolutionMode;
9891
- }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
9946
+ function getModeForUsageLocation(
9947
+ file: {
9948
+ impliedNodeFormat?: ResolutionMode;
9949
+ },
9950
+ usage: StringLiteralLike,
9951
+ compilerOptions: CompilerOptions,
9952
+ ): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
9892
9953
  function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
9893
9954
  /**
9894
9955
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
9895
9956
  * `options` parameter.
9896
9957
  *
9897
- * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
9958
+ * @param fileName The file name to check the format of (it need not exist on disk)
9898
9959
  * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
9899
9960
  * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
9900
9961
  * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
9901
9962
  * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
9902
9963
  */
9903
- function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ResolutionMode;
9964
+ function getImpliedNodeFormatForFile(fileName: string, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ResolutionMode;
9904
9965
  /**
9905
9966
  * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
9906
9967
  * that represent a compilation unit.
@@ -11087,6 +11148,10 @@ declare namespace ts {
11087
11148
  */
11088
11149
  fileToRename?: string;
11089
11150
  displayName: string;
11151
+ /**
11152
+ * Full display name of item to be renamed.
11153
+ * If item to be renamed is a file, then this is the original text of the module specifer
11154
+ */
11090
11155
  fullDisplayName: string;
11091
11156
  kind: ScriptElementKind;
11092
11157
  kindModifiers: string;