typescript 7.1.0-dev.20261124.1 → 7.1.0-dev.20261125.1

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 (90) hide show
  1. package/dist/api/async/api.d.ts +6 -4
  2. package/dist/api/async/api.d.ts.map +1 -1
  3. package/dist/api/async/api.js +42 -31
  4. package/dist/api/async/api.js.map +1 -1
  5. package/dist/api/async/client.js +4 -4
  6. package/dist/api/async/client.js.map +1 -1
  7. package/dist/api/async/jsonrpc.d.ts +3 -2
  8. package/dist/api/async/jsonrpc.d.ts.map +1 -1
  9. package/dist/api/async/jsonrpc.js +1 -1
  10. package/dist/api/async/jsonrpc.js.map +1 -1
  11. package/dist/api/async/transportClient.js +1 -2
  12. package/dist/api/async/transportClient.js.map +1 -1
  13. package/dist/api/fsCallbacks.js +6 -6
  14. package/dist/api/fsCallbacks.js.map +1 -1
  15. package/dist/api/node/encoder.d.ts.map +1 -1
  16. package/dist/api/node/encoder.js +5 -5
  17. package/dist/api/node/encoder.js.map +1 -1
  18. package/dist/api/node/msgpack.js +6 -6
  19. package/dist/api/node/msgpack.js.map +1 -1
  20. package/dist/api/node/node.d.ts.map +1 -1
  21. package/dist/api/node/node.infrastructure.d.ts.map +1 -1
  22. package/dist/api/node/node.infrastructure.js +13 -13
  23. package/dist/api/node/node.infrastructure.js.map +1 -1
  24. package/dist/api/node/node.js +30 -30
  25. package/dist/api/node/node.js.map +1 -1
  26. package/dist/api/node/wtf8.d.ts.map +1 -1
  27. package/dist/api/node/wtf8.js +2 -2
  28. package/dist/api/node/wtf8.js.map +1 -1
  29. package/dist/api/options.js +2 -2
  30. package/dist/api/options.js.map +1 -1
  31. package/dist/api/path.js +3 -3
  32. package/dist/api/path.js.map +1 -1
  33. package/dist/api/printer.d.ts.map +1 -1
  34. package/dist/api/printer.js.map +1 -1
  35. package/dist/api/proto.d.ts.map +1 -1
  36. package/dist/api/proto.generated.d.ts +1 -1
  37. package/dist/api/proto.generated.d.ts.map +1 -1
  38. package/dist/api/proto.js +2 -2
  39. package/dist/api/proto.js.map +1 -1
  40. package/dist/api/sourceFileCache.d.ts +4 -4
  41. package/dist/api/sourceFileCache.d.ts.map +1 -1
  42. package/dist/api/sourceFileCache.js +2 -1
  43. package/dist/api/sourceFileCache.js.map +1 -1
  44. package/dist/api/sync/api.d.ts +10 -6
  45. package/dist/api/sync/api.d.ts.map +1 -1
  46. package/dist/api/sync/api.js +62 -42
  47. package/dist/api/sync/api.js.map +1 -1
  48. package/dist/api/sync/client.js +1 -1
  49. package/dist/api/sync/client.js.map +1 -1
  50. package/dist/api/sync/generatorSupport.js +4 -4
  51. package/dist/api/sync/generatorSupport.js.map +1 -1
  52. package/dist/api/sync/transportClient.js.map +1 -1
  53. package/dist/api/syncChannel.js +7 -7
  54. package/dist/api/syncChannel.js.map +1 -1
  55. package/dist/api/timing.d.ts +0 -14
  56. package/dist/api/timing.d.ts.map +1 -1
  57. package/dist/api/timing.js +1 -1
  58. package/dist/api/timingDump.d.ts.map +1 -1
  59. package/dist/api/timingDump.js +1 -0
  60. package/dist/api/timingDump.js.map +1 -1
  61. package/dist/ast/astnav.js.map +1 -1
  62. package/dist/ast/is.d.ts.map +1 -1
  63. package/dist/ast/is.js +3 -9
  64. package/dist/ast/is.js.map +1 -1
  65. package/dist/ast/scanner.d.ts.map +1 -1
  66. package/dist/ast/scanner.js +2 -17
  67. package/dist/ast/scanner.js.map +1 -1
  68. package/dist/ast/spanMap.d.ts.map +1 -1
  69. package/dist/ast/spanMap.js +21 -17
  70. package/dist/ast/spanMap.js.map +1 -1
  71. package/dist/ast/utils.d.ts +1 -1
  72. package/dist/ast/utils.d.ts.map +1 -1
  73. package/dist/ast/utils.js +16 -20
  74. package/dist/ast/utils.js.map +1 -1
  75. package/dist/ast/visitor.d.ts.map +1 -1
  76. package/dist/ast/visitor.js.map +1 -1
  77. package/dist/vscode/extensionApi.d.ts +2 -2
  78. package/dist/vscode/extensionApi.d.ts.map +1 -1
  79. package/dist/vscode/moduleLoader.d.ts.map +1 -1
  80. package/dist/vscode/moduleLoader.js +6 -1
  81. package/dist/vscode/moduleLoader.js.map +1 -1
  82. package/dist/wasm/transport.d.ts +1 -1
  83. package/dist/wasm/transport.d.ts.map +1 -1
  84. package/dist/wasm/transport.js +3 -2
  85. package/dist/wasm/transport.js.map +1 -1
  86. package/dist/wasm/wasi.d.ts +2 -4
  87. package/dist/wasm/wasi.d.ts.map +1 -1
  88. package/dist/wasm/wasi.js +6 -6
  89. package/dist/wasm/wasi.js.map +1 -1
  90. package/package.json +9 -9
@@ -24,7 +24,7 @@ import { TypePredicateKind } from "../../../enums/typePredicateKind.js";
24
24
  import { ModifierFlags, symbolName, } from "../../ast/index.js";
25
25
  import { assertNever } from "../../internal/utils.js";
26
26
  import { encodeNode, sourceFileResponseToUint8Array, uint8ArrayToBase64, } from "../node/encoder.js";
27
- import { decodeNode, getNodeId, getNodeRequestHandle, parseNodeHandleFromCompiler, readParseOptionsKey, readSourceFileHash, readSourceFileLease, RemoteNode, RemoteSourceFile, } from "../node/node.js";
27
+ import { decodeNode, getNodeId, getNodeRequestHandle, parseNodeHandleFromCompiler, readSourceFileLease, RemoteNode, RemoteSourceFile, } from "../node/node.js";
28
28
  import { Wtf8Decoder } from "../node/wtf8.js";
29
29
  import { canonicalize, CaseSensitivity, pathKey, toRootedDirectoryPath, toRootedPath, } from "../path.js";
30
30
  import { prepareCompilerOptions } from "../prepareCompilerOptions.generated.js";
@@ -77,35 +77,35 @@ export class API {
77
77
  this.debug = new DebugHandlers(this.client, this.ensureInitialized);
78
78
  }
79
79
  /**
80
- * Looks up a remote declaration's binder symbol. Throws for synthesized or configuration ASTs.
80
+ * Looks up a remote node's binder symbol. Throws for synthesized or configuration ASTs.
81
81
  */
82
82
  get getSymbol() {
83
83
  const owner = this;
84
- return cacheGeneratorMethod(owner, "getSymbol", function (declaration) {
85
- const file = getRemoteSourceFile(declaration);
84
+ function getSymbol(node) {
85
+ const file = getRemoteSourceFile(node);
86
86
  if (!file)
87
87
  throw new Error(`Source file not found for declaration`);
88
88
  const record = file.symbolCache;
89
89
  if (!record)
90
90
  throw new Error(`Cached source file not found for declaration`);
91
- const index = parseNodeHandleFromCompiler(getNodeId(declaration)).index;
92
- const cached = record.symbolsByDeclarationNodeIndex.get(index);
93
- if (cached)
94
- return cached;
91
+ const index = parseNodeHandleFromCompiler(getNodeId(node)).index;
92
+ if (record.symbolsByDeclarationNodeIndex.has(index))
93
+ return record.symbolsByDeclarationNodeIndex.get(index);
95
94
  return owner.fetchDeclarationSymbol(record, index);
96
- }, function* (declaration) {
97
- const file = getRemoteSourceFile(declaration);
95
+ }
96
+ function* gen(node) {
97
+ const file = getRemoteSourceFile(node);
98
98
  if (!file)
99
99
  throw new Error(`Source file not found for declaration`);
100
100
  const record = file.symbolCache;
101
101
  if (!record)
102
102
  throw new Error(`Cached source file not found for declaration`);
103
- const index = parseNodeHandleFromCompiler(getNodeId(declaration)).index;
104
- const cached = record.symbolsByDeclarationNodeIndex.get(index);
105
- if (cached)
106
- return cached;
103
+ const index = parseNodeHandleFromCompiler(getNodeId(node)).index;
104
+ if (record.symbolsByDeclarationNodeIndex.has(index))
105
+ return record.symbolsByDeclarationNodeIndex.get(index);
107
106
  return yield* owner.fetchDeclarationSymbol.gen(record, index);
108
- });
107
+ }
108
+ return cacheGeneratorMethod(owner, "getSymbol", getSymbol, gen);
109
109
  }
110
110
  get fetchDeclarationSymbol() {
111
111
  const owner = this;
@@ -114,6 +114,10 @@ export class API {
114
114
  file: record.descriptor,
115
115
  index,
116
116
  });
117
+ if (!data) {
118
+ record.symbolsByDeclarationNodeIndex.set(index, undefined);
119
+ return undefined;
120
+ }
117
121
  validateSymbolResponse(data);
118
122
  const reference = data.reference;
119
123
  if (reference.kind !== SymbolOwnerKind.File) {
@@ -128,6 +132,10 @@ export class API {
128
132
  file: record.descriptor,
129
133
  index,
130
134
  });
135
+ if (!data) {
136
+ record.symbolsByDeclarationNodeIndex.set(index, undefined);
137
+ return undefined;
138
+ }
131
139
  validateSymbolResponse(data);
132
140
  const reference = data.reference;
133
141
  if (reference.kind !== SymbolOwnerKind.File) {
@@ -174,7 +182,8 @@ export class API {
174
182
  const owner = this;
175
183
  return cacheGeneratorMethod(owner, "initializeWorker", function () {
176
184
  try {
177
- const response = owner.client.apiRequest("initialize", null);
185
+ // eslint-disable-next-line no-restricted-syntax -- The initialize request requires null parameters.
186
+ const response = owner.client.apiRequest("initialize", /*params*/ null);
178
187
  owner.currentDirectory = response.currentDirectory;
179
188
  owner.caseSensitivity = response.caseSensitivity;
180
189
  owner.toPath = (fileName, basePath = response.currentDirectory) => pathKey(toRootedPath(fileName, toRootedDirectoryPath(basePath, response.currentDirectory)), response.caseSensitivity);
@@ -186,6 +195,7 @@ export class API {
186
195
  }
187
196
  }, function* () {
188
197
  try {
198
+ // eslint-disable-next-line no-restricted-syntax -- The initialize request requires null parameters.
189
199
  const response = yield* apiRequest("initialize", null);
190
200
  owner.currentDirectory = response.currentDirectory;
191
201
  owner.caseSensitivity = response.caseSensitivity;
@@ -256,9 +266,11 @@ export class API {
256
266
  const owner = this;
257
267
  return cacheGeneratorMethod(owner, "getDefaultFormatCodeSettings", function () {
258
268
  owner.ensureInitialized();
259
- return owner.client.apiRequest("getDefaultFormatCodeSettings", null);
269
+ // eslint-disable-next-line no-restricted-syntax -- The getDefaultFormatCodeSettings request requires null parameters.
270
+ return owner.client.apiRequest("getDefaultFormatCodeSettings", /*params*/ null);
260
271
  }, function* () {
261
272
  yield* owner.ensureInitialized.gen();
273
+ // eslint-disable-next-line no-restricted-syntax -- The getDefaultFormatCodeSettings request requires null parameters.
262
274
  return yield* apiRequest("getDefaultFormatCodeSettings", null);
263
275
  });
264
276
  }
@@ -488,7 +500,8 @@ export class API {
488
500
  const snapshot = new Snapshot(data, owner.toPath, owner, () => {
489
501
  owner.activeSnapshots.delete(snapshot.id);
490
502
  owner.sourceFileCache.releaseSnapshot(snapshot.id);
491
- }, owner.createSnapshotUpdater(() => snapshot), undefined);
503
+ }, owner.createSnapshotUpdater(() => snapshot),
504
+ /*baseSnapshot*/ undefined);
492
505
  owner.activeSnapshots.set(snapshot.id, snapshot);
493
506
  return snapshot;
494
507
  }
@@ -499,7 +512,8 @@ export class API {
499
512
  const snapshot = new Snapshot(data, owner.toPath, owner, () => {
500
513
  owner.activeSnapshots.delete(snapshot.id);
501
514
  owner.sourceFileCache.releaseSnapshot(snapshot.id);
502
- }, owner.createSnapshotUpdater(() => snapshot), undefined);
515
+ }, owner.createSnapshotUpdater(() => snapshot),
516
+ /*baseSnapshot*/ undefined);
503
517
  owner.activeSnapshots.set(snapshot.id, snapshot);
504
518
  return snapshot;
505
519
  }
@@ -856,19 +870,19 @@ function getNodeAPI(node) {
856
870
  throw new Error("Source file does not belong to the sync API");
857
871
  return api;
858
872
  }
859
- /** Looks up a remote declaration's binder symbol through its API. Throws for non-remote declarations. */
860
- export function getSymbol(declaration) {
861
- const api = getNodeAPI(declaration);
873
+ export function getSymbol(node) {
874
+ const api = getNodeAPI(node);
862
875
  if (!api)
863
876
  throw new Error("Source file not found for declaration");
864
- return api.getSymbol(declaration);
877
+ return api.getSymbol(node);
865
878
  }
866
- getSymbol.gen = function* (declaration) {
867
- const api = getNodeAPI(declaration);
879
+ function* getSymbolGenerator(node) {
880
+ const api = getNodeAPI(node);
868
881
  if (!api)
869
882
  throw new Error("Source file not found for declaration");
870
- return yield* api.getSymbol.gen(declaration);
871
- };
883
+ return yield* api.getSymbol.gen(node);
884
+ }
885
+ getSymbol.gen = getSymbolGenerator;
872
886
  /** An independently retained source file and its disposable remote-lifetime lease. */
873
887
  export class RetainedSourceFile {
874
888
  sourceFile;
@@ -944,10 +958,12 @@ export class DebugHandlers {
944
958
  const owner = this;
945
959
  return cacheGeneratorMethod(owner, "stopCPUProfile", function () {
946
960
  owner.ensureInitialized();
947
- const result = owner.client.apiRequest("stopCPUProfile", null);
961
+ // eslint-disable-next-line no-restricted-syntax -- The stopCPUProfile request requires null parameters.
962
+ const result = owner.client.apiRequest("stopCPUProfile", /*params*/ null);
948
963
  return result.file;
949
964
  }, function* () {
950
965
  yield* owner.ensureInitialized.gen();
966
+ // eslint-disable-next-line no-restricted-syntax -- The stopCPUProfile request requires null parameters.
951
967
  const result = yield* apiRequest("stopCPUProfile", null);
952
968
  return result.file;
953
969
  });
@@ -1490,7 +1506,7 @@ class ProjectObjectRegistry {
1490
1506
  project: owner.project.handle,
1491
1507
  objectId: source.id,
1492
1508
  });
1493
- if (typesData == null)
1509
+ if (typesData == undefined)
1494
1510
  return [];
1495
1511
  else
1496
1512
  return typesData.map(data => owner.getOrCreateType(data));
@@ -1514,7 +1530,7 @@ class ProjectObjectRegistry {
1514
1530
  project: owner.project.handle,
1515
1531
  objectId: source.id,
1516
1532
  });
1517
- if (typesData == null)
1533
+ if (typesData == undefined)
1518
1534
  return [];
1519
1535
  else
1520
1536
  return typesData.map(data => owner.getOrCreateType(data));
@@ -1582,7 +1598,7 @@ class ProjectObjectRegistry {
1582
1598
  project: owner.project.handle,
1583
1599
  type: source.id,
1584
1600
  });
1585
- if (typesData == null)
1601
+ if (typesData == undefined)
1586
1602
  return [];
1587
1603
  return typesData.map(data => owner.getOrCreateType(data));
1588
1604
  }, function* (source) {
@@ -1591,7 +1607,7 @@ class ProjectObjectRegistry {
1591
1607
  project: owner.project.handle,
1592
1608
  type: source.id,
1593
1609
  });
1594
- if (typesData == null)
1610
+ if (typesData == undefined)
1595
1611
  return [];
1596
1612
  return typesData.map(data => owner.getOrCreateType(data));
1597
1613
  });
@@ -2396,7 +2412,7 @@ export class Program {
2396
2412
  if (!binaryData) {
2397
2413
  return undefined;
2398
2414
  }
2399
- return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
2415
+ return new RemoteSourceFile(binaryData, owner.decoder, /*timing*/ undefined, owner.project.api);
2400
2416
  }, function* (file) {
2401
2417
  const binaryData = sourceFileResponseToUint8Array(yield* apiRequest("getConfigSourceFile", {
2402
2418
  snapshot: owner.snapshotId,
@@ -2406,7 +2422,7 @@ export class Program {
2406
2422
  if (!binaryData) {
2407
2423
  return undefined;
2408
2424
  }
2409
- return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
2425
+ return new RemoteSourceFile(binaryData, owner.decoder, /*timing*/ undefined, owner.project.api);
2410
2426
  });
2411
2427
  }
2412
2428
  /**
@@ -2872,6 +2888,9 @@ function encodeNumberLiteralValue(value) {
2872
2888
  return "NaN";
2873
2889
  return value;
2874
2890
  }
2891
+ function isNodeLocation(location) {
2892
+ return !!location.kind;
2893
+ }
2875
2894
  export class Checker {
2876
2895
  /** Get the original symbols underlying a synthetic, instantiated, or mapped property. */
2877
2896
  get getRootSymbols() {
@@ -3414,7 +3433,7 @@ export class Checker {
3414
3433
  const owner = this;
3415
3434
  return cacheGeneratorMethod(owner, "resolveName", function (name, meaning, location, excludeGlobals) {
3416
3435
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3417
- const isNode = location && "kind" in location;
3436
+ const isNode = location && isNodeLocation(location);
3418
3437
  const data = owner.client.apiRequest("resolveName", {
3419
3438
  snapshot: owner.snapshotId,
3420
3439
  project: owner.project.handle,
@@ -3428,7 +3447,7 @@ export class Checker {
3428
3447
  return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
3429
3448
  }, function* (name, meaning, location, excludeGlobals) {
3430
3449
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3431
- const isNode = location && "kind" in location;
3450
+ const isNode = location && isNodeLocation(location);
3432
3451
  const data = yield* apiRequest("resolveName", {
3433
3452
  snapshot: owner.snapshotId,
3434
3453
  project: owner.project.handle,
@@ -3449,7 +3468,7 @@ export class Checker {
3449
3468
  const owner = this;
3450
3469
  return cacheGeneratorMethod(owner, "getSymbolsInScope", function (location, meaning) {
3451
3470
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3452
- const isNode = "kind" in location;
3471
+ const isNode = isNodeLocation(location);
3453
3472
  const data = owner.client.apiRequest("getSymbolsInScope", {
3454
3473
  snapshot: owner.snapshotId,
3455
3474
  project: owner.project.handle,
@@ -3461,7 +3480,7 @@ export class Checker {
3461
3480
  return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
3462
3481
  }, function* (location, meaning) {
3463
3482
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3464
- const isNode = "kind" in location;
3483
+ const isNode = isNodeLocation(location);
3465
3484
  const data = yield* apiRequest("getSymbolsInScope", {
3466
3485
  snapshot: owner.snapshotId,
3467
3486
  project: owner.project.handle,
@@ -5184,7 +5203,7 @@ export class Symbol {
5184
5203
  // A file-owned symbol has no canonical project; its declarations resolve through its file.
5185
5204
  return this.storage.kind === SymbolOwnerKind.Snapshot
5186
5205
  ? this.storage.registry.createNodeHandle(handle)
5187
- : new NodeHandle(handle, undefined, this.storage.owner);
5206
+ : new NodeHandle(handle, /*canonicalProject*/ undefined, this.storage.owner);
5188
5207
  }
5189
5208
  get getParent() {
5190
5209
  const owner = this;
@@ -5388,10 +5407,11 @@ class TypeObject {
5388
5407
  this.objectFlags = data.objectFlags ?? 0;
5389
5408
  if (data.symbol !== undefined)
5390
5409
  this.symbol = data.symbol;
5391
- if (data.value != null) {
5410
+ const typeValue = data.value;
5411
+ if (typeValue != undefined) {
5392
5412
  // BigInt literal values are serialized as decimal strings (e.g. "-123") because
5393
5413
  // JSON cannot represent bigint. Decode them back into a real bigint here.
5394
- const value = data.value;
5414
+ const value = typeValue;
5395
5415
  if (data.flags & TypeFlags.BigIntLiteral) {
5396
5416
  this.value = BigInt(value);
5397
5417
  }
@@ -5734,7 +5754,7 @@ class TypeObject {
5734
5754
  return cacheGeneratorMethod(owner, "getThisType", function () {
5735
5755
  return owner.objectRegistry.fetchOptionalType(owner, "getThisTypeOfType", owner.thisType);
5736
5756
  }, function* () {
5737
- return (yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getThisTypeOfType", owner.thisType));
5757
+ return yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getThisTypeOfType", owner.thisType);
5738
5758
  });
5739
5759
  }
5740
5760
  get getAliasTypeArguments() {