typescript 5.6.0-dev.20240613 → 5.6.0-dev.20240614

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.
package/lib/tsserver.js CHANGED
@@ -159,18 +159,6 @@ function initializeNodeSystem() {
159
159
  return this.loggingEnabled() && this.level >= level;
160
160
  }
161
161
  msg(s, type = typescript_exports.server.Msg.Err) {
162
- var _a, _b, _c;
163
- switch (type) {
164
- case typescript_exports.server.Msg.Info:
165
- (_a = typescript_exports.perfLogger) == null ? void 0 : _a.logInfoEvent(s);
166
- break;
167
- case typescript_exports.server.Msg.Perf:
168
- (_b = typescript_exports.perfLogger) == null ? void 0 : _b.logPerfEvent(s);
169
- break;
170
- default:
171
- (_c = typescript_exports.perfLogger) == null ? void 0 : _c.logErrEvent(s);
172
- break;
173
- }
174
162
  if (!this.canWrite()) return;
175
163
  s = `[${typescript_exports.server.nowString()}] ${s}
176
164
  `;
@@ -584,23 +584,7 @@ declare namespace ts {
584
584
  }
585
585
  export interface ApplyCodeActionCommandResponse extends Response {
586
586
  }
587
- export interface FileRangeRequestArgs extends FileRequestArgs {
588
- /**
589
- * The line number for the request (1-based).
590
- */
591
- startLine: number;
592
- /**
593
- * The character offset (on the line) for the request (1-based).
594
- */
595
- startOffset: number;
596
- /**
597
- * The line number for the request (1-based).
598
- */
599
- endLine: number;
600
- /**
601
- * The character offset (on the line) for the request (1-based).
602
- */
603
- endOffset: number;
587
+ export interface FileRangeRequestArgs extends FileRequestArgs, FileRange {
604
588
  }
605
589
  /**
606
590
  * Instances of this interface specify errorcodes on a specific location in a sourcefile.
@@ -1866,7 +1850,7 @@ declare namespace ts {
1866
1850
  * List of file names for which to compute compiler errors.
1867
1851
  * The files will be checked in list order.
1868
1852
  */
1869
- files: string[];
1853
+ files: (string | FileRangesRequestArgs)[];
1870
1854
  /**
1871
1855
  * Delay in milliseconds to wait before starting to compute
1872
1856
  * errors for the files in the file list
@@ -1887,6 +1871,27 @@ declare namespace ts {
1887
1871
  command: CommandTypes.Geterr;
1888
1872
  arguments: GeterrRequestArgs;
1889
1873
  }
1874
+ export interface FileRange {
1875
+ /**
1876
+ * The line number for the request (1-based).
1877
+ */
1878
+ startLine: number;
1879
+ /**
1880
+ * The character offset (on the line) for the request (1-based).
1881
+ */
1882
+ startOffset: number;
1883
+ /**
1884
+ * The line number for the request (1-based).
1885
+ */
1886
+ endLine: number;
1887
+ /**
1888
+ * The character offset (on the line) for the request (1-based).
1889
+ */
1890
+ endOffset: number;
1891
+ }
1892
+ export interface FileRangesRequestArgs extends Pick<FileRequestArgs, "file"> {
1893
+ ranges: FileRange[];
1894
+ }
1890
1895
  export type RequestCompletedEventName = "requestCompleted";
1891
1896
  /**
1892
1897
  * Event that is sent when server have finished processing request with specified id.
@@ -1969,8 +1974,16 @@ declare namespace ts {
1969
1974
  * An array of diagnostic information items.
1970
1975
  */
1971
1976
  diagnostics: Diagnostic[];
1977
+ /**
1978
+ * Spans where the region diagnostic was requested, if this is a region semantic diagnostic event.
1979
+ */
1980
+ spans?: TextSpan[];
1981
+ /**
1982
+ * Time spent computing the diagnostics, in milliseconds.
1983
+ */
1984
+ duration?: number;
1972
1985
  }
1973
- export type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag";
1986
+ export type DiagnosticEventKind = "semanticDiag" | "syntaxDiag" | "suggestionDiag" | "regionSemanticDiag";
1974
1987
  /**
1975
1988
  * Event message for DiagnosticEventKind event types.
1976
1989
  * These events provide syntactic and semantic errors for a file.
@@ -3386,10 +3399,6 @@ declare namespace ts {
3386
3399
  resetRequest(requestId: number): void;
3387
3400
  }
3388
3401
  const nullCancellationToken: ServerCancellationToken;
3389
- interface PendingErrorCheck {
3390
- fileName: NormalizedPath;
3391
- project: Project;
3392
- }
3393
3402
  /** @deprecated use ts.server.protocol.CommandTypes */
3394
3403
  type CommandNames = protocol.CommandTypes;
3395
3404
  /** @deprecated use ts.server.protocol.CommandTypes */
@@ -3460,6 +3469,7 @@ declare namespace ts {
3460
3469
  private semanticCheck;
3461
3470
  private syntacticCheck;
3462
3471
  private suggestionCheck;
3472
+ private regionSemanticCheck;
3463
3473
  private sendDiagnosticsEvent;
3464
3474
  /** It is the caller's responsibility to verify that `!this.suppressDiagnosticEvents`. */
3465
3475
  private updateErrorCheck;
@@ -6015,67 +6025,19 @@ declare namespace ts {
6015
6025
  isSourceFileFromExternalLibrary(file: SourceFile): boolean;
6016
6026
  isSourceFileDefaultLibrary(file: SourceFile): boolean;
6017
6027
  /**
6018
- * Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
6019
- * settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
6020
- * which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
6021
- * overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
6022
- * Some examples:
6023
- *
6024
- * ```ts
6025
- * // tsc foo.mts --module nodenext
6026
- * import {} from "mod";
6027
- * // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
6028
- *
6029
- * // tsc foo.cts --module nodenext
6030
- * import {} from "mod";
6031
- * // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
6032
- *
6033
- * // tsc foo.ts --module preserve --moduleResolution bundler
6034
- * import {} from "mod";
6035
- * // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
6036
- * // supports conditional imports/exports
6037
- *
6038
- * // tsc foo.ts --module preserve --moduleResolution node10
6039
- * import {} from "mod";
6040
- * // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
6041
- * // does not support conditional imports/exports
6042
- *
6043
- * // tsc foo.ts --module commonjs --moduleResolution node10
6044
- * import type {} from "mod" with { "resolution-mode": "import" };
6045
- * // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
6046
- * ```
6028
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
6029
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
6030
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
6031
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
6032
+ * impact on module resolution, emit, or type checking.
6047
6033
  */
6048
6034
  getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode;
6049
6035
  /**
6050
- * Calculates the final resolution mode for an import at some index within a file's `imports` list. This function only returns a result
6051
- * when module resolution settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided
6052
- * via import attributes, which cause an `import` or `require` condition to be used during resolution regardless of module resolution
6053
- * settings. In absence of overriding attributes, and in modes that support differing resolution, the result indicates the syntax the
6054
- * usage would emit to JavaScript. Some examples:
6055
- *
6056
- * ```ts
6057
- * // tsc foo.mts --module nodenext
6058
- * import {} from "mod";
6059
- * // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
6060
- *
6061
- * // tsc foo.cts --module nodenext
6062
- * import {} from "mod";
6063
- * // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
6064
- *
6065
- * // tsc foo.ts --module preserve --moduleResolution bundler
6066
- * import {} from "mod";
6067
- * // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
6068
- * // supports conditional imports/exports
6069
- *
6070
- * // tsc foo.ts --module preserve --moduleResolution node10
6071
- * import {} from "mod";
6072
- * // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
6073
- * // does not support conditional imports/exports
6074
- *
6075
- * // tsc foo.ts --module commonjs --moduleResolution node10
6076
- * import type {} from "mod" with { "resolution-mode": "import" };
6077
- * // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
6078
- * ```
6036
+ * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode
6037
+ * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In
6038
+ * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the
6039
+ * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns
6040
+ * `undefined`, as the result would have no impact on module resolution, emit, or type checking.
6079
6041
  */
6080
6042
  getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode;
6081
6043
  getProjectReferences(): readonly ProjectReference[] | undefined;
@@ -9429,43 +9391,24 @@ declare namespace ts {
9429
9391
  function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode;
9430
9392
  /**
9431
9393
  * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible.
9432
- * Calculates the final resolution mode for a given module reference node. This function only returns a result when module resolution
9433
- * settings allow differing resolution between ESM imports and CJS requires, or when a mode is explicitly provided via import attributes,
9434
- * which cause an `import` or `require` condition to be used during resolution regardless of module resolution settings. In absence of
9435
- * overriding attributes, and in modes that support differing resolution, the result indicates the syntax the usage would emit to JavaScript.
9436
- * Some examples:
9437
- *
9438
- * ```ts
9439
- * // tsc foo.mts --module nodenext
9440
- * import {} from "mod";
9441
- * // Result: ESNext - the import emits as ESM due to `impliedNodeFormat` set by .mts file extension
9442
- *
9443
- * // tsc foo.cts --module nodenext
9444
- * import {} from "mod";
9445
- * // Result: CommonJS - the import emits as CJS due to `impliedNodeFormat` set by .cts file extension
9446
- *
9447
- * // tsc foo.ts --module preserve --moduleResolution bundler
9448
- * import {} from "mod";
9449
- * // Result: ESNext - the import emits as ESM due to `--module preserve` and `--moduleResolution bundler`
9450
- * // supports conditional imports/exports
9451
- *
9452
- * // tsc foo.ts --module preserve --moduleResolution node10
9453
- * import {} from "mod";
9454
- * // Result: undefined - the import emits as ESM due to `--module preserve`, but `--moduleResolution node10`
9455
- * // does not support conditional imports/exports
9456
- *
9457
- * // tsc foo.ts --module commonjs --moduleResolution node10
9458
- * import type {} from "mod" with { "resolution-mode": "import" };
9459
- * // Result: ESNext - conditional imports/exports always supported with "resolution-mode" attribute
9460
- * ```
9461
- *
9394
+ * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import
9395
+ * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may
9396
+ * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other
9397
+ * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no
9398
+ * impact on module resolution, emit, or type checking.
9462
9399
  * @param file The file the import or import-like reference is contained within
9463
9400
  * @param usage The module reference string
9464
9401
  * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options
9465
9402
  * should be the options of the referenced project, not the referencing project.
9466
9403
  * @returns The final resolution mode of the import
9467
9404
  */
9468
- function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike, compilerOptions: CompilerOptions): ResolutionMode;
9405
+ function getModeForUsageLocation(
9406
+ file: {
9407
+ impliedNodeFormat?: ResolutionMode;
9408
+ },
9409
+ usage: StringLiteralLike,
9410
+ compilerOptions: CompilerOptions,
9411
+ ): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
9469
9412
  function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
9470
9413
  /**
9471
9414
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the