typescript 5.3.3 → 5.4.0-beta

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.
@@ -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",
@@ -4132,7 +4150,7 @@ declare namespace ts {
4132
4150
  responseRequired?: boolean;
4133
4151
  }
4134
4152
  }
4135
- const versionMajorMinor = "5.3";
4153
+ const versionMajorMinor = "5.4";
4136
4154
  /** The version of the TypeScript compiler release */
4137
4155
  const version: string;
4138
4156
  /**
@@ -6650,6 +6668,22 @@ declare namespace ts {
6650
6668
  };
6651
6669
  isSourceFileFromExternalLibrary(file: SourceFile): boolean;
6652
6670
  isSourceFileDefaultLibrary(file: SourceFile): boolean;
6671
+ /**
6672
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
6673
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
6674
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
6675
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
6676
+ * impact on module resolution, emit, or type checking.
6677
+ */
6678
+ getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
6679
+ /**
6680
+ * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
6681
+ * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
6682
+ * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
6683
+ * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
6684
+ * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
6685
+ */
6686
+ getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
6653
6687
  getProjectReferences(): readonly ProjectReference[] | undefined;
6654
6688
  getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
6655
6689
  }
@@ -6829,6 +6863,20 @@ declare namespace ts {
6829
6863
  * is `never`. Instead, use `type.flags & TypeFlags.Never`.
6830
6864
  */
6831
6865
  getNeverType(): Type;
6866
+ /**
6867
+ * Returns true if the "source" type is assignable to the "target" type.
6868
+ *
6869
+ * ```ts
6870
+ * declare const abcLiteral: ts.Type; // Type of "abc"
6871
+ * declare const stringType: ts.Type; // Type of string
6872
+ *
6873
+ * isTypeAssignableTo(abcLiteral, abcLiteral); // true; "abc" is assignable to "abc"
6874
+ * isTypeAssignableTo(abcLiteral, stringType); // true; "abc" is assignable to string
6875
+ * isTypeAssignableTo(stringType, abcLiteral); // false; string is not assignable to "abc"
6876
+ * isTypeAssignableTo(stringType, stringType); // true; string is assignable to string
6877
+ * ```
6878
+ */
6879
+ isTypeAssignableTo(source: Type, target: Type): boolean;
6832
6880
  /**
6833
6881
  * True if this type is the `Array` or `ReadonlyArray` type from lib.d.ts.
6834
6882
  * This function will _not_ return true if passed a type which
@@ -6844,6 +6892,7 @@ declare namespace ts {
6844
6892
  * True if this type is assignable to `ReadonlyArray<any>`.
6845
6893
  */
6846
6894
  isArrayLikeType(type: Type): boolean;
6895
+ resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
6847
6896
  getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
6848
6897
  /**
6849
6898
  * Depending on the operation performed, it may be appropriate to throw away the checker
@@ -6889,6 +6938,7 @@ declare namespace ts {
6889
6938
  None = 0,
6890
6939
  NoTruncation = 1,
6891
6940
  WriteArrayAsGenericType = 2,
6941
+ GenerateNamesForShadowedTypeParams = 4,
6892
6942
  UseStructuralFallback = 8,
6893
6943
  WriteTypeArgumentsOfSignature = 32,
6894
6944
  UseFullyQualifiedType = 64,
@@ -6908,7 +6958,7 @@ declare namespace ts {
6908
6958
  InElementType = 2097152,
6909
6959
  InFirstTypeArgument = 4194304,
6910
6960
  InTypeAlias = 8388608,
6911
- NodeBuilderFlagsMask = 848330091,
6961
+ NodeBuilderFlagsMask = 848330095,
6912
6962
  }
6913
6963
  enum SymbolFormatFlags {
6914
6964
  None = 0,
@@ -6982,6 +7032,7 @@ declare namespace ts {
6982
7032
  Transient = 33554432,
6983
7033
  Assignment = 67108864,
6984
7034
  ModuleExports = 134217728,
7035
+ All = -1,
6985
7036
  Enum = 384,
6986
7037
  Variable = 3,
6987
7038
  Value = 111551,
@@ -7050,6 +7101,8 @@ declare namespace ts {
7050
7101
  ExportEquals = "export=",
7051
7102
  Default = "default",
7052
7103
  This = "this",
7104
+ InstantiationExpression = "__instantiationExpression",
7105
+ ImportAttributes = "__importAttributes",
7053
7106
  }
7054
7107
  /**
7055
7108
  * This represents a string whose leading underscore have been escaped by adding extra leading underscores.
@@ -7614,6 +7667,7 @@ declare namespace ts {
7614
7667
  ESNext = 99,
7615
7668
  Node16 = 100,
7616
7669
  NodeNext = 199,
7670
+ Preserve = 200,
7617
7671
  }
7618
7672
  enum JsxEmit {
7619
7673
  None = 0,
@@ -7892,6 +7946,7 @@ declare namespace ts {
7892
7946
  Unspecified = 4,
7893
7947
  EmbeddedStatement = 5,
7894
7948
  JsxAttributeValue = 6,
7949
+ ImportTypeNodeAttributes = 7,
7895
7950
  }
7896
7951
  enum OuterExpressionKinds {
7897
7952
  Parentheses = 1,
@@ -8764,6 +8819,7 @@ declare namespace ts {
8764
8819
  readonly organizeImportsNumericCollation?: boolean;
8765
8820
  readonly organizeImportsAccentCollation?: boolean;
8766
8821
  readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
8822
+ readonly organizeImportsTypeOrder?: "first" | "last" | "inline";
8767
8823
  readonly excludeLibrarySymbolsInNavTo?: boolean;
8768
8824
  }
8769
8825
  /** Represents a bigint literal value without requiring bigint support */
@@ -9169,6 +9225,7 @@ declare namespace ts {
9169
9225
  function isForInitializer(node: Node): node is ForInitializer;
9170
9226
  function isModuleBody(node: Node): node is ModuleBody;
9171
9227
  function isNamedImportBindings(node: Node): node is NamedImportBindings;
9228
+ function isDeclarationStatement(node: Node): node is DeclarationStatement;
9172
9229
  function isStatement(node: Node): node is Statement;
9173
9230
  function isModuleReference(node: Node): node is ModuleReference;
9174
9231
  function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression;
@@ -9188,11 +9245,13 @@ declare namespace ts {
9188
9245
  function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain;
9189
9246
  function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean;
9190
9247
  function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean;
9248
+ function isInternalDeclaration(node: Node, sourceFile?: SourceFile): boolean;
9191
9249
  const unchangedTextChangeRange: TextChangeRange;
9192
9250
  type ParameterPropertyDeclaration = ParameterDeclaration & {
9193
9251
  parent: ConstructorDeclaration;
9194
9252
  name: Identifier;
9195
9253
  };
9254
+ function isPartOfTypeNode(node: Node): boolean;
9196
9255
  /**
9197
9256
  * This function checks multiple locations for JSDoc comments that apply to a host node.
9198
9257
  * At each location, the whole comment may apply to the node, or only a specific tag in
@@ -9831,7 +9890,7 @@ declare namespace ts {
9831
9890
  * @param visitor The callback used to visit each child.
9832
9891
  * @param context A lexical environment context for the visitor.
9833
9892
  */
9834
- function visitEachChild<T extends Node>(node: T, visitor: Visitor, context: TransformationContext): T;
9893
+ function visitEachChild<T extends Node>(node: T, visitor: Visitor, context: TransformationContext | undefined): T;
9835
9894
  /**
9836
9895
  * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place.
9837
9896
  *
@@ -9839,7 +9898,7 @@ declare namespace ts {
9839
9898
  * @param visitor The callback used to visit each child.
9840
9899
  * @param context A lexical environment context for the visitor.
9841
9900
  */
9842
- function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
9901
+ function visitEachChild<T extends Node>(node: T | undefined, visitor: Visitor, context: TransformationContext | undefined, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined;
9843
9902
  function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined;
9844
9903
  function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
9845
9904
  function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer;
@@ -9870,37 +9929,50 @@ declare namespace ts {
9870
9929
  */
9871
9930
  function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode;
9872
9931
  /**
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.
9932
+ * Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
9933
+ * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
9934
+ * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
9935
+ * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
9936
+ * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
9937
+ * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
9876
9938
  * @param file File to fetch the resolution mode within
9877
9939
  * @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
9940
+ * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
9941
+ * should be the options of the referenced project, not the referencing project.
9878
9942
  */
9879
- function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
9943
+ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
9880
9944
  /**
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`+.
9945
+ * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
9946
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
9947
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
9948
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
9949
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
9950
+ * impact on module resolution, emit, or type checking.
9885
9951
  * @param file The file the import or import-like reference is contained within
9886
9952
  * @param usage The module reference string
9953
+ * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
9954
+ * should be the options of the referenced project, not the referencing project.
9887
9955
  * @returns The final resolution mode of the import
9888
9956
  */
9889
- function getModeForUsageLocation(file: {
9890
- impliedNodeFormat?: ResolutionMode;
9891
- }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
9957
+ function getModeForUsageLocation(
9958
+ file: {
9959
+ impliedNodeFormat?: ResolutionMode;
9960
+ },
9961
+ usage: StringLiteralLike,
9962
+ compilerOptions: CompilerOptions,
9963
+ ): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
9892
9964
  function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
9893
9965
  /**
9894
9966
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
9895
9967
  * `options` parameter.
9896
9968
  *
9897
- * @param fileName The normalized absolute path to check the format of (it need not exist on disk)
9969
+ * @param fileName The file name to check the format of (it need not exist on disk)
9898
9970
  * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
9899
9971
  * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
9900
9972
  * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
9901
9973
  * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
9902
9974
  */
9903
- function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ResolutionMode;
9975
+ function getImpliedNodeFormatForFile(fileName: string, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ResolutionMode;
9904
9976
  /**
9905
9977
  * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
9906
9978
  * that represent a compilation unit.
@@ -11087,6 +11159,10 @@ declare namespace ts {
11087
11159
  */
11088
11160
  fileToRename?: string;
11089
11161
  displayName: string;
11162
+ /**
11163
+ * Full display name of item to be renamed.
11164
+ * If item to be renamed is a file, then this is the original text of the module specifer
11165
+ */
11090
11166
  fullDisplayName: string;
11091
11167
  kind: ScriptElementKind;
11092
11168
  kindModifiers: string;