@typescript/native-preview 7.0.0-dev.20260701.1 → 7.0.0-dev.20260702.3

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 (73) hide show
  1. package/dist/api/async/api.d.ts +35 -18
  2. package/dist/api/async/api.d.ts.map +1 -1
  3. package/dist/api/async/api.js +135 -107
  4. package/dist/api/async/api.js.map +1 -1
  5. package/dist/api/compilerOptions.d.ts +109 -0
  6. package/dist/api/compilerOptions.d.ts.map +1 -0
  7. package/dist/api/compilerOptions.js +2 -0
  8. package/dist/api/compilerOptions.js.map +1 -0
  9. package/dist/api/proto.d.ts +11 -3
  10. package/dist/api/proto.d.ts.map +1 -1
  11. package/dist/api/proto.js.map +1 -1
  12. package/dist/api/sync/api.d.ts +35 -18
  13. package/dist/api/sync/api.d.ts.map +1 -1
  14. package/dist/api/sync/api.js +135 -107
  15. package/dist/api/sync/api.js.map +1 -1
  16. package/dist/ast/ast.d.ts +4 -1
  17. package/dist/ast/ast.d.ts.map +1 -1
  18. package/dist/ast/ast.generated.d.ts +2 -2
  19. package/dist/ast/ast.generated.d.ts.map +1 -1
  20. package/dist/ast/ast.js.map +1 -1
  21. package/dist/ast/index.d.ts +1 -0
  22. package/dist/ast/index.d.ts.map +1 -1
  23. package/dist/ast/index.js +1 -0
  24. package/dist/ast/index.js.map +1 -1
  25. package/dist/ast/is.d.ts +2 -1
  26. package/dist/ast/is.d.ts.map +1 -1
  27. package/dist/ast/is.generated.d.ts +1 -2
  28. package/dist/ast/is.generated.d.ts.map +1 -1
  29. package/dist/ast/is.generated.js +0 -4
  30. package/dist/ast/is.generated.js.map +1 -1
  31. package/dist/ast/is.js +8 -1
  32. package/dist/ast/is.js.map +1 -1
  33. package/dist/ast/jsdoc.d.ts +11 -0
  34. package/dist/ast/jsdoc.d.ts.map +1 -0
  35. package/dist/ast/jsdoc.js +202 -0
  36. package/dist/ast/jsdoc.js.map +1 -0
  37. package/dist/enums/jsxEmit.d.ts +2 -0
  38. package/dist/enums/jsxEmit.d.ts.map +1 -0
  39. package/dist/enums/jsxEmit.enum.d.ts +9 -0
  40. package/dist/enums/jsxEmit.enum.d.ts.map +1 -0
  41. package/dist/enums/jsxEmit.enum.js +11 -0
  42. package/dist/enums/jsxEmit.enum.js.map +1 -0
  43. package/dist/enums/jsxEmit.js +11 -0
  44. package/dist/enums/jsxEmit.js.map +1 -0
  45. package/dist/enums/moduleDetectionKind.d.ts +2 -0
  46. package/dist/enums/moduleDetectionKind.d.ts.map +1 -0
  47. package/dist/enums/moduleDetectionKind.enum.d.ts +7 -0
  48. package/dist/enums/moduleDetectionKind.enum.d.ts.map +1 -0
  49. package/dist/enums/moduleDetectionKind.enum.js +9 -0
  50. package/dist/enums/moduleDetectionKind.enum.js.map +1 -0
  51. package/dist/enums/moduleDetectionKind.js +9 -0
  52. package/dist/enums/moduleDetectionKind.js.map +1 -0
  53. package/dist/enums/moduleResolutionKind.d.ts +2 -0
  54. package/dist/enums/moduleResolutionKind.d.ts.map +1 -0
  55. package/dist/enums/moduleResolutionKind.enum.d.ts +9 -0
  56. package/dist/enums/moduleResolutionKind.enum.d.ts.map +1 -0
  57. package/dist/enums/moduleResolutionKind.enum.js +11 -0
  58. package/dist/enums/moduleResolutionKind.enum.js.map +1 -0
  59. package/dist/enums/moduleResolutionKind.js +11 -0
  60. package/dist/enums/moduleResolutionKind.js.map +1 -0
  61. package/dist/enums/newLineKind.d.ts +2 -0
  62. package/dist/enums/newLineKind.d.ts.map +1 -0
  63. package/dist/enums/newLineKind.enum.d.ts +6 -0
  64. package/dist/enums/newLineKind.enum.d.ts.map +1 -0
  65. package/dist/enums/newLineKind.enum.js +8 -0
  66. package/dist/enums/newLineKind.enum.js.map +1 -0
  67. package/dist/enums/newLineKind.js +8 -0
  68. package/dist/enums/newLineKind.js.map +1 -0
  69. package/dist/internal/utils.d.ts +23 -0
  70. package/dist/internal/utils.d.ts.map +1 -0
  71. package/dist/internal/utils.js +25 -0
  72. package/dist/internal/utils.js.map +1 -0
  73. package/package.json +9 -9
@@ -129,8 +129,8 @@ export class Snapshot {
129
129
  this.client = client;
130
130
  this.toPath = toPath;
131
131
  this.onDispose = onDispose;
132
- this.snapshotRegistry = new SnapshotObjectRegistry(client, this.id);
133
132
  this.projectMap = new Map();
133
+ this.snapshotRegistry = new SnapshotObjectRegistry(client, this.id, projectId => this.projectMap.get(projectId));
134
134
  for (const projData of data.projects) {
135
135
  const project = new Project(projData, this.id, client, sourceFileCache, toPath, this.snapshotRegistry);
136
136
  this.projectMap.set(toPath(projData.configFileName), project);
@@ -182,9 +182,15 @@ class SnapshotObjectRegistry {
182
182
  symbols = new Map();
183
183
  client;
184
184
  snapshotId;
185
- constructor(client, snapshotId) {
185
+ resolveProject;
186
+ constructor(client, snapshotId, resolveProject) {
186
187
  this.client = client;
187
188
  this.snapshotId = snapshotId;
189
+ this.resolveProject = resolveProject;
190
+ }
191
+ /** Resolve a project id (a config file path) to its Project within this snapshot. */
192
+ getProject(projectId) {
193
+ return this.resolveProject(projectId);
188
194
  }
189
195
  getOrCreateSymbol(data) {
190
196
  let symbol = this.symbols.get(data.id);
@@ -244,14 +250,14 @@ class SnapshotObjectRegistry {
244
250
  class ProjectObjectRegistry {
245
251
  client;
246
252
  snapshotId;
247
- projectId;
253
+ project;
248
254
  snapshotRegistry;
249
255
  types = new Map();
250
256
  signatures = new Map();
251
- constructor(client, snapshotId, projectId, snapshotRegistry) {
257
+ constructor(client, snapshotId, project, snapshotRegistry) {
252
258
  this.client = client;
253
259
  this.snapshotId = snapshotId;
254
- this.projectId = projectId;
260
+ this.project = project;
255
261
  this.snapshotRegistry = snapshotRegistry;
256
262
  }
257
263
  getOrCreateSymbol(data) {
@@ -274,7 +280,7 @@ class ProjectObjectRegistry {
274
280
  getOrCreateSignature(data) {
275
281
  let sig = this.signatures.get(data.id);
276
282
  if (!sig) {
277
- sig = new Signature(data, this);
283
+ sig = new Signature(data, this.project, this);
278
284
  this.signatures.set(data.id, sig);
279
285
  }
280
286
  return sig;
@@ -296,7 +302,7 @@ class ProjectObjectRegistry {
296
302
  }
297
303
  const data = await this.client.apiRequest(method, {
298
304
  snapshot: this.snapshotId,
299
- project: this.projectId,
305
+ project: this.project.id,
300
306
  objectId: source.id,
301
307
  });
302
308
  if (!data)
@@ -304,7 +310,7 @@ class ProjectObjectRegistry {
304
310
  return this.getOrCreateType(data);
305
311
  }
306
312
  async fetchSymbol(source, method, handle) {
307
- return this.snapshotRegistry.fetchSymbol(source, method, handle, this.projectId);
313
+ return this.snapshotRegistry.fetchSymbol(source, method, handle, this.project.id);
308
314
  }
309
315
  async fetchSignature(source, method, handle) {
310
316
  if (!handle)
@@ -314,7 +320,7 @@ class ProjectObjectRegistry {
314
320
  return cached;
315
321
  const data = await this.client.apiRequest(method, {
316
322
  snapshot: this.snapshotId,
317
- project: this.projectId,
323
+ project: this.project.id,
318
324
  objectId: source.id,
319
325
  });
320
326
  if (!data)
@@ -338,7 +344,7 @@ class ProjectObjectRegistry {
338
344
  }
339
345
  const typesData = await this.client.apiRequest(method, {
340
346
  snapshot: this.snapshotId,
341
- project: this.projectId,
347
+ project: this.project.id,
342
348
  objectId: source.id,
343
349
  });
344
350
  if (typesData == null)
@@ -347,14 +353,14 @@ class ProjectObjectRegistry {
347
353
  return typesData.map(data => this.getOrCreateType(data));
348
354
  }
349
355
  async fetchSymbols(source, method, handles) {
350
- return this.snapshotRegistry.fetchSymbols(source, method, handles, this.projectId);
356
+ return this.snapshotRegistry.fetchSymbols(source, method, handles, this.project.id);
351
357
  }
352
358
  // getBaseTypes is a checker-level endpoint keyed by `type` (not `objectId`),
353
359
  // so it cannot go through fetchTypes. This helper reuses that server method.
354
360
  async fetchBaseTypes(source) {
355
361
  const typesData = await this.client.apiRequest("getBaseTypes", {
356
362
  snapshot: this.snapshotId,
357
- project: this.projectId,
363
+ project: this.project.id,
358
364
  type: source.id,
359
365
  });
360
366
  if (typesData == null)
@@ -377,9 +383,9 @@ export class Project {
377
383
  this.compilerOptions = data.compilerOptions;
378
384
  this.rootFiles = data.rootFiles;
379
385
  this.client = client;
380
- this.program = new Program(snapshotId, this.id, client, sourceFileCache, toPath);
381
- const objectRegistry = new ProjectObjectRegistry(client, snapshotId, this.id, snapshotRegistry);
382
- this.checker = new Checker(snapshotId, this.id, client, objectRegistry);
386
+ this.program = new Program(snapshotId, this, client, sourceFileCache, toPath);
387
+ const objectRegistry = new ProjectObjectRegistry(client, snapshotId, this, snapshotRegistry);
388
+ this.checker = new Checker(snapshotId, this, client, objectRegistry);
383
389
  this.emitter = new Emitter(client);
384
390
  }
385
391
  dispose() {
@@ -388,31 +394,34 @@ export class Project {
388
394
  }
389
395
  export class Program {
390
396
  snapshotId;
391
- projectId;
397
+ project;
392
398
  client;
393
399
  sourceFileCache;
394
400
  toPath;
395
401
  decoder = new Wtf8Decoder();
396
402
  sourceFileMetadataCache = new Map();
397
- constructor(snapshotId, projectId, client, sourceFileCache, toPath) {
403
+ constructor(snapshotId, project, client, sourceFileCache, toPath) {
398
404
  this.snapshotId = snapshotId;
399
- this.projectId = projectId;
405
+ this.project = project;
400
406
  this.client = client;
401
407
  this.sourceFileCache = sourceFileCache;
402
408
  this.toPath = toPath;
403
409
  }
410
+ getCompilerOptions() {
411
+ return this.project.compilerOptions;
412
+ }
404
413
  async getSourceFile(file) {
405
414
  const fileName = resolveFileName(file);
406
415
  const path = this.toPath(fileName);
407
416
  // Check if we already have a retained cache entry for this (snapshot, project) pair
408
- const retained = this.sourceFileCache.getRetained(path, this.snapshotId, this.projectId);
417
+ const retained = this.sourceFileCache.getRetained(path, this.snapshotId, this.project.id);
409
418
  if (retained) {
410
419
  return retained;
411
420
  }
412
421
  // Fetch from server
413
422
  const binaryData = await this.client.apiRequestBinary("getSourceFile", {
414
423
  snapshot: this.snapshotId,
415
- project: this.projectId,
424
+ project: this.project.id,
416
425
  file,
417
426
  });
418
427
  if (!binaryData) {
@@ -423,12 +432,12 @@ export class Program {
423
432
  const parseOptionsKey = readParseOptionsKey(view);
424
433
  // Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
425
434
  const sourceFile = new RemoteSourceFile(binaryData, this.decoder);
426
- return this.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.projectId);
435
+ return this.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, this.snapshotId, this.project.id);
427
436
  }
428
437
  async getSourceFileNames() {
429
438
  const data = await this.client.apiRequest("getSourceFileNames", {
430
439
  snapshot: this.snapshotId,
431
- project: this.projectId,
440
+ project: this.project.id,
432
441
  });
433
442
  return data ?? [];
434
443
  }
@@ -457,7 +466,7 @@ export class Program {
457
466
  async fetchSourceFileMetadata(path) {
458
467
  const data = await this.client.apiRequest("getSourceFileMetadata", {
459
468
  snapshot: this.snapshotId,
460
- project: this.projectId,
469
+ project: this.project.id,
461
470
  file: path,
462
471
  });
463
472
  return data ?? undefined;
@@ -487,7 +496,7 @@ export class Program {
487
496
  async getSyntacticDiagnostics(file) {
488
497
  const data = await this.client.apiRequest("getSyntacticDiagnostics", {
489
498
  snapshot: this.snapshotId,
490
- project: this.projectId,
499
+ project: this.project.id,
491
500
  ...(file !== undefined ? { file } : {}),
492
501
  });
493
502
  return data ?? [];
@@ -499,7 +508,7 @@ export class Program {
499
508
  async getBindDiagnostics(file) {
500
509
  const data = await this.client.apiRequest("getBindDiagnostics", {
501
510
  snapshot: this.snapshotId,
502
- project: this.projectId,
511
+ project: this.project.id,
503
512
  ...(file !== undefined ? { file } : {}),
504
513
  });
505
514
  return data ?? [];
@@ -511,7 +520,7 @@ export class Program {
511
520
  async getSemanticDiagnostics(file) {
512
521
  const data = await this.client.apiRequest("getSemanticDiagnostics", {
513
522
  snapshot: this.snapshotId,
514
- project: this.projectId,
523
+ project: this.project.id,
515
524
  ...(file !== undefined ? { file } : {}),
516
525
  });
517
526
  return data ?? [];
@@ -523,7 +532,7 @@ export class Program {
523
532
  async getSuggestionDiagnostics(file) {
524
533
  const data = await this.client.apiRequest("getSuggestionDiagnostics", {
525
534
  snapshot: this.snapshotId,
526
- project: this.projectId,
535
+ project: this.project.id,
527
536
  ...(file !== undefined ? { file } : {}),
528
537
  });
529
538
  return data ?? [];
@@ -535,7 +544,7 @@ export class Program {
535
544
  async getDeclarationDiagnostics(file) {
536
545
  const data = await this.client.apiRequest("getDeclarationDiagnostics", {
537
546
  snapshot: this.snapshotId,
538
- project: this.projectId,
547
+ project: this.project.id,
539
548
  ...(file !== undefined ? { file } : {}),
540
549
  });
541
550
  return data ?? [];
@@ -546,7 +555,7 @@ export class Program {
546
555
  async getProgramDiagnostics() {
547
556
  const data = await this.client.apiRequest("getProgramDiagnostics", {
548
557
  snapshot: this.snapshotId,
549
- project: this.projectId,
558
+ project: this.project.id,
550
559
  });
551
560
  return data ?? [];
552
561
  }
@@ -556,7 +565,7 @@ export class Program {
556
565
  async getGlobalDiagnostics() {
557
566
  const data = await this.client.apiRequest("getGlobalDiagnostics", {
558
567
  snapshot: this.snapshotId,
559
- project: this.projectId,
568
+ project: this.project.id,
560
569
  });
561
570
  return data ?? [];
562
571
  }
@@ -566,20 +575,20 @@ export class Program {
566
575
  async getConfigFileParsingDiagnostics() {
567
576
  const data = await this.client.apiRequest("getConfigFileParsingDiagnostics", {
568
577
  snapshot: this.snapshotId,
569
- project: this.projectId,
578
+ project: this.project.id,
570
579
  });
571
580
  return data ?? [];
572
581
  }
573
582
  }
574
583
  export class Checker {
575
584
  snapshotId;
576
- projectId;
585
+ project;
577
586
  client;
578
587
  objectRegistry;
579
588
  wellKnownSymbols;
580
- constructor(snapshotId, projectId, client, objectRegistry) {
589
+ constructor(snapshotId, project, client, objectRegistry) {
581
590
  this.snapshotId = snapshotId;
582
- this.projectId = projectId;
591
+ this.project = project;
583
592
  this.client = client;
584
593
  this.objectRegistry = objectRegistry;
585
594
  }
@@ -590,14 +599,14 @@ export class Checker {
590
599
  if (Array.isArray(nodeOrNodes)) {
591
600
  const data = await this.client.apiRequest("getSymbolsAtLocations", {
592
601
  snapshot: this.snapshotId,
593
- project: this.projectId,
602
+ project: this.project.id,
594
603
  locations: nodeOrNodes.map(node => getNodeId(node)),
595
604
  });
596
605
  return data.map(d => d ? this.objectRegistry.getOrCreateSymbol(d) : undefined);
597
606
  }
598
607
  const data = await this.client.apiRequest("getSymbolAtLocation", {
599
608
  snapshot: this.snapshotId,
600
- project: this.projectId,
609
+ project: this.project.id,
601
610
  location: getNodeId(nodeOrNodes),
602
611
  });
603
612
  return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
@@ -606,7 +615,7 @@ export class Checker {
606
615
  if (typeof positionOrPositions === "number") {
607
616
  const data = await this.client.apiRequest("getSymbolAtPosition", {
608
617
  snapshot: this.snapshotId,
609
- project: this.projectId,
618
+ project: this.project.id,
610
619
  file,
611
620
  position: positionOrPositions,
612
621
  });
@@ -614,7 +623,7 @@ export class Checker {
614
623
  }
615
624
  const data = await this.client.apiRequest("getSymbolsAtPositions", {
616
625
  snapshot: this.snapshotId,
617
- project: this.projectId,
626
+ project: this.project.id,
618
627
  file,
619
628
  positions: positionOrPositions,
620
629
  });
@@ -624,14 +633,14 @@ export class Checker {
624
633
  if (Array.isArray(symbolOrSymbols)) {
625
634
  const data = await this.client.apiRequest("getTypesOfSymbols", {
626
635
  snapshot: this.snapshotId,
627
- project: this.projectId,
636
+ project: this.project.id,
628
637
  symbols: symbolOrSymbols.map(s => s.id),
629
638
  });
630
639
  return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
631
640
  }
632
641
  const data = await this.client.apiRequest("getTypeOfSymbol", {
633
642
  snapshot: this.snapshotId,
634
- project: this.projectId,
643
+ project: this.project.id,
635
644
  symbol: symbolOrSymbols.id,
636
645
  });
637
646
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -644,7 +653,7 @@ export class Checker {
644
653
  async getDeclaredTypeOfSymbol(symbol) {
645
654
  const data = await this.client.apiRequest("getDeclaredTypeOfSymbol", {
646
655
  snapshot: this.snapshotId,
647
- project: this.projectId,
656
+ project: this.project.id,
648
657
  symbol: symbol.id,
649
658
  });
650
659
  if (!data)
@@ -654,40 +663,40 @@ export class Checker {
654
663
  async getReferencesToSymbolInFile(file, symbol) {
655
664
  const data = await this.client.apiRequest("getReferencesToSymbolInFile", {
656
665
  snapshot: this.snapshotId,
657
- project: this.projectId,
666
+ project: this.project.id,
658
667
  file,
659
668
  symbol: symbol.id,
660
669
  });
661
- return (data ?? []).map(h => new NodeHandle(h));
670
+ return (data ?? []).map(h => new NodeHandle(h, this.project));
662
671
  }
663
672
  async getReferencedSymbolsForNode(node, position) {
664
673
  const data = await this.client.apiRequest("getReferencedSymbolsForNode", {
665
674
  snapshot: this.snapshotId,
666
- project: this.projectId,
675
+ project: this.project.id,
667
676
  node: getNodeId(node),
668
677
  position,
669
678
  });
670
679
  return (data ?? []).map(entry => ({
671
- definition: new NodeHandle(entry.definition),
680
+ definition: new NodeHandle(entry.definition, this.project),
672
681
  symbol: entry.symbol ? this.objectRegistry.getOrCreateSymbol(entry.symbol) : undefined,
673
- references: (entry.references ?? []).map(h => new NodeHandle(h)),
682
+ references: (entry.references ?? []).map(h => new NodeHandle(h, this.project)),
674
683
  }));
675
684
  }
676
685
  async getSignatureUsage(signatureDecl) {
677
686
  const data = await this.client.apiRequest("getSignatureUsages", {
678
687
  snapshot: this.snapshotId,
679
- project: this.projectId,
688
+ project: this.project.id,
680
689
  signatureDecl: getNodeId(signatureDecl),
681
690
  });
682
691
  return (data ?? []).map(entry => ({
683
- name: new NodeHandle(entry.name),
684
- call: entry.call ? new NodeHandle(entry.call) : undefined,
692
+ name: new NodeHandle(entry.name, this.project),
693
+ call: entry.call ? new NodeHandle(entry.call, this.project) : undefined,
685
694
  }));
686
695
  }
687
696
  async getCompletionsAtPosition(document, position, options) {
688
697
  const data = await this.client.apiRequest("getCompletionsAtPosition", {
689
698
  snapshot: this.snapshotId,
690
- project: this.projectId,
699
+ project: this.project.id,
691
700
  file: document,
692
701
  position,
693
702
  triggerCharacter: options?.triggerCharacter,
@@ -707,14 +716,14 @@ export class Checker {
707
716
  if (Array.isArray(nodeOrNodes)) {
708
717
  const data = await this.client.apiRequest("getTypeAtLocations", {
709
718
  snapshot: this.snapshotId,
710
- project: this.projectId,
719
+ project: this.project.id,
711
720
  locations: nodeOrNodes.map(node => getNodeId(node)),
712
721
  });
713
722
  return data.map(d => d ? this.objectRegistry.getOrCreateType(d) : undefined);
714
723
  }
715
724
  const data = await this.client.apiRequest("getTypeAtLocation", {
716
725
  snapshot: this.snapshotId,
717
- project: this.projectId,
726
+ project: this.project.id,
718
727
  location: getNodeId(nodeOrNodes),
719
728
  });
720
729
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -722,7 +731,7 @@ export class Checker {
722
731
  async getSignaturesOfType(type, kind) {
723
732
  const data = await this.client.apiRequest("getSignaturesOfType", {
724
733
  snapshot: this.snapshotId,
725
- project: this.projectId,
734
+ project: this.project.id,
726
735
  type: type.id,
727
736
  kind,
728
737
  });
@@ -731,7 +740,7 @@ export class Checker {
731
740
  async getResolvedSignature(node) {
732
741
  const data = await this.client.apiRequest("getResolvedSignature", {
733
742
  snapshot: this.snapshotId,
734
- project: this.projectId,
743
+ project: this.project.id,
735
744
  location: getNodeId(node),
736
745
  });
737
746
  return data ? this.objectRegistry.getOrCreateSignature(data) : undefined;
@@ -740,7 +749,7 @@ export class Checker {
740
749
  if (typeof positionOrPositions === "number") {
741
750
  const data = await this.client.apiRequest("getTypeAtPosition", {
742
751
  snapshot: this.snapshotId,
743
- project: this.projectId,
752
+ project: this.project.id,
744
753
  file,
745
754
  position: positionOrPositions,
746
755
  });
@@ -748,7 +757,7 @@ export class Checker {
748
757
  }
749
758
  const data = await this.client.apiRequest("getTypesAtPositions", {
750
759
  snapshot: this.snapshotId,
751
- project: this.projectId,
760
+ project: this.project.id,
752
761
  file,
753
762
  positions: positionOrPositions,
754
763
  });
@@ -759,7 +768,7 @@ export class Checker {
759
768
  const isNode = location && "kind" in location;
760
769
  const data = await this.client.apiRequest("resolveName", {
761
770
  snapshot: this.snapshotId,
762
- project: this.projectId,
771
+ project: this.project.id,
763
772
  name,
764
773
  meaning,
765
774
  location: isNode ? getNodeId(location) : undefined,
@@ -778,7 +787,7 @@ export class Checker {
778
787
  async getContextualType(node) {
779
788
  const data = await this.client.apiRequest("getContextualType", {
780
789
  snapshot: this.snapshotId,
781
- project: this.projectId,
790
+ project: this.project.id,
782
791
  location: getNodeId(node),
783
792
  });
784
793
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -786,7 +795,7 @@ export class Checker {
786
795
  async getBaseTypeOfLiteralType(type) {
787
796
  const data = await this.client.apiRequest("getBaseTypeOfLiteralType", {
788
797
  snapshot: this.snapshotId,
789
- project: this.projectId,
798
+ project: this.project.id,
790
799
  type: type.id,
791
800
  });
792
801
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -794,7 +803,7 @@ export class Checker {
794
803
  async getNonNullableType(type) {
795
804
  const data = await this.client.apiRequest("getNonNullableType", {
796
805
  snapshot: this.snapshotId,
797
- project: this.projectId,
806
+ project: this.project.id,
798
807
  type: type.id,
799
808
  });
800
809
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -802,7 +811,7 @@ export class Checker {
802
811
  async getTypeFromTypeNode(node) {
803
812
  const data = await this.client.apiRequest("getTypeFromTypeNode", {
804
813
  snapshot: this.snapshotId,
805
- project: this.projectId,
814
+ project: this.project.id,
806
815
  location: getNodeId(node),
807
816
  });
808
817
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -810,7 +819,7 @@ export class Checker {
810
819
  async getWidenedType(type) {
811
820
  const data = await this.client.apiRequest("getWidenedType", {
812
821
  snapshot: this.snapshotId,
813
- project: this.projectId,
822
+ project: this.project.id,
814
823
  type: type.id,
815
824
  });
816
825
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -818,7 +827,7 @@ export class Checker {
818
827
  async getParameterType(signature, index) {
819
828
  const data = await this.client.apiRequest("getParameterType", {
820
829
  snapshot: this.snapshotId,
821
- project: this.projectId,
830
+ project: this.project.id,
822
831
  signature: signature.id,
823
832
  index,
824
833
  });
@@ -827,14 +836,14 @@ export class Checker {
827
836
  async isArrayLikeType(type) {
828
837
  return this.client.apiRequest("isArrayLikeType", {
829
838
  snapshot: this.snapshotId,
830
- project: this.projectId,
839
+ project: this.project.id,
831
840
  type: type.id,
832
841
  });
833
842
  }
834
843
  async isTypeAssignableTo(source, target) {
835
844
  return this.client.apiRequest("isTypeAssignableTo", {
836
845
  snapshot: this.snapshotId,
837
- project: this.projectId,
846
+ project: this.project.id,
838
847
  source: source.id,
839
848
  target: target.id,
840
849
  });
@@ -842,7 +851,7 @@ export class Checker {
842
851
  async getShorthandAssignmentValueSymbol(node) {
843
852
  const data = await this.client.apiRequest("getShorthandAssignmentValueSymbol", {
844
853
  snapshot: this.snapshotId,
845
- project: this.projectId,
854
+ project: this.project.id,
846
855
  location: getNodeId(node),
847
856
  });
848
857
  return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
@@ -855,7 +864,7 @@ export class Checker {
855
864
  async getTypeOfSymbolAtLocation(symbol, location) {
856
865
  const data = await this.client.apiRequest("getTypeOfSymbolAtLocation", {
857
866
  snapshot: this.snapshotId,
858
- project: this.projectId,
867
+ project: this.project.id,
859
868
  symbol: symbol.id,
860
869
  location: getNodeId(location),
861
870
  });
@@ -866,7 +875,7 @@ export class Checker {
866
875
  async getIntrinsicType(method) {
867
876
  const data = await this.client.apiRequest(method, {
868
877
  snapshot: this.snapshotId,
869
- project: this.projectId,
878
+ project: this.project.id,
870
879
  });
871
880
  return this.objectRegistry.getOrCreateType(data);
872
881
  }
@@ -906,7 +915,7 @@ export class Checker {
906
915
  async typeToTypeNode(type, enclosingDeclaration, flags) {
907
916
  const binaryData = await this.client.apiRequestBinary("typeToTypeNode", {
908
917
  snapshot: this.snapshotId,
909
- project: this.projectId,
918
+ project: this.project.id,
910
919
  type: type.id,
911
920
  location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
912
921
  flags,
@@ -918,7 +927,7 @@ export class Checker {
918
927
  async signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags) {
919
928
  const binaryData = await this.client.apiRequestBinary("signatureToSignatureDeclaration", {
920
929
  snapshot: this.snapshotId,
921
- project: this.projectId,
930
+ project: this.project.id,
922
931
  signature: signature.id,
923
932
  kind,
924
933
  location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
@@ -931,7 +940,7 @@ export class Checker {
931
940
  async typeToString(type, enclosingDeclaration, flags) {
932
941
  return this.client.apiRequest("typeToString", {
933
942
  snapshot: this.snapshotId,
934
- project: this.projectId,
943
+ project: this.project.id,
935
944
  type: type.id,
936
945
  location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
937
946
  flags,
@@ -940,28 +949,28 @@ export class Checker {
940
949
  async isContextSensitive(node) {
941
950
  return this.client.apiRequest("isContextSensitive", {
942
951
  snapshot: this.snapshotId,
943
- project: this.projectId,
952
+ project: this.project.id,
944
953
  location: getNodeId(node),
945
954
  });
946
955
  }
947
956
  async isArrayType(type) {
948
957
  return this.client.apiRequest("isArrayType", {
949
958
  snapshot: this.snapshotId,
950
- project: this.projectId,
959
+ project: this.project.id,
951
960
  type: type.id,
952
961
  });
953
962
  }
954
963
  async isTupleType(type) {
955
964
  return this.client.apiRequest("isTupleType", {
956
965
  snapshot: this.snapshotId,
957
- project: this.projectId,
966
+ project: this.project.id,
958
967
  type: type.id,
959
968
  });
960
969
  }
961
970
  async getReturnTypeOfSignature(signature) {
962
971
  const data = await this.client.apiRequest("getReturnTypeOfSignature", {
963
972
  snapshot: this.snapshotId,
964
- project: this.projectId,
973
+ project: this.project.id,
965
974
  signature: signature.id,
966
975
  });
967
976
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -969,7 +978,7 @@ export class Checker {
969
978
  async getRestTypeOfSignature(signature) {
970
979
  const data = await this.client.apiRequest("getRestTypeOfSignature", {
971
980
  snapshot: this.snapshotId,
972
- project: this.projectId,
981
+ project: this.project.id,
973
982
  signature: signature.id,
974
983
  });
975
984
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -977,7 +986,7 @@ export class Checker {
977
986
  async getTypePredicateOfSignature(signature) {
978
987
  const data = await this.client.apiRequest("getTypePredicateOfSignature", {
979
988
  snapshot: this.snapshotId,
980
- project: this.projectId,
989
+ project: this.project.id,
981
990
  signature: signature.id,
982
991
  });
983
992
  if (!data)
@@ -996,7 +1005,7 @@ export class Checker {
996
1005
  async getBaseTypes(type) {
997
1006
  const data = await this.client.apiRequest("getBaseTypes", {
998
1007
  snapshot: this.snapshotId,
999
- project: this.projectId,
1008
+ project: this.project.id,
1000
1009
  type: type.id,
1001
1010
  });
1002
1011
  return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
@@ -1004,7 +1013,7 @@ export class Checker {
1004
1013
  async getApparentType(type) {
1005
1014
  const data = await this.client.apiRequest("getApparentType", {
1006
1015
  snapshot: this.snapshotId,
1007
- project: this.projectId,
1016
+ project: this.project.id,
1008
1017
  type: type.id,
1009
1018
  });
1010
1019
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -1012,7 +1021,7 @@ export class Checker {
1012
1021
  async getPropertiesOfType(type) {
1013
1022
  const data = await this.client.apiRequest("getPropertiesOfType", {
1014
1023
  snapshot: this.snapshotId,
1015
- project: this.projectId,
1024
+ project: this.project.id,
1016
1025
  type: type.id,
1017
1026
  });
1018
1027
  return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
@@ -1020,7 +1029,7 @@ export class Checker {
1020
1029
  async getIndexInfosOfType(type) {
1021
1030
  const data = await this.client.apiRequest("getIndexInfosOfType", {
1022
1031
  snapshot: this.snapshotId,
1023
- project: this.projectId,
1032
+ project: this.project.id,
1024
1033
  type: type.id,
1025
1034
  });
1026
1035
  if (!data)
@@ -1029,7 +1038,7 @@ export class Checker {
1029
1038
  keyType: this.objectRegistry.getOrCreateType(d.keyType),
1030
1039
  valueType: this.objectRegistry.getOrCreateType(d.valueType),
1031
1040
  isReadonly: d.isReadonly ?? false,
1032
- declaration: d.declaration ? new NodeHandle(d.declaration) : undefined,
1041
+ declaration: d.declaration ? new NodeHandle(d.declaration, this.project) : undefined,
1033
1042
  }));
1034
1043
  }
1035
1044
  /**
@@ -1039,7 +1048,7 @@ export class Checker {
1039
1048
  async getConstraintOfTypeParameter(type) {
1040
1049
  const data = await this.client.apiRequest("getConstraintOfTypeParameter", {
1041
1050
  snapshot: this.snapshotId,
1042
- project: this.projectId,
1051
+ project: this.project.id,
1043
1052
  type: type.id,
1044
1053
  });
1045
1054
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -1047,7 +1056,7 @@ export class Checker {
1047
1056
  async getBaseConstraintOfType(type) {
1048
1057
  const data = await this.client.apiRequest("getBaseConstraintOfType", {
1049
1058
  snapshot: this.snapshotId,
1050
- project: this.projectId,
1059
+ project: this.project.id,
1051
1060
  type: type.id,
1052
1061
  });
1053
1062
  return data ? this.objectRegistry.getOrCreateType(data) : undefined;
@@ -1055,7 +1064,7 @@ export class Checker {
1055
1064
  async getPropertyOfType(type, name) {
1056
1065
  const data = await this.client.apiRequest("getPropertyOfType", {
1057
1066
  snapshot: this.snapshotId,
1058
- project: this.projectId,
1067
+ project: this.project.id,
1059
1068
  type: type.id,
1060
1069
  name,
1061
1070
  });
@@ -1064,7 +1073,7 @@ export class Checker {
1064
1073
  async getConstantValue(node) {
1065
1074
  const data = await this.client.apiRequest("getConstantValue", {
1066
1075
  snapshot: this.snapshotId,
1067
- project: this.projectId,
1076
+ project: this.project.id,
1068
1077
  location: getNodeId(node),
1069
1078
  });
1070
1079
  return data ?? undefined;
@@ -1072,7 +1081,7 @@ export class Checker {
1072
1081
  async getSignatureFromDeclaration(node) {
1073
1082
  const data = await this.client.apiRequest("getSignatureFromDeclaration", {
1074
1083
  snapshot: this.snapshotId,
1075
- project: this.projectId,
1084
+ project: this.project.id,
1076
1085
  location: getNodeId(node),
1077
1086
  });
1078
1087
  return data ? this.objectRegistry.getOrCreateSignature(data) : undefined;
@@ -1080,7 +1089,7 @@ export class Checker {
1080
1089
  async getExportSpecifierLocalTargetSymbol(node) {
1081
1090
  const data = await this.client.apiRequest("getExportSpecifierLocalTargetSymbol", {
1082
1091
  snapshot: this.snapshotId,
1083
- project: this.projectId,
1092
+ project: this.project.id,
1084
1093
  location: getNodeId(node),
1085
1094
  });
1086
1095
  return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
@@ -1093,7 +1102,7 @@ export class Checker {
1093
1102
  async getAliasedSymbol(symbol) {
1094
1103
  const data = await this.client.apiRequest("getAliasedSymbol", {
1095
1104
  snapshot: this.snapshotId,
1096
- project: this.projectId,
1105
+ project: this.project.id,
1097
1106
  symbol: symbol.id,
1098
1107
  });
1099
1108
  if (!data)
@@ -1103,7 +1112,7 @@ export class Checker {
1103
1112
  async getImmediateAliasedSymbol(symbol) {
1104
1113
  const data = await this.client.apiRequest("getImmediateAliasedSymbol", {
1105
1114
  snapshot: this.snapshotId,
1106
- project: this.projectId,
1115
+ project: this.project.id,
1107
1116
  symbol: symbol.id,
1108
1117
  });
1109
1118
  return data ? this.objectRegistry.getOrCreateSymbol(data) : undefined;
@@ -1117,7 +1126,7 @@ export class Checker {
1117
1126
  getWellKnownSymbols() {
1118
1127
  return this.wellKnownSymbols ??= this.client.apiRequest("getWellKnownSymbols", {
1119
1128
  snapshot: this.snapshotId,
1120
- project: this.projectId,
1129
+ project: this.project.id,
1121
1130
  });
1122
1131
  }
1123
1132
  /**
@@ -1142,7 +1151,7 @@ export class Checker {
1142
1151
  async getExportsOfModule(symbol) {
1143
1152
  const data = await this.client.apiRequest("getExportsOfModule", {
1144
1153
  snapshot: this.snapshotId,
1145
- project: this.projectId,
1154
+ project: this.project.id,
1146
1155
  symbol: symbol.id,
1147
1156
  });
1148
1157
  return data ? data.map(d => this.objectRegistry.getOrCreateSymbol(d)) : [];
@@ -1150,7 +1159,7 @@ export class Checker {
1150
1159
  async getMemberInModuleExports(symbol, name) {
1151
1160
  const data = await this.client.apiRequest("getMemberInModuleExports", {
1152
1161
  snapshot: this.snapshotId,
1153
- project: this.projectId,
1162
+ project: this.project.id,
1154
1163
  symbol: symbol.id,
1155
1164
  name,
1156
1165
  });
@@ -1159,7 +1168,7 @@ export class Checker {
1159
1168
  async getJsDocTagsOfSymbol(symbol) {
1160
1169
  const data = await this.client.apiRequest("getJsDocTags", {
1161
1170
  snapshot: this.snapshotId,
1162
- project: this.projectId,
1171
+ project: this.project.id,
1163
1172
  symbol: symbol.id,
1164
1173
  });
1165
1174
  return data ?? [];
@@ -1167,7 +1176,7 @@ export class Checker {
1167
1176
  async getDocumentationCommentOfSymbol(symbol) {
1168
1177
  return this.client.apiRequest("getDocumentationComment", {
1169
1178
  snapshot: this.snapshotId,
1170
- project: this.projectId,
1179
+ project: this.project.id,
1171
1180
  symbol: symbol.id,
1172
1181
  });
1173
1182
  }
@@ -1177,7 +1186,7 @@ export class Checker {
1177
1186
  async getTypeArguments(type) {
1178
1187
  const data = await this.client.apiRequest("getTypeArguments", {
1179
1188
  snapshot: this.snapshotId,
1180
- project: this.projectId,
1189
+ project: this.project.id,
1181
1190
  type: type.id,
1182
1191
  });
1183
1192
  return data ? data.map(d => this.objectRegistry.getOrCreateType(d)) : [];
@@ -1198,20 +1207,28 @@ export class Emitter {
1198
1207
  }
1199
1208
  }
1200
1209
  export class NodeHandle {
1210
+ /**
1211
+ * The project this handle was produced in, used as the default for {@link resolve}.
1212
+ * Node handles are only meaningful within a project's program, so the producing project
1213
+ * is remembered so callers don't have to pass it explicitly.
1214
+ */
1215
+ canonicalProject;
1201
1216
  index;
1202
1217
  kind;
1203
1218
  path;
1204
- constructor(handle) {
1219
+ constructor(handle, canonicalProject) {
1205
1220
  const parsed = parseNodeHandle(handle);
1206
1221
  this.index = parsed.index;
1207
1222
  this.kind = parsed.kind;
1208
1223
  this.path = parsed.path;
1224
+ this.canonicalProject = canonicalProject;
1209
1225
  }
1210
1226
  /**
1211
- * Resolve this handle to the actual AST node by fetching the source file
1212
- * from the given project and looking up the node by index.
1227
+ * Resolve this handle to the actual AST node by fetching the source file from a project
1228
+ * and looking up the node by index. If no project is passed, the project that produced
1229
+ * the handle is used.
1213
1230
  */
1214
- async resolve(project) {
1231
+ async resolve(project = this.canonicalProject) {
1215
1232
  const sourceFile = await project.program.getSourceFile(this.path);
1216
1233
  if (!sourceFile) {
1217
1234
  return undefined;
@@ -1221,6 +1238,12 @@ export class NodeHandle {
1221
1238
  }
1222
1239
  export class Symbol {
1223
1240
  objectRegistry;
1241
+ /**
1242
+ * The project this symbol was first observed in, used as the default project for
1243
+ * lookups that need a project context (members/exports/parent). Symbols are shared
1244
+ * snapshot-wide, so these lookups can otherwise be ambiguous about which project to use.
1245
+ */
1246
+ canonicalProject;
1224
1247
  id;
1225
1248
  /** The escaped (`__String`) name, used as the key in member/export tables. */
1226
1249
  escapedName;
@@ -1241,15 +1264,20 @@ export class Symbol {
1241
1264
  this.name = unescapeLeadingUnderscores(data.name);
1242
1265
  this.flags = data.flags;
1243
1266
  this.checkFlags = data.checkFlags;
1244
- this.declarations = (data.declarations ?? []).map(d => new NodeHandle(d));
1245
- this.valueDeclaration = data.valueDeclaration ? new NodeHandle(data.valueDeclaration) : undefined;
1267
+ const canonicalProject = objectRegistry.getProject(data.project);
1268
+ if (!canonicalProject) {
1269
+ throw new Error(`Symbol ${data.id} references unknown canonical project '${data.project}'`);
1270
+ }
1271
+ this.canonicalProject = canonicalProject;
1272
+ this.declarations = (data.declarations ?? []).map(d => new NodeHandle(d, canonicalProject));
1273
+ this.valueDeclaration = data.valueDeclaration ? new NodeHandle(data.valueDeclaration, canonicalProject) : undefined;
1246
1274
  if (data.parent !== undefined)
1247
1275
  this.parent = data.parent;
1248
1276
  if (data.exportSymbol !== undefined)
1249
1277
  this.exportSymbol = data.exportSymbol;
1250
1278
  }
1251
1279
  async getParent() {
1252
- return this.objectRegistry.fetchSymbol(this, "getParentOfSymbol", this.parent);
1280
+ return this.objectRegistry.fetchSymbol(this, "getParentOfSymbol", this.parent, this.canonicalProject.id);
1253
1281
  }
1254
1282
  /**
1255
1283
  * Get this symbol's members keyed by escaped name. The result is cached on
@@ -1266,7 +1294,7 @@ export class Symbol {
1266
1294
  return this.exportsCache ??= this.fetchSymbolTable("getExportsOfSymbol");
1267
1295
  }
1268
1296
  async fetchSymbolTable(method) {
1269
- const symbols = await this.objectRegistry.fetchSymbols(this, method);
1297
+ const symbols = await this.objectRegistry.fetchSymbols(this, method, undefined, this.canonicalProject.id);
1270
1298
  const table = new Map();
1271
1299
  for (const symbol of symbols) {
1272
1300
  table.set(symbol.escapedName, symbol);
@@ -1276,7 +1304,7 @@ export class Symbol {
1276
1304
  async getExportSymbol() {
1277
1305
  if (!this.exportSymbol)
1278
1306
  return this;
1279
- return this.objectRegistry.fetchSymbol(this, "getExportSymbolOfSymbol", this.exportSymbol);
1307
+ return this.objectRegistry.fetchSymbol(this, "getExportSymbolOfSymbol", this.exportSymbol, this.canonicalProject.id);
1280
1308
  }
1281
1309
  async getJsDocTags(checker) {
1282
1310
  return checker.getJsDocTagsOfSymbol(this);
@@ -1576,11 +1604,11 @@ export class Signature {
1576
1604
  parameters;
1577
1605
  thisParameter;
1578
1606
  target;
1579
- constructor(data, objectRegistry) {
1607
+ constructor(data, project, objectRegistry) {
1580
1608
  this.id = data.id;
1581
1609
  this.flags = data.flags;
1582
1610
  this.objectRegistry = objectRegistry;
1583
- this.declaration = data.declaration ? new NodeHandle(data.declaration) : undefined;
1611
+ this.declaration = data.declaration ? new NodeHandle(data.declaration, project) : undefined;
1584
1612
  this.typeParameters = data.typeParameters ?? [];
1585
1613
  this.parameters = data.parameters ?? [];
1586
1614
  this.thisParameter = data.thisParameter;