typescript 5.3.2 → 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
  /**
@@ -6018,9 +6036,11 @@ declare namespace ts {
6018
6036
  /** @deprecated */
6019
6037
  type AssertionKey = ImportAttributeName;
6020
6038
  /** @deprecated */
6021
- type AssertEntry = ImportAttribute;
6039
+ interface AssertEntry extends ImportAttribute {
6040
+ }
6022
6041
  /** @deprecated */
6023
- type AssertClause = ImportAttributes;
6042
+ interface AssertClause extends ImportAttributes {
6043
+ }
6024
6044
  type ImportAttributeName = Identifier | StringLiteral;
6025
6045
  interface ImportAttribute extends Node {
6026
6046
  readonly kind: SyntaxKind.ImportAttribute;
@@ -6648,6 +6668,22 @@ declare namespace ts {
6648
6668
  };
6649
6669
  isSourceFileFromExternalLibrary(file: SourceFile): boolean;
6650
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;
6651
6687
  getProjectReferences(): readonly ProjectReference[] | undefined;
6652
6688
  getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
6653
6689
  }
@@ -6827,6 +6863,20 @@ declare namespace ts {
6827
6863
  * is `never`. Instead, use `type.flags & TypeFlags.Never`.
6828
6864
  */
6829
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;
6830
6880
  /**
6831
6881
  * True if this type is the `Array` or `ReadonlyArray` type from lib.d.ts.
6832
6882
  * This function will _not_ return true if passed a type which
@@ -6842,6 +6892,7 @@ declare namespace ts {
6842
6892
  * True if this type is assignable to `ReadonlyArray<any>`.
6843
6893
  */
6844
6894
  isArrayLikeType(type: Type): boolean;
6895
+ resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
6845
6896
  getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
6846
6897
  /**
6847
6898
  * Depending on the operation performed, it may be appropriate to throw away the checker
@@ -6887,6 +6938,7 @@ declare namespace ts {
6887
6938
  None = 0,
6888
6939
  NoTruncation = 1,
6889
6940
  WriteArrayAsGenericType = 2,
6941
+ GenerateNamesForShadowedTypeParams = 4,
6890
6942
  UseStructuralFallback = 8,
6891
6943
  WriteTypeArgumentsOfSignature = 32,
6892
6944
  UseFullyQualifiedType = 64,
@@ -6906,7 +6958,7 @@ declare namespace ts {
6906
6958
  InElementType = 2097152,
6907
6959
  InFirstTypeArgument = 4194304,
6908
6960
  InTypeAlias = 8388608,
6909
- NodeBuilderFlagsMask = 848330091,
6961
+ NodeBuilderFlagsMask = 848330095,
6910
6962
  }
6911
6963
  enum SymbolFormatFlags {
6912
6964
  None = 0,
@@ -6980,6 +7032,7 @@ declare namespace ts {
6980
7032
  Transient = 33554432,
6981
7033
  Assignment = 67108864,
6982
7034
  ModuleExports = 134217728,
7035
+ All = -1,
6983
7036
  Enum = 384,
6984
7037
  Variable = 3,
6985
7038
  Value = 111551,
@@ -7048,6 +7101,8 @@ declare namespace ts {
7048
7101
  ExportEquals = "export=",
7049
7102
  Default = "default",
7050
7103
  This = "this",
7104
+ InstantiationExpression = "__instantiationExpression",
7105
+ ImportAttributes = "__importAttributes",
7051
7106
  }
7052
7107
  /**
7053
7108
  * This represents a string whose leading underscore have been escaped by adding extra leading underscores.
@@ -7612,6 +7667,7 @@ declare namespace ts {
7612
7667
  ESNext = 99,
7613
7668
  Node16 = 100,
7614
7669
  NodeNext = 199,
7670
+ Preserve = 200,
7615
7671
  }
7616
7672
  enum JsxEmit {
7617
7673
  None = 0,
@@ -7890,6 +7946,7 @@ declare namespace ts {
7890
7946
  Unspecified = 4,
7891
7947
  EmbeddedStatement = 5,
7892
7948
  JsxAttributeValue = 6,
7949
+ ImportTypeNodeAttributes = 7,
7893
7950
  }
7894
7951
  enum OuterExpressionKinds {
7895
7952
  Parentheses = 1,
@@ -8762,6 +8819,7 @@ declare namespace ts {
8762
8819
  readonly organizeImportsNumericCollation?: boolean;
8763
8820
  readonly organizeImportsAccentCollation?: boolean;
8764
8821
  readonly organizeImportsCaseFirst?: "upper" | "lower" | false;
8822
+ readonly organizeImportsTypeOrder?: "first" | "last" | "inline";
8765
8823
  readonly excludeLibrarySymbolsInNavTo?: boolean;
8766
8824
  }
8767
8825
  /** Represents a bigint literal value without requiring bigint support */
@@ -9167,6 +9225,7 @@ declare namespace ts {
9167
9225
  function isForInitializer(node: Node): node is ForInitializer;
9168
9226
  function isModuleBody(node: Node): node is ModuleBody;
9169
9227
  function isNamedImportBindings(node: Node): node is NamedImportBindings;
9228
+ function isDeclarationStatement(node: Node): node is DeclarationStatement;
9170
9229
  function isStatement(node: Node): node is Statement;
9171
9230
  function isModuleReference(node: Node): node is ModuleReference;
9172
9231
  function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression;
@@ -9186,11 +9245,13 @@ declare namespace ts {
9186
9245
  function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain;
9187
9246
  function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean;
9188
9247
  function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean;
9248
+ function isInternalDeclaration(node: Node, sourceFile?: SourceFile): boolean;
9189
9249
  const unchangedTextChangeRange: TextChangeRange;
9190
9250
  type ParameterPropertyDeclaration = ParameterDeclaration & {
9191
9251
  parent: ConstructorDeclaration;
9192
9252
  name: Identifier;
9193
9253
  };
9254
+ function isPartOfTypeNode(node: Node): boolean;
9194
9255
  /**
9195
9256
  * This function checks multiple locations for JSDoc comments that apply to a host node.
9196
9257
  * At each location, the whole comment may apply to the node, or only a specific tag in
@@ -9829,7 +9890,7 @@ declare namespace ts {
9829
9890
  * @param visitor The callback used to visit each child.
9830
9891
  * @param context A lexical environment context for the visitor.
9831
9892
  */
9832
- 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;
9833
9894
  /**
9834
9895
  * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place.
9835
9896
  *
@@ -9837,7 +9898,7 @@ declare namespace ts {
9837
9898
  * @param visitor The callback used to visit each child.
9838
9899
  * @param context A lexical environment context for the visitor.
9839
9900
  */
9840
- 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;
9841
9902
  function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined;
9842
9903
  function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[];
9843
9904
  function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer;
@@ -9868,37 +9929,50 @@ declare namespace ts {
9868
9929
  */
9869
9930
  function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode;
9870
9931
  /**
9871
- * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
9872
- * 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).
9873
- * 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.
9874
9938
  * @param file File to fetch the resolution mode within
9875
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.
9876
9942
  */
9877
- function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
9943
+ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
9878
9944
  /**
9879
- * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
9880
- * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
9881
- * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
9882
- * `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.
9883
9951
  * @param file The file the import or import-like reference is contained within
9884
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.
9885
9955
  * @returns The final resolution mode of the import
9886
9956
  */
9887
- function getModeForUsageLocation(file: {
9888
- impliedNodeFormat?: ResolutionMode;
9889
- }, 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;
9890
9964
  function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
9891
9965
  /**
9892
9966
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
9893
9967
  * `options` parameter.
9894
9968
  *
9895
- * @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)
9896
9970
  * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
9897
9971
  * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
9898
9972
  * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
9899
9973
  * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
9900
9974
  */
9901
- 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;
9902
9976
  /**
9903
9977
  * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions'
9904
9978
  * that represent a compilation unit.
@@ -10416,7 +10490,7 @@ declare namespace ts {
10416
10490
  installPackage?(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
10417
10491
  writeFile?(fileName: string, content: string): void;
10418
10492
  getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
10419
- jsDocParsingMode?: JSDocParsingMode;
10493
+ jsDocParsingMode?: JSDocParsingMode | undefined;
10420
10494
  }
10421
10495
  type WithMetadata<T> = T & {
10422
10496
  metadata?: unknown;
@@ -11085,6 +11159,10 @@ declare namespace ts {
11085
11159
  */
11086
11160
  fileToRename?: string;
11087
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
+ */
11088
11166
  fullDisplayName: string;
11089
11167
  kind: ScriptElementKind;
11090
11168
  kindModifiers: string;
@@ -11612,6 +11690,7 @@ declare namespace ts {
11612
11690
  moduleName?: string;
11613
11691
  renamedDependencies?: MapLike<string>;
11614
11692
  transformers?: CustomTransformers;
11693
+ jsDocParsingMode?: JSDocParsingMode;
11615
11694
  }
11616
11695
  interface TranspileOutput {
11617
11696
  outputText: string;