typescript 5.6.0-dev.20240707 → 5.6.0-dev.20240709

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-dev.20240707`;
21
+ var version = `${versionMajorMinor}.0-dev.20240709`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12745,7 +12745,7 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
12745
12745
  }
12746
12746
  if (isJSDocNode(node) || node.kind === 12 /* JsxText */) {
12747
12747
  return skipTrivia(
12748
- (sourceFile || getSourceFileOfNode(node)).text,
12748
+ (sourceFile ?? getSourceFileOfNode(node)).text,
12749
12749
  node.pos,
12750
12750
  /*stopAfterLineBreak*/
12751
12751
  false,
@@ -12757,13 +12757,14 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
12757
12757
  return getTokenPosOfNode(node.jsDoc[0], sourceFile);
12758
12758
  }
12759
12759
  if (node.kind === 352 /* SyntaxList */) {
12760
- const first2 = firstOrUndefined(getNodeChildren(node));
12760
+ sourceFile ?? (sourceFile = getSourceFileOfNode(node));
12761
+ const first2 = firstOrUndefined(getNodeChildren(node, sourceFile));
12761
12762
  if (first2) {
12762
12763
  return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
12763
12764
  }
12764
12765
  }
12765
12766
  return skipTrivia(
12766
- (sourceFile || getSourceFileOfNode(node)).text,
12767
+ (sourceFile ?? getSourceFileOfNode(node)).text,
12767
12768
  node.pos,
12768
12769
  /*stopAfterLineBreak*/
12769
12770
  false,
@@ -23511,7 +23512,7 @@ function createNodeFactory(flags, baseFactory2) {
23511
23512
  }
23512
23513
  function createSyntaxList(children) {
23513
23514
  const node = createBaseNode(352 /* SyntaxList */);
23514
- setNodeChildren(node, children);
23515
+ node._children = children;
23515
23516
  return node;
23516
23517
  }
23517
23518
  function createNotEmittedStatement(original) {
@@ -26287,17 +26288,31 @@ function isJSDocImportTag(node) {
26287
26288
  }
26288
26289
 
26289
26290
  // src/compiler/factory/nodeChildren.ts
26290
- var nodeChildren = /* @__PURE__ */ new WeakMap();
26291
- function getNodeChildren(node) {
26292
- if (!isNodeKind(node.kind)) return emptyArray;
26293
- return nodeChildren.get(node);
26291
+ var sourceFileToNodeChildren = /* @__PURE__ */ new WeakMap();
26292
+ function getNodeChildren(node, sourceFile) {
26293
+ var _a;
26294
+ const kind = node.kind;
26295
+ if (!isNodeKind(kind)) {
26296
+ return emptyArray;
26297
+ }
26298
+ if (kind === 352 /* SyntaxList */) {
26299
+ return node._children;
26300
+ }
26301
+ return (_a = sourceFileToNodeChildren.get(sourceFile)) == null ? void 0 : _a.get(node);
26294
26302
  }
26295
- function setNodeChildren(node, children) {
26296
- nodeChildren.set(node, children);
26297
- return children;
26303
+ function unsetNodeChildren(node, origSourceFile) {
26304
+ var _a;
26305
+ if (node.kind === 352 /* SyntaxList */) {
26306
+ Debug.fail("Did not expect to unset the children of a SyntaxList.");
26307
+ }
26308
+ (_a = sourceFileToNodeChildren.get(origSourceFile)) == null ? void 0 : _a.delete(node);
26298
26309
  }
26299
- function unsetNodeChildren(node) {
26300
- nodeChildren.delete(node);
26310
+ function transferSourceFileChildren(sourceFile, targetSourceFile) {
26311
+ const map2 = sourceFileToNodeChildren.get(sourceFile);
26312
+ if (map2 !== void 0) {
26313
+ sourceFileToNodeChildren.delete(sourceFile);
26314
+ sourceFileToNodeChildren.set(targetSourceFile, map2);
26315
+ }
26301
26316
  }
26302
26317
 
26303
26318
  // src/compiler/factory/utilities.ts
@@ -34887,6 +34902,7 @@ var IncrementalParser;
34887
34902
  aggressiveChecks
34888
34903
  );
34889
34904
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
34905
+ transferSourceFileChildren(sourceFile, result);
34890
34906
  return result;
34891
34907
  }
34892
34908
  IncrementalParser2.updateSourceFile = updateSourceFile;
@@ -34922,7 +34938,7 @@ var IncrementalParser;
34922
34938
  }
34923
34939
  }
34924
34940
  }
34925
- function moveElementEntirelyPastChangeRange(element, isArray2, delta, oldText, newText, aggressiveChecks) {
34941
+ function moveElementEntirelyPastChangeRange(element, origSourceFile, isArray2, delta, oldText, newText, aggressiveChecks) {
34926
34942
  if (isArray2) {
34927
34943
  visitArray2(element);
34928
34944
  } else {
@@ -34934,7 +34950,7 @@ var IncrementalParser;
34934
34950
  if (aggressiveChecks && shouldCheckNode(node)) {
34935
34951
  text = oldText.substring(node.pos, node.end);
34936
34952
  }
34937
- unsetNodeChildren(node);
34953
+ unsetNodeChildren(node, origSourceFile);
34938
34954
  setTextRangePosEnd(node, node.pos + delta, node.end + delta);
34939
34955
  if (aggressiveChecks && shouldCheckNode(node)) {
34940
34956
  Debug.assert(text === newText.substring(node.pos, node.end));
@@ -35008,6 +35024,7 @@ var IncrementalParser;
35008
35024
  if (child.pos > changeRangeOldEnd) {
35009
35025
  moveElementEntirelyPastChangeRange(
35010
35026
  child,
35027
+ sourceFile,
35011
35028
  /*isArray*/
35012
35029
  false,
35013
35030
  delta,
@@ -35020,7 +35037,7 @@ var IncrementalParser;
35020
35037
  const fullEnd = child.end;
35021
35038
  if (fullEnd >= changeStart) {
35022
35039
  markAsIntersectingIncrementalChange(child);
35023
- unsetNodeChildren(child);
35040
+ unsetNodeChildren(child, sourceFile);
35024
35041
  adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
35025
35042
  forEachChild(child, visitNode3, visitArray2);
35026
35043
  if (hasJSDocNodes(child)) {
@@ -35038,6 +35055,7 @@ var IncrementalParser;
35038
35055
  if (array.pos > changeRangeOldEnd) {
35039
35056
  moveElementEntirelyPastChangeRange(
35040
35057
  array,
35058
+ sourceFile,
35041
35059
  /*isArray*/
35042
35060
  true,
35043
35061
  delta,
@@ -119475,7 +119493,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119475
119493
  const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
119476
119494
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
119477
119495
  oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
119478
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
119496
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path), newFile);
119479
119497
  }
119480
119498
  }
119481
119499
  if (!host.getParsedCommandLine) {
@@ -119485,7 +119503,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119485
119503
  resolvedProjectReference.sourceFile,
119486
119504
  oldProgram.getCompilerOptions(),
119487
119505
  /*hasSourceFileByPath*/
119488
- false
119506
+ false,
119507
+ /*newSourceFileByResolvedPath*/
119508
+ void 0
119489
119509
  );
119490
119510
  }
119491
119511
  });
@@ -125180,11 +125200,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125180
125200
  );
125181
125201
  } else if (packageDirWatcher.isSymlink !== isSymlink) {
125182
125202
  packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
125183
- removeDirectoryWatcher(
125184
- packageDirWatcher.isSymlink ? packageDirPath : dirPath,
125185
- /*syncDirWatcherRemove*/
125186
- false
125187
- );
125203
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125188
125204
  watcher.watcher = createDirPathToWatcher();
125189
125205
  });
125190
125206
  packageDirWatcher.isSymlink = isSymlink;
@@ -125224,7 +125240,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125224
125240
  }
125225
125241
  return dirWatcher;
125226
125242
  }
125227
- function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove) {
125243
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
125228
125244
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
125229
125245
  const toWatch = getDirectoryToWatchFailedLookupLocation(
125230
125246
  failedLookupLocation,
@@ -125244,7 +125260,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125244
125260
  const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
125245
125261
  forDirPath.refCount--;
125246
125262
  if (forDirPath.refCount === 0) {
125247
- removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath, syncDirWatcherRemove);
125263
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
125248
125264
  packageDirWatcher.dirPathToWatcher.delete(dirPath);
125249
125265
  if (packageDirWatcher.isSymlink) {
125250
125266
  const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
@@ -125254,15 +125270,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125254
125270
  dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
125255
125271
  }
125256
125272
  }
125257
- if (syncDirWatcherRemove) closePackageDirWatcher(packageDirWatcher, packageDirPath);
125258
125273
  }
125259
125274
  } else {
125260
- removeDirectoryWatcher(dirPath, syncDirWatcherRemove);
125275
+ removeDirectoryWatcher(dirPath);
125261
125276
  }
125262
125277
  }
125263
125278
  return removeAtRoot;
125264
125279
  }
125265
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125280
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
125266
125281
  Debug.checkDefined(resolution.files).delete(filePath);
125267
125282
  if (resolution.files.size) return;
125268
125283
  resolution.files = void 0;
@@ -125277,11 +125292,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125277
125292
  let removeAtRoot = false;
125278
125293
  if (failedLookupLocations) {
125279
125294
  for (const failedLookupLocation of failedLookupLocations) {
125280
- removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove);
125295
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
125281
125296
  }
125282
125297
  }
125283
- if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot, syncDirWatcherRemove);
125284
- if (removeAtRoot) removeDirectoryWatcher(rootPath, syncDirWatcherRemove);
125298
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
125299
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
125285
125300
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
125286
125301
  resolutionsWithOnlyAffectingLocations.delete(resolution);
125287
125302
  }
@@ -125289,14 +125304,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125289
125304
  for (const affectingLocation of affectingLocations) {
125290
125305
  const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
125291
125306
  watcher.resolutions--;
125292
- if (syncDirWatcherRemove) closeFileWatcherOfAffectingLocation(watcher, affectingLocation);
125293
125307
  }
125294
125308
  }
125295
125309
  }
125296
- function removeDirectoryWatcher(dirPath, syncDirWatcherRemove) {
125310
+ function removeDirectoryWatcher(dirPath) {
125297
125311
  const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
125298
125312
  dirWatcher.refCount--;
125299
- if (syncDirWatcherRemove) closeDirectoryWatchesOfFailedLookup(dirWatcher, dirPath);
125300
125313
  }
125301
125314
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
125302
125315
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
@@ -125307,15 +125320,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125307
125320
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
125308
125321
  }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
125309
125322
  }
125310
- function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125323
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
125311
125324
  const resolutions = cache.get(filePath);
125312
125325
  if (resolutions) {
125313
125326
  resolutions.forEach(
125314
125327
  (resolution) => stopWatchFailedLookupLocationOfResolution(
125315
125328
  resolution,
125316
125329
  filePath,
125317
- getResolutionWithResolvedFileName,
125318
- syncDirWatcherRemove
125330
+ getResolutionWithResolvedFileName
125319
125331
  )
125320
125332
  );
125321
125333
  cache.delete(filePath);
@@ -125329,9 +125341,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125329
125341
  if (!resolvedProjectReference) return;
125330
125342
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
125331
125343
  }
125332
- function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
125333
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
125334
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
125344
+ function removeResolutionsOfFile(filePath) {
125345
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
125346
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
125335
125347
  }
125336
125348
  function invalidateResolutions(resolutions, canInvalidate) {
125337
125349
  if (!resolutions) return false;
package/lib/typescript.js CHANGED
@@ -2143,6 +2143,7 @@ __export(typescript_exports, {
2143
2143
  trace: () => trace,
2144
2144
  tracing: () => tracing,
2145
2145
  tracingEnabled: () => tracingEnabled,
2146
+ transferSourceFileChildren: () => transferSourceFileChildren,
2146
2147
  transform: () => transform,
2147
2148
  transformClassFields: () => transformClassFields,
2148
2149
  transformDeclarations: () => transformDeclarations,
@@ -2250,7 +2251,7 @@ module.exports = __toCommonJS(typescript_exports);
2250
2251
 
2251
2252
  // src/compiler/corePublic.ts
2252
2253
  var versionMajorMinor = "5.6";
2253
- var version = `${versionMajorMinor}.0-dev.20240707`;
2254
+ var version = `${versionMajorMinor}.0-dev.20240709`;
2254
2255
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2255
2256
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2256
2257
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -16357,7 +16358,7 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
16357
16358
  }
16358
16359
  if (isJSDocNode(node) || node.kind === 12 /* JsxText */) {
16359
16360
  return skipTrivia(
16360
- (sourceFile || getSourceFileOfNode(node)).text,
16361
+ (sourceFile ?? getSourceFileOfNode(node)).text,
16361
16362
  node.pos,
16362
16363
  /*stopAfterLineBreak*/
16363
16364
  false,
@@ -16369,13 +16370,14 @@ function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
16369
16370
  return getTokenPosOfNode(node.jsDoc[0], sourceFile);
16370
16371
  }
16371
16372
  if (node.kind === 352 /* SyntaxList */) {
16372
- const first2 = firstOrUndefined(getNodeChildren(node));
16373
+ sourceFile ?? (sourceFile = getSourceFileOfNode(node));
16374
+ const first2 = firstOrUndefined(getNodeChildren(node, sourceFile));
16373
16375
  if (first2) {
16374
16376
  return getTokenPosOfNode(first2, sourceFile, includeJsDoc);
16375
16377
  }
16376
16378
  }
16377
16379
  return skipTrivia(
16378
- (sourceFile || getSourceFileOfNode(node)).text,
16380
+ (sourceFile ?? getSourceFileOfNode(node)).text,
16379
16381
  node.pos,
16380
16382
  /*stopAfterLineBreak*/
16381
16383
  false,
@@ -27606,7 +27608,7 @@ function createNodeFactory(flags, baseFactory2) {
27606
27608
  }
27607
27609
  function createSyntaxList3(children) {
27608
27610
  const node = createBaseNode(352 /* SyntaxList */);
27609
- setNodeChildren(node, children);
27611
+ node._children = children;
27610
27612
  return node;
27611
27613
  }
27612
27614
  function createNotEmittedStatement(original) {
@@ -30507,17 +30509,43 @@ function isSyntaxList(n) {
30507
30509
  }
30508
30510
 
30509
30511
  // src/compiler/factory/nodeChildren.ts
30510
- var nodeChildren = /* @__PURE__ */ new WeakMap();
30511
- function getNodeChildren(node) {
30512
- if (!isNodeKind(node.kind)) return emptyArray;
30513
- return nodeChildren.get(node);
30512
+ var sourceFileToNodeChildren = /* @__PURE__ */ new WeakMap();
30513
+ function getNodeChildren(node, sourceFile) {
30514
+ var _a;
30515
+ const kind = node.kind;
30516
+ if (!isNodeKind(kind)) {
30517
+ return emptyArray;
30518
+ }
30519
+ if (kind === 352 /* SyntaxList */) {
30520
+ return node._children;
30521
+ }
30522
+ return (_a = sourceFileToNodeChildren.get(sourceFile)) == null ? void 0 : _a.get(node);
30514
30523
  }
30515
- function setNodeChildren(node, children) {
30516
- nodeChildren.set(node, children);
30524
+ function setNodeChildren(node, sourceFile, children) {
30525
+ if (node.kind === 352 /* SyntaxList */) {
30526
+ Debug.fail("Should not need to re-set the children of a SyntaxList.");
30527
+ }
30528
+ let map2 = sourceFileToNodeChildren.get(sourceFile);
30529
+ if (map2 === void 0) {
30530
+ map2 = /* @__PURE__ */ new WeakMap();
30531
+ sourceFileToNodeChildren.set(sourceFile, map2);
30532
+ }
30533
+ map2.set(node, children);
30517
30534
  return children;
30518
30535
  }
30519
- function unsetNodeChildren(node) {
30520
- nodeChildren.delete(node);
30536
+ function unsetNodeChildren(node, origSourceFile) {
30537
+ var _a;
30538
+ if (node.kind === 352 /* SyntaxList */) {
30539
+ Debug.fail("Did not expect to unset the children of a SyntaxList.");
30540
+ }
30541
+ (_a = sourceFileToNodeChildren.get(origSourceFile)) == null ? void 0 : _a.delete(node);
30542
+ }
30543
+ function transferSourceFileChildren(sourceFile, targetSourceFile) {
30544
+ const map2 = sourceFileToNodeChildren.get(sourceFile);
30545
+ if (map2 !== void 0) {
30546
+ sourceFileToNodeChildren.delete(sourceFile);
30547
+ sourceFileToNodeChildren.set(targetSourceFile, map2);
30548
+ }
30521
30549
  }
30522
30550
 
30523
30551
  // src/compiler/factory/utilities.ts
@@ -39126,6 +39154,7 @@ var IncrementalParser;
39126
39154
  aggressiveChecks
39127
39155
  );
39128
39156
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
39157
+ transferSourceFileChildren(sourceFile, result);
39129
39158
  return result;
39130
39159
  }
39131
39160
  IncrementalParser2.updateSourceFile = updateSourceFile2;
@@ -39161,7 +39190,7 @@ var IncrementalParser;
39161
39190
  }
39162
39191
  }
39163
39192
  }
39164
- function moveElementEntirelyPastChangeRange(element, isArray2, delta, oldText, newText, aggressiveChecks) {
39193
+ function moveElementEntirelyPastChangeRange(element, origSourceFile, isArray2, delta, oldText, newText, aggressiveChecks) {
39165
39194
  if (isArray2) {
39166
39195
  visitArray2(element);
39167
39196
  } else {
@@ -39173,7 +39202,7 @@ var IncrementalParser;
39173
39202
  if (aggressiveChecks && shouldCheckNode(node)) {
39174
39203
  text = oldText.substring(node.pos, node.end);
39175
39204
  }
39176
- unsetNodeChildren(node);
39205
+ unsetNodeChildren(node, origSourceFile);
39177
39206
  setTextRangePosEnd(node, node.pos + delta, node.end + delta);
39178
39207
  if (aggressiveChecks && shouldCheckNode(node)) {
39179
39208
  Debug.assert(text === newText.substring(node.pos, node.end));
@@ -39247,6 +39276,7 @@ var IncrementalParser;
39247
39276
  if (child.pos > changeRangeOldEnd) {
39248
39277
  moveElementEntirelyPastChangeRange(
39249
39278
  child,
39279
+ sourceFile,
39250
39280
  /*isArray*/
39251
39281
  false,
39252
39282
  delta,
@@ -39259,7 +39289,7 @@ var IncrementalParser;
39259
39289
  const fullEnd = child.end;
39260
39290
  if (fullEnd >= changeStart) {
39261
39291
  markAsIntersectingIncrementalChange(child);
39262
- unsetNodeChildren(child);
39292
+ unsetNodeChildren(child, sourceFile);
39263
39293
  adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
39264
39294
  forEachChild(child, visitNode3, visitArray2);
39265
39295
  if (hasJSDocNodes(child)) {
@@ -39277,6 +39307,7 @@ var IncrementalParser;
39277
39307
  if (array.pos > changeRangeOldEnd) {
39278
39308
  moveElementEntirelyPastChangeRange(
39279
39309
  array,
39310
+ sourceFile,
39280
39311
  /*isArray*/
39281
39312
  true,
39282
39313
  delta,
@@ -124299,7 +124330,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124299
124330
  const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
124300
124331
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
124301
124332
  oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
124302
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
124333
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path), newFile);
124303
124334
  }
124304
124335
  }
124305
124336
  if (!host.getParsedCommandLine) {
@@ -124309,7 +124340,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124309
124340
  resolvedProjectReference.sourceFile,
124310
124341
  oldProgram.getCompilerOptions(),
124311
124342
  /*hasSourceFileByPath*/
124312
- false
124343
+ false,
124344
+ /*newSourceFileByResolvedPath*/
124345
+ void 0
124313
124346
  );
124314
124347
  }
124315
124348
  });
@@ -130065,11 +130098,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130065
130098
  );
130066
130099
  } else if (packageDirWatcher.isSymlink !== isSymlink) {
130067
130100
  packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
130068
- removeDirectoryWatcher(
130069
- packageDirWatcher.isSymlink ? packageDirPath : dirPath,
130070
- /*syncDirWatcherRemove*/
130071
- false
130072
- );
130101
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
130073
130102
  watcher.watcher = createDirPathToWatcher();
130074
130103
  });
130075
130104
  packageDirWatcher.isSymlink = isSymlink;
@@ -130109,7 +130138,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130109
130138
  }
130110
130139
  return dirWatcher;
130111
130140
  }
130112
- function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove) {
130141
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
130113
130142
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
130114
130143
  const toWatch = getDirectoryToWatchFailedLookupLocation(
130115
130144
  failedLookupLocation,
@@ -130129,7 +130158,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130129
130158
  const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
130130
130159
  forDirPath.refCount--;
130131
130160
  if (forDirPath.refCount === 0) {
130132
- removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath, syncDirWatcherRemove);
130161
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
130133
130162
  packageDirWatcher.dirPathToWatcher.delete(dirPath);
130134
130163
  if (packageDirWatcher.isSymlink) {
130135
130164
  const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
@@ -130139,15 +130168,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130139
130168
  dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
130140
130169
  }
130141
130170
  }
130142
- if (syncDirWatcherRemove) closePackageDirWatcher(packageDirWatcher, packageDirPath);
130143
130171
  }
130144
130172
  } else {
130145
- removeDirectoryWatcher(dirPath, syncDirWatcherRemove);
130173
+ removeDirectoryWatcher(dirPath);
130146
130174
  }
130147
130175
  }
130148
130176
  return removeAtRoot;
130149
130177
  }
130150
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
130178
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
130151
130179
  Debug.checkDefined(resolution.files).delete(filePath);
130152
130180
  if (resolution.files.size) return;
130153
130181
  resolution.files = void 0;
@@ -130162,11 +130190,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130162
130190
  let removeAtRoot = false;
130163
130191
  if (failedLookupLocations) {
130164
130192
  for (const failedLookupLocation of failedLookupLocations) {
130165
- removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove);
130193
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
130166
130194
  }
130167
130195
  }
130168
- if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot, syncDirWatcherRemove);
130169
- if (removeAtRoot) removeDirectoryWatcher(rootPath, syncDirWatcherRemove);
130196
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
130197
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
130170
130198
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
130171
130199
  resolutionsWithOnlyAffectingLocations.delete(resolution);
130172
130200
  }
@@ -130174,14 +130202,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130174
130202
  for (const affectingLocation of affectingLocations) {
130175
130203
  const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
130176
130204
  watcher.resolutions--;
130177
- if (syncDirWatcherRemove) closeFileWatcherOfAffectingLocation(watcher, affectingLocation);
130178
130205
  }
130179
130206
  }
130180
130207
  }
130181
- function removeDirectoryWatcher(dirPath, syncDirWatcherRemove) {
130208
+ function removeDirectoryWatcher(dirPath) {
130182
130209
  const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
130183
130210
  dirWatcher.refCount--;
130184
- if (syncDirWatcherRemove) closeDirectoryWatchesOfFailedLookup(dirWatcher, dirPath);
130185
130211
  }
130186
130212
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
130187
130213
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
@@ -130192,15 +130218,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130192
130218
  scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
130193
130219
  }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
130194
130220
  }
130195
- function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
130221
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
130196
130222
  const resolutions = cache.get(filePath);
130197
130223
  if (resolutions) {
130198
130224
  resolutions.forEach(
130199
130225
  (resolution) => stopWatchFailedLookupLocationOfResolution(
130200
130226
  resolution,
130201
130227
  filePath,
130202
- getResolutionWithResolvedFileName,
130203
- syncDirWatcherRemove
130228
+ getResolutionWithResolvedFileName
130204
130229
  )
130205
130230
  );
130206
130231
  cache.delete(filePath);
@@ -130214,9 +130239,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
130214
130239
  if (!resolvedProjectReference) return;
130215
130240
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
130216
130241
  }
130217
- function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
130218
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
130219
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
130242
+ function removeResolutionsOfFile(filePath) {
130243
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
130244
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
130220
130245
  }
130221
130246
  function invalidateResolutions(resolutions, canInvalidate) {
130222
130247
  if (!resolutions) return false;
@@ -148116,9 +148141,9 @@ var NodeObject = class {
148116
148141
  getChildAt(index, sourceFile) {
148117
148142
  return this.getChildren(sourceFile)[index];
148118
148143
  }
148119
- getChildren(sourceFile) {
148144
+ getChildren(sourceFile = getSourceFileOfNode(this)) {
148120
148145
  this.assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine");
148121
- return getNodeChildren(this) ?? setNodeChildren(this, createChildren(this, sourceFile));
148146
+ return getNodeChildren(this, sourceFile) ?? setNodeChildren(this, sourceFile, createChildren(this, sourceFile));
148122
148147
  }
148123
148148
  getFirstToken(sourceFile) {
148124
148149
  this.assertHasRealPosition();
@@ -148199,7 +148224,7 @@ function createSyntaxList(nodes, parent2) {
148199
148224
  pos = node.end;
148200
148225
  }
148201
148226
  addSyntheticNodes(children, pos, nodes.end, parent2);
148202
- setNodeChildren(list, children);
148227
+ list._children = children;
148203
148228
  return list;
148204
148229
  }
148205
148230
  var TokenOrIdentifierObject = class {
@@ -149138,13 +149163,18 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
149138
149163
  if (host.getParsedCommandLine) {
149139
149164
  (_a3 = host.onReleaseParsedCommandLine) == null ? void 0 : _a3.call(host, configFileName, oldResolvedRef, oldOptions);
149140
149165
  } else if (oldResolvedRef) {
149141
- onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
149166
+ releaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
149142
149167
  }
149143
149168
  }
149144
- function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
149169
+ function releaseOldSourceFile(oldSourceFile, oldOptions) {
149145
149170
  const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
149146
149171
  documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
149147
149172
  }
149173
+ function onReleaseOldSourceFile(oldSourceFile, oldOptions, hasSourceFileByPath, newSourceFileByResolvedPath) {
149174
+ var _a3;
149175
+ releaseOldSourceFile(oldSourceFile, oldOptions);
149176
+ (_a3 = host.onReleaseOldSourceFile) == null ? void 0 : _a3.call(host, oldSourceFile, oldOptions, hasSourceFileByPath, newSourceFileByResolvedPath);
149177
+ }
149148
149178
  function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
149149
149179
  return getOrCreateSourceFileByPath(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
149150
149180
  }
@@ -180571,6 +180601,7 @@ __export(ts_exports2, {
180571
180601
  trace: () => trace,
180572
180602
  tracing: () => tracing,
180573
180603
  tracingEnabled: () => tracingEnabled,
180604
+ transferSourceFileChildren: () => transferSourceFileChildren,
180574
180605
  transform: () => transform,
180575
180606
  transformClassFields: () => transformClassFields,
180576
180607
  transformDeclarations: () => transformDeclarations,
@@ -183084,6 +183115,12 @@ var Project2 = class _Project {
183084
183115
  this.hasAddedOrRemovedSymlinks = true;
183085
183116
  }
183086
183117
  /** @internal */
183118
+ onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath, newSourceFileByResolvedPath) {
183119
+ if (!newSourceFileByResolvedPath || oldSourceFile.resolvedPath === oldSourceFile.path && newSourceFileByResolvedPath.resolvedPath !== oldSourceFile.path) {
183120
+ this.detachScriptInfoFromProject(oldSourceFile.fileName, hasSourceFileByPath);
183121
+ }
183122
+ }
183123
+ /** @internal */
183087
183124
  updateFromProject() {
183088
183125
  updateProjectIfDirty(this);
183089
183126
  }
@@ -183267,30 +183304,6 @@ var Project2 = class _Project {
183267
183304
  let hasNewProgram = false;
183268
183305
  if (this.program && (!oldProgram || this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */)) {
183269
183306
  hasNewProgram = true;
183270
- if (oldProgram) {
183271
- for (const f of oldProgram.getSourceFiles()) {
183272
- const newFile = this.program.getSourceFileByPath(f.resolvedPath);
183273
- if (!newFile || f.resolvedPath === f.path && newFile.resolvedPath !== f.path) {
183274
- this.detachScriptInfoFromProject(
183275
- f.fileName,
183276
- !!this.program.getSourceFileByPath(f.path),
183277
- /*syncDirWatcherRemove*/
183278
- true
183279
- );
183280
- }
183281
- }
183282
- oldProgram.forEachResolvedProjectReference((resolvedProjectReference) => {
183283
- if (!this.program.getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
183284
- this.detachScriptInfoFromProject(
183285
- resolvedProjectReference.sourceFile.fileName,
183286
- /*noRemoveResolution*/
183287
- void 0,
183288
- /*syncDirWatcherRemove*/
183289
- true
183290
- );
183291
- }
183292
- });
183293
- }
183294
183307
  this.rootFilesMap.forEach((value, path) => {
183295
183308
  var _a2;
183296
183309
  const file = this.program.getSourceFileByPath(path);
@@ -183415,12 +183428,12 @@ var Project2 = class _Project {
183415
183428
  sendPerformanceEvent(kind, durationMs) {
183416
183429
  this.projectService.sendPerformanceEvent(kind, durationMs);
183417
183430
  }
183418
- detachScriptInfoFromProject(uncheckedFileName, noRemoveResolution, syncDirWatcherRemove) {
183431
+ detachScriptInfoFromProject(uncheckedFileName, noRemoveResolution) {
183419
183432
  const scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName);
183420
183433
  if (scriptInfoToDetach) {
183421
183434
  scriptInfoToDetach.detachFromProject(this);
183422
183435
  if (!noRemoveResolution) {
183423
- this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path, syncDirWatcherRemove);
183436
+ this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path);
183424
183437
  }
183425
183438
  }
183426
183439
  }
@@ -194946,6 +194959,7 @@ if (typeof console !== "undefined") {
194946
194959
  trace,
194947
194960
  tracing,
194948
194961
  tracingEnabled,
194962
+ transferSourceFileChildren,
194949
194963
  transform,
194950
194964
  transformClassFields,
194951
194965
  transformDeclarations,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.6.0-dev.20240707",
5
+ "version": "5.6.0-dev.20240709",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -68,7 +68,7 @@
68
68
  "globals": "^13.24.0",
69
69
  "hereby": "^1.8.9",
70
70
  "jsonc-parser": "^3.3.1",
71
- "knip": "^5.23.1",
71
+ "knip": "^5.25.1",
72
72
  "minimist": "^1.2.8",
73
73
  "mocha": "^10.5.2",
74
74
  "mocha-fivemat-progress-reporter": "^0.1.0",
@@ -113,5 +113,5 @@
113
113
  "node": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "3163fe7e3898c1f48cd9bc097b96e3426cd2a453"
116
+ "gitHead": "a6fb4dc103a57516450149d765e240e64a3a26b0"
117
117
  }