typescript 7.1.0-dev.20260910.1 → 7.1.0-dev.20260912.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.
@@ -422,8 +422,8 @@ export class API {
422
422
  const data = owner.client.apiRequest("createProgram", {
423
423
  rootFiles,
424
424
  createProgramOptions,
425
- ...(oldProgram ? { oldProgram: { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } } : {}),
426
- ...(fileChanges ? { fileChanges } : {}),
425
+ oldProgram: oldProgram ? { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } : undefined,
426
+ fileChanges,
427
427
  });
428
428
  if (!data.project) {
429
429
  throw new Error("createProgram did not return a project");
@@ -447,8 +447,8 @@ export class API {
447
447
  const data = yield* apiRequest("createProgram", {
448
448
  rootFiles,
449
449
  createProgramOptions,
450
- ...(oldProgram ? { oldProgram: { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } } : {}),
451
- ...(fileChanges ? { fileChanges } : {}),
450
+ oldProgram: oldProgram ? { snapshot: oldProgram.snapshotId, project: oldProgram.getProject().id } : undefined,
451
+ fileChanges,
452
452
  });
453
453
  if (!data.project) {
454
454
  throw new Error("createProgram did not return a project");
@@ -1302,8 +1302,8 @@ export class LanguageService {
1302
1302
  project: owner.project.id,
1303
1303
  file: document,
1304
1304
  position,
1305
- ...(options?.triggerCharacter !== undefined ? { triggerCharacter: options.triggerCharacter } : {}),
1306
- ...(options?.includeSymbol !== undefined ? { includeSymbol: options.includeSymbol } : {}),
1305
+ triggerCharacter: options?.triggerCharacter,
1306
+ includeSymbol: options?.includeSymbol,
1307
1307
  });
1308
1308
  if (!data)
1309
1309
  return undefined;
@@ -1320,8 +1320,8 @@ export class LanguageService {
1320
1320
  project: owner.project.id,
1321
1321
  file: document,
1322
1322
  position,
1323
- ...(options?.triggerCharacter !== undefined ? { triggerCharacter: options.triggerCharacter } : {}),
1324
- ...(options?.includeSymbol !== undefined ? { includeSymbol: options.includeSymbol } : {}),
1323
+ triggerCharacter: options?.triggerCharacter,
1324
+ includeSymbol: options?.includeSymbol,
1325
1325
  });
1326
1326
  if (!data)
1327
1327
  return undefined;
@@ -1446,6 +1446,92 @@ export class Program {
1446
1446
  return owner.sourceFileCache.set(path, sourceFile, parseOptionsKey, contentHash, owner.snapshotId, owner.project.id);
1447
1447
  });
1448
1448
  }
1449
+ get getResolvedModule() {
1450
+ const owner = this;
1451
+ return cacheGeneratorMethod(owner, "getResolvedModule", function (file, moduleName, mode) {
1452
+ const result = owner.client.apiRequest("getResolvedModule", {
1453
+ snapshot: owner.snapshotId,
1454
+ project: owner.project.id,
1455
+ file,
1456
+ moduleName,
1457
+ mode,
1458
+ });
1459
+ return result ?? undefined;
1460
+ }, function* (file, moduleName, mode) {
1461
+ const result = yield* apiRequest("getResolvedModule", {
1462
+ snapshot: owner.snapshotId,
1463
+ project: owner.project.id,
1464
+ file,
1465
+ moduleName,
1466
+ mode,
1467
+ });
1468
+ return result ?? undefined;
1469
+ });
1470
+ }
1471
+ get getResolvedModuleFromModuleSpecifier() {
1472
+ const owner = this;
1473
+ return cacheGeneratorMethod(owner, "getResolvedModuleFromModuleSpecifier", function (moduleSpecifier, sourceFile) {
1474
+ const result = owner.client.apiRequest("getResolvedModuleFromModuleSpecifier", {
1475
+ snapshot: owner.snapshotId,
1476
+ project: owner.project.id,
1477
+ moduleSpecifier: getNodeId(moduleSpecifier),
1478
+ sourceFile,
1479
+ });
1480
+ return result ?? undefined;
1481
+ }, function* (moduleSpecifier, sourceFile) {
1482
+ const result = yield* apiRequest("getResolvedModuleFromModuleSpecifier", {
1483
+ snapshot: owner.snapshotId,
1484
+ project: owner.project.id,
1485
+ moduleSpecifier: getNodeId(moduleSpecifier),
1486
+ sourceFile,
1487
+ });
1488
+ return result ?? undefined;
1489
+ });
1490
+ }
1491
+ get getResolvedTypeReferenceDirective() {
1492
+ const owner = this;
1493
+ return cacheGeneratorMethod(owner, "getResolvedTypeReferenceDirective", function (file, typeDirectiveName, mode) {
1494
+ const result = owner.client.apiRequest("getResolvedTypeReferenceDirective", {
1495
+ snapshot: owner.snapshotId,
1496
+ project: owner.project.id,
1497
+ file,
1498
+ typeDirectiveName,
1499
+ mode,
1500
+ });
1501
+ return result ?? undefined;
1502
+ }, function* (file, typeDirectiveName, mode) {
1503
+ const result = yield* apiRequest("getResolvedTypeReferenceDirective", {
1504
+ snapshot: owner.snapshotId,
1505
+ project: owner.project.id,
1506
+ file,
1507
+ typeDirectiveName,
1508
+ mode,
1509
+ });
1510
+ return result ?? undefined;
1511
+ });
1512
+ }
1513
+ get getResolvedTypeReferenceDirectiveFromTypeReferenceDirective() {
1514
+ const owner = this;
1515
+ return cacheGeneratorMethod(owner, "getResolvedTypeReferenceDirectiveFromTypeReferenceDirective", function (typeReferenceDirective, sourceFile) {
1516
+ const result = owner.client.apiRequest("getResolvedTypeReferenceDirectiveFromTypeReferenceDirective", {
1517
+ snapshot: owner.snapshotId,
1518
+ project: owner.project.id,
1519
+ sourceFile,
1520
+ typeDirectiveName: typeReferenceDirective.fileName,
1521
+ resolutionMode: typeReferenceDirective.resolutionMode,
1522
+ });
1523
+ return result ?? undefined;
1524
+ }, function* (typeReferenceDirective, sourceFile) {
1525
+ const result = yield* apiRequest("getResolvedTypeReferenceDirectiveFromTypeReferenceDirective", {
1526
+ snapshot: owner.snapshotId,
1527
+ project: owner.project.id,
1528
+ sourceFile,
1529
+ typeDirectiveName: typeReferenceDirective.fileName,
1530
+ resolutionMode: typeReferenceDirective.resolutionMode,
1531
+ });
1532
+ return result ?? undefined;
1533
+ });
1534
+ }
1449
1535
  get getSourceFileNames() {
1450
1536
  const owner = this;
1451
1537
  return cacheGeneratorMethod(owner, "getSourceFileNames", function () {
@@ -1608,7 +1694,7 @@ export class Program {
1608
1694
  const data = owner.client.apiRequest("getSyntacticDiagnostics", {
1609
1695
  snapshot: owner.snapshotId,
1610
1696
  project: owner.project.id,
1611
- ...(files !== undefined ? { files } : {}),
1697
+ files,
1612
1698
  });
1613
1699
  return data ?? [];
1614
1700
  }, function* (file) {
@@ -1618,7 +1704,7 @@ export class Program {
1618
1704
  const data = yield* apiRequest("getSyntacticDiagnostics", {
1619
1705
  snapshot: owner.snapshotId,
1620
1706
  project: owner.project.id,
1621
- ...(files !== undefined ? { files } : {}),
1707
+ files,
1622
1708
  });
1623
1709
  return data ?? [];
1624
1710
  });
@@ -1636,7 +1722,7 @@ export class Program {
1636
1722
  const data = owner.client.apiRequest("getBindDiagnostics", {
1637
1723
  snapshot: owner.snapshotId,
1638
1724
  project: owner.project.id,
1639
- ...(files !== undefined ? { files } : {}),
1725
+ files,
1640
1726
  });
1641
1727
  return data ?? [];
1642
1728
  }, function* (file) {
@@ -1646,7 +1732,7 @@ export class Program {
1646
1732
  const data = yield* apiRequest("getBindDiagnostics", {
1647
1733
  snapshot: owner.snapshotId,
1648
1734
  project: owner.project.id,
1649
- ...(files !== undefined ? { files } : {}),
1735
+ files,
1650
1736
  });
1651
1737
  return data ?? [];
1652
1738
  });
@@ -1664,7 +1750,7 @@ export class Program {
1664
1750
  const data = owner.client.apiRequest("getSemanticDiagnostics", {
1665
1751
  snapshot: owner.snapshotId,
1666
1752
  project: owner.project.id,
1667
- ...(files !== undefined ? { files } : {}),
1753
+ files,
1668
1754
  });
1669
1755
  return data ?? [];
1670
1756
  }, function* (file) {
@@ -1674,7 +1760,7 @@ export class Program {
1674
1760
  const data = yield* apiRequest("getSemanticDiagnostics", {
1675
1761
  snapshot: owner.snapshotId,
1676
1762
  project: owner.project.id,
1677
- ...(files !== undefined ? { files } : {}),
1763
+ files,
1678
1764
  });
1679
1765
  return data ?? [];
1680
1766
  });
@@ -1692,7 +1778,7 @@ export class Program {
1692
1778
  const data = owner.client.apiRequest("getSuggestionDiagnostics", {
1693
1779
  snapshot: owner.snapshotId,
1694
1780
  project: owner.project.id,
1695
- ...(files !== undefined ? { files } : {}),
1781
+ files,
1696
1782
  });
1697
1783
  return data ?? [];
1698
1784
  }, function* (file) {
@@ -1702,7 +1788,7 @@ export class Program {
1702
1788
  const data = yield* apiRequest("getSuggestionDiagnostics", {
1703
1789
  snapshot: owner.snapshotId,
1704
1790
  project: owner.project.id,
1705
- ...(files !== undefined ? { files } : {}),
1791
+ files,
1706
1792
  });
1707
1793
  return data ?? [];
1708
1794
  });
@@ -1720,7 +1806,7 @@ export class Program {
1720
1806
  const data = owner.client.apiRequest("getDeclarationDiagnostics", {
1721
1807
  snapshot: owner.snapshotId,
1722
1808
  project: owner.project.id,
1723
- ...(files !== undefined ? { files } : {}),
1809
+ files,
1724
1810
  });
1725
1811
  return data ?? [];
1726
1812
  }, function* (file) {
@@ -1730,7 +1816,7 @@ export class Program {
1730
1816
  const data = yield* apiRequest("getDeclarationDiagnostics", {
1731
1817
  snapshot: owner.snapshotId,
1732
1818
  project: owner.project.id,
1733
- ...(files !== undefined ? { files } : {}),
1819
+ files,
1734
1820
  });
1735
1821
  return data ?? [];
1736
1822
  });
@@ -1803,7 +1889,7 @@ export class Program {
1803
1889
  const response = owner.client.apiRequest("emit", {
1804
1890
  snapshot: owner.snapshotId,
1805
1891
  project: owner.project.id,
1806
- ...(emitOnly !== undefined ? { emitOnly } : {}),
1892
+ emitOnly,
1807
1893
  });
1808
1894
  const fileSystem = response.emittedFilesContents.length
1809
1895
  ? {
@@ -1821,7 +1907,7 @@ export class Program {
1821
1907
  const response = yield* apiRequest("emit", {
1822
1908
  snapshot: owner.snapshotId,
1823
1909
  project: owner.project.id,
1824
- ...(emitOnly !== undefined ? { emitOnly } : {}),
1910
+ emitOnly,
1825
1911
  });
1826
1912
  const fileSystem = response.emittedFilesContents.length
1827
1913
  ? {
@@ -1846,14 +1932,14 @@ export class Program {
1846
1932
  const response = owner.client.apiRequest("emitToString", {
1847
1933
  snapshot: owner.snapshotId,
1848
1934
  project: owner.project.id,
1849
- ...(emitOnly !== undefined ? { emitOnly } : {}),
1935
+ emitOnly,
1850
1936
  });
1851
1937
  return toEmitOutput(response);
1852
1938
  }, function* (emitOnly) {
1853
1939
  const response = yield* apiRequest("emitToString", {
1854
1940
  snapshot: owner.snapshotId,
1855
1941
  project: owner.project.id,
1856
- ...(emitOnly !== undefined ? { emitOnly } : {}),
1942
+ emitOnly,
1857
1943
  });
1858
1944
  return toEmitOutput(response);
1859
1945
  });
@@ -2300,14 +2386,10 @@ export class Checker {
2300
2386
  project: owner.project.id,
2301
2387
  name,
2302
2388
  meaning,
2303
- ...(isNode ? { location: getNodeId(location) } : {}),
2304
- ...(!isNode && location
2305
- ? {
2306
- file: location.document,
2307
- position: location.position,
2308
- }
2309
- : {}),
2310
- ...(excludeGlobals !== undefined ? { excludeGlobals } : {}),
2389
+ location: isNode ? getNodeId(location) : undefined,
2390
+ file: !isNode && location ? location.document : undefined,
2391
+ position: !isNode && location ? location.position : undefined,
2392
+ excludeGlobals,
2311
2393
  });
2312
2394
  return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
2313
2395
  }, function* (name, meaning, location, excludeGlobals) {
@@ -2318,14 +2400,10 @@ export class Checker {
2318
2400
  project: owner.project.id,
2319
2401
  name,
2320
2402
  meaning,
2321
- ...(isNode ? { location: getNodeId(location) } : {}),
2322
- ...(!isNode && location
2323
- ? {
2324
- file: location.document,
2325
- position: location.position,
2326
- }
2327
- : {}),
2328
- ...(excludeGlobals !== undefined ? { excludeGlobals } : {}),
2403
+ location: isNode ? getNodeId(location) : undefined,
2404
+ file: !isNode && location ? location.document : undefined,
2405
+ position: !isNode && location ? location.position : undefined,
2406
+ excludeGlobals,
2329
2407
  });
2330
2408
  return data ? owner.objectRegistry.getOrCreateSymbol(data) : undefined;
2331
2409
  });
@@ -2342,12 +2420,9 @@ export class Checker {
2342
2420
  snapshot: owner.snapshotId,
2343
2421
  project: owner.project.id,
2344
2422
  meaning,
2345
- ...(isNode
2346
- ? { location: getNodeId(location) }
2347
- : {
2348
- file: location.document,
2349
- position: location.position,
2350
- }),
2423
+ location: isNode ? getNodeId(location) : undefined,
2424
+ file: isNode ? undefined : location.document,
2425
+ position: isNode ? undefined : location.position,
2351
2426
  });
2352
2427
  return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
2353
2428
  }, function* (location, meaning) {
@@ -2357,12 +2432,9 @@ export class Checker {
2357
2432
  snapshot: owner.snapshotId,
2358
2433
  project: owner.project.id,
2359
2434
  meaning,
2360
- ...(isNode
2361
- ? { location: getNodeId(location) }
2362
- : {
2363
- file: location.document,
2364
- position: location.position,
2365
- }),
2435
+ location: isNode ? getNodeId(location) : undefined,
2436
+ file: isNode ? undefined : location.document,
2437
+ position: isNode ? undefined : location.position,
2366
2438
  });
2367
2439
  return data ? data.map(d => owner.objectRegistry.getOrCreateSymbol(d)) : [];
2368
2440
  });
@@ -2689,8 +2761,8 @@ export class Checker {
2689
2761
  snapshot: owner.snapshotId,
2690
2762
  project: owner.project.id,
2691
2763
  type: type.id,
2692
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2693
- ...(flags !== undefined ? { flags } : {}),
2764
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2765
+ flags,
2694
2766
  });
2695
2767
  if (!binaryData)
2696
2768
  return undefined;
@@ -2700,8 +2772,8 @@ export class Checker {
2700
2772
  snapshot: owner.snapshotId,
2701
2773
  project: owner.project.id,
2702
2774
  type: type.id,
2703
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2704
- ...(flags !== undefined ? { flags } : {}),
2775
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2776
+ flags,
2705
2777
  });
2706
2778
  if (!binaryData)
2707
2779
  return undefined;
@@ -2716,8 +2788,8 @@ export class Checker {
2716
2788
  project: owner.project.id,
2717
2789
  signature: signature.id,
2718
2790
  kind,
2719
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2720
- ...(flags !== undefined ? { flags } : {}),
2791
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2792
+ flags,
2721
2793
  });
2722
2794
  if (!binaryData)
2723
2795
  return undefined;
@@ -2728,8 +2800,8 @@ export class Checker {
2728
2800
  project: owner.project.id,
2729
2801
  signature: signature.id,
2730
2802
  kind,
2731
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2732
- ...(flags !== undefined ? { flags } : {}),
2803
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2804
+ flags,
2733
2805
  });
2734
2806
  if (!binaryData)
2735
2807
  return undefined;
@@ -2743,8 +2815,8 @@ export class Checker {
2743
2815
  snapshot: owner.snapshotId,
2744
2816
  project: owner.project.id,
2745
2817
  type: type.id,
2746
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2747
- ...(flags !== undefined ? { flags } : {}),
2818
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2819
+ flags,
2748
2820
  });
2749
2821
  if (typeof result !== "string")
2750
2822
  throw new TypeError("typeToString returned a non-string result");
@@ -2754,8 +2826,8 @@ export class Checker {
2754
2826
  snapshot: owner.snapshotId,
2755
2827
  project: owner.project.id,
2756
2828
  type: type.id,
2757
- ...(enclosingDeclaration ? { location: getNodeId(enclosingDeclaration) } : {}),
2758
- ...(flags !== undefined ? { flags } : {}),
2829
+ location: enclosingDeclaration ? getNodeId(enclosingDeclaration) : undefined,
2830
+ flags,
2759
2831
  });
2760
2832
  if (typeof result !== "string")
2761
2833
  throw new TypeError("typeToString returned a non-string result");
@@ -3337,18 +3409,18 @@ export class Emitter {
3337
3409
  const base64 = uint8ArrayToBase64(encoded);
3338
3410
  return owner.client.apiRequest("printNode", {
3339
3411
  data: base64,
3340
- ...(options.preserveSourceNewlines !== undefined ? { preserveSourceNewlines: options.preserveSourceNewlines } : {}),
3341
- ...(options.neverAsciiEscape !== undefined ? { neverAsciiEscape: options.neverAsciiEscape } : {}),
3342
- ...(options.terminateUnterminatedLiterals !== undefined ? { terminateUnterminatedLiterals: options.terminateUnterminatedLiterals } : {}),
3412
+ preserveSourceNewlines: options.preserveSourceNewlines,
3413
+ neverAsciiEscape: options.neverAsciiEscape,
3414
+ terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
3343
3415
  });
3344
3416
  }, function* (node, options = {}) {
3345
3417
  const encoded = encodeNode(node);
3346
3418
  const base64 = uint8ArrayToBase64(encoded);
3347
3419
  return yield* apiRequest("printNode", {
3348
3420
  data: base64,
3349
- ...(options.preserveSourceNewlines !== undefined ? { preserveSourceNewlines: options.preserveSourceNewlines } : {}),
3350
- ...(options.neverAsciiEscape !== undefined ? { neverAsciiEscape: options.neverAsciiEscape } : {}),
3351
- ...(options.terminateUnterminatedLiterals !== undefined ? { terminateUnterminatedLiterals: options.terminateUnterminatedLiterals } : {}),
3421
+ preserveSourceNewlines: options.preserveSourceNewlines,
3422
+ neverAsciiEscape: options.neverAsciiEscape,
3423
+ terminateUnterminatedLiterals: options.terminateUnterminatedLiterals,
3352
3424
  });
3353
3425
  });
3354
3426
  }