typescript 5.4.0-dev.20240119 → 5.4.0-dev.20240120

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.
@@ -3036,10 +3036,18 @@ declare namespace ts {
3036
3036
  ES6 = "ES6",
3037
3037
  ES2015 = "ES2015",
3038
3038
  ESNext = "ESNext",
3039
+ Node16 = "Node16",
3040
+ NodeNext = "NodeNext",
3041
+ Preserve = "Preserve",
3039
3042
  }
3040
3043
  enum ModuleResolutionKind {
3041
3044
  Classic = "Classic",
3045
+ /** @deprecated Renamed to `Node10` */
3042
3046
  Node = "Node",
3047
+ Node10 = "Node10",
3048
+ Node16 = "Node16",
3049
+ NodeNext = "NodeNext",
3050
+ Bundler = "Bundler",
3043
3051
  }
3044
3052
  enum NewLineKind {
3045
3053
  Crlf = "Crlf",
@@ -6660,6 +6668,22 @@ declare namespace ts {
6660
6668
  };
6661
6669
  isSourceFileFromExternalLibrary(file: SourceFile): boolean;
6662
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;
6663
6687
  getProjectReferences(): readonly ProjectReference[] | undefined;
6664
6688
  getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined;
6665
6689
  }
@@ -6868,6 +6892,7 @@ declare namespace ts {
6868
6892
  * True if this type is assignable to `ReadonlyArray<any>`.
6869
6893
  */
6870
6894
  isArrayLikeType(type: Type): boolean;
6895
+ resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
6871
6896
  getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
6872
6897
  /**
6873
6898
  * Depending on the operation performed, it may be appropriate to throw away the checker
@@ -7007,6 +7032,7 @@ declare namespace ts {
7007
7032
  Transient = 33554432,
7008
7033
  Assignment = 67108864,
7009
7034
  ModuleExports = 134217728,
7035
+ All = -1,
7010
7036
  Enum = 384,
7011
7037
  Variable = 3,
7012
7038
  Value = 111551,
@@ -7641,6 +7667,7 @@ declare namespace ts {
7641
7667
  ESNext = 99,
7642
7668
  Node16 = 100,
7643
7669
  NodeNext = 199,
7670
+ Preserve = 200,
7644
7671
  }
7645
7672
  enum JsxEmit {
7646
7673
  None = 0,
@@ -9902,25 +9929,38 @@ declare namespace ts {
9902
9929
  */
9903
9930
  function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode;
9904
9931
  /**
9905
- * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
9906
- * 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).
9907
- * 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.
9908
9938
  * @param file File to fetch the resolution mode within
9909
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.
9910
9942
  */
9911
- function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
9943
+ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
9912
9944
  /**
9913
- * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
9914
- * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
9915
- * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
9916
- * `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.
9917
9951
  * @param file The file the import or import-like reference is contained within
9918
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.
9919
9955
  * @returns The final resolution mode of the import
9920
9956
  */
9921
- function getModeForUsageLocation(file: {
9922
- impliedNodeFormat?: ResolutionMode;
9923
- }, 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;
9924
9964
  function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
9925
9965
  /**
9926
9966
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the