typescript 7.1.0-dev.20261124.1 → 7.1.0-dev.20261126.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 (100) 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 -41
  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 +58 -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 +9 -1
  34. package/dist/api/printer.d.ts.map +1 -1
  35. package/dist/api/printer.js +47 -1
  36. package/dist/api/printer.js.map +1 -1
  37. package/dist/api/proto.d.ts.map +1 -1
  38. package/dist/api/proto.generated.d.ts +13 -1
  39. package/dist/api/proto.generated.d.ts.map +1 -1
  40. package/dist/api/proto.js +2 -2
  41. package/dist/api/proto.js.map +1 -1
  42. package/dist/api/sourceFileCache.d.ts +4 -4
  43. package/dist/api/sourceFileCache.d.ts.map +1 -1
  44. package/dist/api/sourceFileCache.js +2 -1
  45. package/dist/api/sourceFileCache.js.map +1 -1
  46. package/dist/api/sync/api.d.ts +10 -6
  47. package/dist/api/sync/api.d.ts.map +1 -1
  48. package/dist/api/sync/api.js +62 -52
  49. package/dist/api/sync/api.js.map +1 -1
  50. package/dist/api/sync/client.js +1 -1
  51. package/dist/api/sync/client.js.map +1 -1
  52. package/dist/api/sync/generatorSupport.js +4 -4
  53. package/dist/api/sync/generatorSupport.js.map +1 -1
  54. package/dist/api/sync/transportClient.js.map +1 -1
  55. package/dist/api/syncChannel.js +7 -7
  56. package/dist/api/syncChannel.js.map +1 -1
  57. package/dist/api/timing.d.ts +0 -14
  58. package/dist/api/timing.d.ts.map +1 -1
  59. package/dist/api/timing.js +1 -1
  60. package/dist/api/timingDump.d.ts.map +1 -1
  61. package/dist/api/timingDump.js +1 -0
  62. package/dist/api/timingDump.js.map +1 -1
  63. package/dist/ast/astnav.js.map +1 -1
  64. package/dist/ast/clone.d.ts +6 -8
  65. package/dist/ast/clone.d.ts.map +1 -1
  66. package/dist/ast/clone.js +6 -11
  67. package/dist/ast/clone.js.map +1 -1
  68. package/dist/ast/factory.generated.d.ts.map +1 -1
  69. package/dist/ast/factory.generated.js +186 -181
  70. package/dist/ast/factory.generated.js.map +1 -1
  71. package/dist/ast/is.d.ts.map +1 -1
  72. package/dist/ast/is.js +3 -9
  73. package/dist/ast/is.js.map +1 -1
  74. package/dist/ast/scanner.d.ts.map +1 -1
  75. package/dist/ast/scanner.js +2 -17
  76. package/dist/ast/scanner.js.map +1 -1
  77. package/dist/ast/spanMap.d.ts.map +1 -1
  78. package/dist/ast/spanMap.js +21 -17
  79. package/dist/ast/spanMap.js.map +1 -1
  80. package/dist/ast/utils.d.ts +11 -1
  81. package/dist/ast/utils.d.ts.map +1 -1
  82. package/dist/ast/utils.js +39 -20
  83. package/dist/ast/utils.js.map +1 -1
  84. package/dist/ast/visitor.d.ts.map +1 -1
  85. package/dist/ast/visitor.js +9 -2
  86. package/dist/ast/visitor.js.map +1 -1
  87. package/dist/vscode/extensionApi.d.ts +2 -2
  88. package/dist/vscode/extensionApi.d.ts.map +1 -1
  89. package/dist/vscode/moduleLoader.d.ts.map +1 -1
  90. package/dist/vscode/moduleLoader.js +6 -1
  91. package/dist/vscode/moduleLoader.js.map +1 -1
  92. package/dist/wasm/transport.d.ts +1 -1
  93. package/dist/wasm/transport.d.ts.map +1 -1
  94. package/dist/wasm/transport.js +3 -2
  95. package/dist/wasm/transport.js.map +1 -1
  96. package/dist/wasm/wasi.d.ts +2 -4
  97. package/dist/wasm/wasi.d.ts.map +1 -1
  98. package/dist/wasm/wasi.js +6 -6
  99. package/dist/wasm/wasi.js.map +1 -1
  100. 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, sourceFileDescriptor, } 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
  }
@@ -828,16 +842,6 @@ export class API {
828
842
  });
829
843
  }
830
844
  }
831
- function sourceFileDescriptor(sourceFile) {
832
- return {
833
- fileName: sourceFile.fileName,
834
- path: sourceFile.path,
835
- contentHash: sourceFile.contentHash,
836
- parseOptionsKey: sourceFile.parseOptionsKey,
837
- scriptKind: sourceFile.scriptKind,
838
- nodeId: sourceFile.nodeId,
839
- };
840
- }
841
845
  /** Returns whether a node is backed by a remote compiler response. */
842
846
  export function isRemoteNode(node) {
843
847
  return node instanceof RemoteNode;
@@ -856,19 +860,19 @@ function getNodeAPI(node) {
856
860
  throw new Error("Source file does not belong to the sync API");
857
861
  return api;
858
862
  }
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);
863
+ export function getSymbol(node) {
864
+ const api = getNodeAPI(node);
862
865
  if (!api)
863
866
  throw new Error("Source file not found for declaration");
864
- return api.getSymbol(declaration);
867
+ return api.getSymbol(node);
865
868
  }
866
- getSymbol.gen = function* (declaration) {
867
- const api = getNodeAPI(declaration);
869
+ function* getSymbolGenerator(node) {
870
+ const api = getNodeAPI(node);
868
871
  if (!api)
869
872
  throw new Error("Source file not found for declaration");
870
- return yield* api.getSymbol.gen(declaration);
871
- };
873
+ return yield* api.getSymbol.gen(node);
874
+ }
875
+ getSymbol.gen = getSymbolGenerator;
872
876
  /** An independently retained source file and its disposable remote-lifetime lease. */
873
877
  export class RetainedSourceFile {
874
878
  sourceFile;
@@ -944,10 +948,12 @@ export class DebugHandlers {
944
948
  const owner = this;
945
949
  return cacheGeneratorMethod(owner, "stopCPUProfile", function () {
946
950
  owner.ensureInitialized();
947
- const result = owner.client.apiRequest("stopCPUProfile", null);
951
+ // eslint-disable-next-line no-restricted-syntax -- The stopCPUProfile request requires null parameters.
952
+ const result = owner.client.apiRequest("stopCPUProfile", /*params*/ null);
948
953
  return result.file;
949
954
  }, function* () {
950
955
  yield* owner.ensureInitialized.gen();
956
+ // eslint-disable-next-line no-restricted-syntax -- The stopCPUProfile request requires null parameters.
951
957
  const result = yield* apiRequest("stopCPUProfile", null);
952
958
  return result.file;
953
959
  });
@@ -1490,7 +1496,7 @@ class ProjectObjectRegistry {
1490
1496
  project: owner.project.handle,
1491
1497
  objectId: source.id,
1492
1498
  });
1493
- if (typesData == null)
1499
+ if (typesData == undefined)
1494
1500
  return [];
1495
1501
  else
1496
1502
  return typesData.map(data => owner.getOrCreateType(data));
@@ -1514,7 +1520,7 @@ class ProjectObjectRegistry {
1514
1520
  project: owner.project.handle,
1515
1521
  objectId: source.id,
1516
1522
  });
1517
- if (typesData == null)
1523
+ if (typesData == undefined)
1518
1524
  return [];
1519
1525
  else
1520
1526
  return typesData.map(data => owner.getOrCreateType(data));
@@ -1582,7 +1588,7 @@ class ProjectObjectRegistry {
1582
1588
  project: owner.project.handle,
1583
1589
  type: source.id,
1584
1590
  });
1585
- if (typesData == null)
1591
+ if (typesData == undefined)
1586
1592
  return [];
1587
1593
  return typesData.map(data => owner.getOrCreateType(data));
1588
1594
  }, function* (source) {
@@ -1591,7 +1597,7 @@ class ProjectObjectRegistry {
1591
1597
  project: owner.project.handle,
1592
1598
  type: source.id,
1593
1599
  });
1594
- if (typesData == null)
1600
+ if (typesData == undefined)
1595
1601
  return [];
1596
1602
  return typesData.map(data => owner.getOrCreateType(data));
1597
1603
  });
@@ -2396,7 +2402,7 @@ export class Program {
2396
2402
  if (!binaryData) {
2397
2403
  return undefined;
2398
2404
  }
2399
- return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
2405
+ return new RemoteSourceFile(binaryData, owner.decoder, /*timing*/ undefined, owner.project.api);
2400
2406
  }, function* (file) {
2401
2407
  const binaryData = sourceFileResponseToUint8Array(yield* apiRequest("getConfigSourceFile", {
2402
2408
  snapshot: owner.snapshotId,
@@ -2406,7 +2412,7 @@ export class Program {
2406
2412
  if (!binaryData) {
2407
2413
  return undefined;
2408
2414
  }
2409
- return new RemoteSourceFile(binaryData, owner.decoder, undefined, owner.project.api);
2415
+ return new RemoteSourceFile(binaryData, owner.decoder, /*timing*/ undefined, owner.project.api);
2410
2416
  });
2411
2417
  }
2412
2418
  /**
@@ -2872,6 +2878,9 @@ function encodeNumberLiteralValue(value) {
2872
2878
  return "NaN";
2873
2879
  return value;
2874
2880
  }
2881
+ function isNodeLocation(location) {
2882
+ return !!location.kind;
2883
+ }
2875
2884
  export class Checker {
2876
2885
  /** Get the original symbols underlying a synthetic, instantiated, or mapped property. */
2877
2886
  get getRootSymbols() {
@@ -3414,7 +3423,7 @@ export class Checker {
3414
3423
  const owner = this;
3415
3424
  return cacheGeneratorMethod(owner, "resolveName", function (name, meaning, location, excludeGlobals) {
3416
3425
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3417
- const isNode = location && "kind" in location;
3426
+ const isNode = location && isNodeLocation(location);
3418
3427
  const data = owner.client.apiRequest("resolveName", {
3419
3428
  snapshot: owner.snapshotId,
3420
3429
  project: owner.project.handle,
@@ -3428,7 +3437,7 @@ export class Checker {
3428
3437
  return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
3429
3438
  }, function* (name, meaning, location, excludeGlobals) {
3430
3439
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3431
- const isNode = location && "kind" in location;
3440
+ const isNode = location && isNodeLocation(location);
3432
3441
  const data = yield* apiRequest("resolveName", {
3433
3442
  snapshot: owner.snapshotId,
3434
3443
  project: owner.project.handle,
@@ -3449,7 +3458,7 @@ export class Checker {
3449
3458
  const owner = this;
3450
3459
  return cacheGeneratorMethod(owner, "getSymbolsInScope", function (location, meaning) {
3451
3460
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3452
- const isNode = "kind" in location;
3461
+ const isNode = isNodeLocation(location);
3453
3462
  const data = owner.client.apiRequest("getSymbolsInScope", {
3454
3463
  snapshot: owner.snapshotId,
3455
3464
  project: owner.project.handle,
@@ -3461,7 +3470,7 @@ export class Checker {
3461
3470
  return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
3462
3471
  }, function* (location, meaning) {
3463
3472
  // Distinguish Node (has `kind`) from DocumentPosition (has `document` and `position`)
3464
- const isNode = "kind" in location;
3473
+ const isNode = isNodeLocation(location);
3465
3474
  const data = yield* apiRequest("getSymbolsInScope", {
3466
3475
  snapshot: owner.snapshotId,
3467
3476
  project: owner.project.handle,
@@ -5184,7 +5193,7 @@ export class Symbol {
5184
5193
  // A file-owned symbol has no canonical project; its declarations resolve through its file.
5185
5194
  return this.storage.kind === SymbolOwnerKind.Snapshot
5186
5195
  ? this.storage.registry.createNodeHandle(handle)
5187
- : new NodeHandle(handle, undefined, this.storage.owner);
5196
+ : new NodeHandle(handle, /*canonicalProject*/ undefined, this.storage.owner);
5188
5197
  }
5189
5198
  get getParent() {
5190
5199
  const owner = this;
@@ -5388,10 +5397,11 @@ class TypeObject {
5388
5397
  this.objectFlags = data.objectFlags ?? 0;
5389
5398
  if (data.symbol !== undefined)
5390
5399
  this.symbol = data.symbol;
5391
- if (data.value != null) {
5400
+ const typeValue = data.value;
5401
+ if (typeValue != undefined) {
5392
5402
  // BigInt literal values are serialized as decimal strings (e.g. "-123") because
5393
5403
  // JSON cannot represent bigint. Decode them back into a real bigint here.
5394
- const value = data.value;
5404
+ const value = typeValue;
5395
5405
  if (data.flags & TypeFlags.BigIntLiteral) {
5396
5406
  this.value = BigInt(value);
5397
5407
  }
@@ -5734,7 +5744,7 @@ class TypeObject {
5734
5744
  return cacheGeneratorMethod(owner, "getThisType", function () {
5735
5745
  return owner.objectRegistry.fetchOptionalType(owner, "getThisTypeOfType", owner.thisType);
5736
5746
  }, function* () {
5737
- return (yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getThisTypeOfType", owner.thisType));
5747
+ return yield* owner.objectRegistry.fetchOptionalType.gen(owner, "getThisTypeOfType", owner.thisType);
5738
5748
  });
5739
5749
  }
5740
5750
  get getAliasTypeArguments() {