typescript 5.6.0-dev.20240626 → 5.6.0-dev.20240628

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.20240626`;
21
+ var version = `${versionMajorMinor}.0-dev.20240628`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -4902,6 +4902,7 @@ var sys = (() => {
4902
4902
  writeFile: writeFile2,
4903
4903
  watchFile: watchFile2,
4904
4904
  watchDirectory,
4905
+ preferNonRecursiveWatch: !fsSupportsRecursiveFsWatch,
4905
4906
  resolvePath: (path) => _path.resolve(path),
4906
4907
  fileExists,
4907
4908
  directoryExists,
@@ -12544,6 +12545,12 @@ function projectReferenceIsEqualTo(oldRef, newRef) {
12544
12545
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
12545
12546
  return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.alternateResult === newResolution.alternateResult;
12546
12547
  }
12548
+ function getResolvedModuleFromResolution(resolution) {
12549
+ return resolution.resolvedModule;
12550
+ }
12551
+ function getResolvedTypeReferenceDirectiveFromResolution(resolution) {
12552
+ return resolution.resolvedTypeReferenceDirective;
12553
+ }
12547
12554
  function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
12548
12555
  var _a;
12549
12556
  const alternateResult = (_a = host.getResolvedModule(sourceFile, moduleReference, mode)) == null ? void 0 : _a.alternateResult;
@@ -86894,6 +86901,7 @@ function createTypeChecker(host) {
86894
86901
  }
86895
86902
  case 7 /* ES2022 */:
86896
86903
  case 99 /* ESNext */:
86904
+ case 200 /* Preserve */:
86897
86905
  case 4 /* System */:
86898
86906
  if (languageVersion >= 4 /* ES2017 */) {
86899
86907
  break;
@@ -119674,12 +119682,18 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119674
119682
  }
119675
119683
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
119676
119684
  var _a2, _b2;
119677
- if (!moduleNames.length) return emptyArray;
119678
119685
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
119679
119686
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
119680
119687
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
119681
119688
  mark("beforeResolveModule");
119682
- const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames);
119689
+ const result = actualResolveModuleNamesWorker(
119690
+ moduleNames,
119691
+ containingFileName,
119692
+ redirectedReference,
119693
+ options,
119694
+ containingFile,
119695
+ reusedNames
119696
+ );
119683
119697
  mark("afterResolveModule");
119684
119698
  measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
119685
119699
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -119687,13 +119701,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119687
119701
  }
119688
119702
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, reusedNames) {
119689
119703
  var _a2, _b2;
119690
- if (!typeDirectiveNames.length) return [];
119691
119704
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119692
119705
  const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
119693
119706
  const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile);
119694
119707
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
119695
119708
  mark("beforeResolveTypeReference");
119696
- const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames);
119709
+ const result = actualResolveTypeReferenceDirectiveNamesWorker(
119710
+ typeDirectiveNames,
119711
+ containingFileName,
119712
+ redirectedReference,
119713
+ options,
119714
+ containingSourceFile,
119715
+ reusedNames
119716
+ );
119697
119717
  mark("afterResolveTypeReference");
119698
119718
  measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
119699
119719
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -119763,144 +119783,123 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119763
119783
  }
119764
119784
  return classifiableNames;
119765
119785
  }
119766
- function resolveModuleNamesReusingOldState(moduleNames, file) {
119767
- if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
119768
- return resolveModuleNamesWorker(
119769
- moduleNames,
119770
- file,
119771
- /*reusedNames*/
119772
- void 0
119773
- );
119774
- }
119775
- let unknownModuleNames;
119776
- let result;
119777
- let reusedNames;
119778
- const predictedToResolveToAmbientModuleMarker = emptyResolution;
119779
- const oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
119780
- for (let i = 0; i < moduleNames.length; i++) {
119781
- const moduleName = moduleNames[i];
119782
- if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) {
119783
- const oldResolution = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName));
119784
- if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
119785
- if (isTraceEnabled(options, host)) {
119786
- trace(
119787
- host,
119788
- oldResolution.resolvedModule.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
119789
- moduleName.text,
119790
- getNormalizedAbsolutePath(file.originalFileName, currentDirectory),
119791
- oldResolution.resolvedModule.resolvedFileName,
119792
- oldResolution.resolvedModule.packageId && packageIdToString(oldResolution.resolvedModule.packageId)
119793
- );
119794
- }
119795
- (result ?? (result = new Array(moduleNames.length)))[i] = oldResolution;
119796
- (reusedNames ?? (reusedNames = [])).push(moduleName);
119797
- continue;
119798
- }
119799
- }
119800
- let resolvesToAmbientModuleInNonModifiedFile = false;
119801
- if (contains(file.ambientModuleNames, moduleName.text)) {
119802
- resolvesToAmbientModuleInNonModifiedFile = true;
119803
- if (isTraceEnabled(options, host)) {
119804
- trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
119805
- }
119806
- } else {
119807
- resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
119808
- }
119809
- if (resolvesToAmbientModuleInNonModifiedFile) {
119810
- (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
119811
- } else {
119812
- (unknownModuleNames ?? (unknownModuleNames = [])).push(moduleName);
119786
+ function resolveModuleNamesReusingOldState(moduleNames, containingFile) {
119787
+ return resolveNamesReusingOldState({
119788
+ entries: moduleNames,
119789
+ containingFile,
119790
+ containingSourceFile: containingFile,
119791
+ redirectedReference: getRedirectReferenceForResolution(containingFile),
119792
+ nameAndModeGetter: moduleResolutionNameAndModeGetter,
119793
+ resolutionWorker: resolveModuleNamesWorker,
119794
+ getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
119795
+ getResolved: getResolvedModuleFromResolution,
119796
+ canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
119797
+ isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
119798
+ });
119799
+ }
119800
+ function moduleNameResolvesToAmbientModule(moduleName, file) {
119801
+ if (contains(file.ambientModuleNames, moduleName.text)) {
119802
+ if (isTraceEnabled(options, host)) {
119803
+ trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
119813
119804
  }
119805
+ return true;
119806
+ } else {
119807
+ return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
119814
119808
  }
119815
- const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray;
119816
- if (!result) {
119817
- Debug.assert(resolutions.length === moduleNames.length);
119818
- return resolutions;
119809
+ }
119810
+ function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file) {
119811
+ var _a2;
119812
+ const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
119813
+ const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
119814
+ if (resolutionToFile && resolvedFile) {
119815
+ return false;
119819
119816
  }
119820
- let j = 0;
119821
- for (let i = 0; i < result.length; i++) {
119822
- if (!result[i]) {
119823
- result[i] = resolutions[j];
119824
- j++;
119825
- }
119817
+ const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
119818
+ if (!unmodifiedFile) {
119819
+ return false;
119826
119820
  }
119827
- Debug.assert(j === resolutions.length);
119828
- return result;
119829
- function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
119830
- var _a2;
119831
- const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
119832
- const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
119833
- if (resolutionToFile && resolvedFile) {
119834
- return false;
119835
- }
119836
- const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
119837
- if (!unmodifiedFile) {
119838
- return false;
119839
- }
119840
- if (isTraceEnabled(options, host)) {
119841
- trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
119842
- }
119843
- return true;
119821
+ if (isTraceEnabled(options, host)) {
119822
+ trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
119844
119823
  }
119824
+ return true;
119845
119825
  }
119846
119826
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
119847
- var _a2;
119848
- if (structureIsReused === 0 /* Not */) {
119849
- return resolveTypeReferenceDirectiveNamesWorker(
119850
- typeDirectiveNames,
119827
+ const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119828
+ return resolveNamesReusingOldState({
119829
+ entries: typeDirectiveNames,
119830
+ containingFile,
119831
+ containingSourceFile,
119832
+ redirectedReference: containingSourceFile && getRedirectReferenceForResolution(containingSourceFile),
119833
+ nameAndModeGetter: typeReferenceResolutionNameAndModeGetter,
119834
+ resolutionWorker: resolveTypeReferenceDirectiveNamesWorker,
119835
+ getResolutionFromOldProgram: (name, mode) => {
119836
+ var _a2;
119837
+ return containingSourceFile ? oldProgram == null ? void 0 : oldProgram.getResolvedTypeReferenceDirective(containingSourceFile, name, mode) : (_a2 = oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a2.get(name, mode);
119838
+ },
119839
+ getResolved: getResolvedTypeReferenceDirectiveFromResolution,
119840
+ canReuseResolutionsInFile: () => containingSourceFile ? containingSourceFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName)) && !hasInvalidatedResolutions(containingSourceFile.path) : !hasInvalidatedResolutions(toPath3(containingFile))
119841
+ });
119842
+ }
119843
+ function resolveNamesReusingOldState({
119844
+ entries,
119845
+ containingFile,
119846
+ containingSourceFile,
119847
+ redirectedReference,
119848
+ nameAndModeGetter,
119849
+ resolutionWorker,
119850
+ getResolutionFromOldProgram,
119851
+ getResolved,
119852
+ canReuseResolutionsInFile,
119853
+ isEntryResolvingToAmbientModule
119854
+ }) {
119855
+ if (!entries.length) return emptyArray;
119856
+ if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119857
+ return resolutionWorker(
119858
+ entries,
119851
119859
  containingFile,
119852
119860
  /*reusedNames*/
119853
119861
  void 0
119854
119862
  );
119855
119863
  }
119856
- let unknownTypeReferenceDirectiveNames;
119864
+ let unknownEntries;
119865
+ let unknownEntryIndices;
119857
119866
  let result;
119858
119867
  let reusedNames;
119859
- const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119860
- const oldSourceFile = !isString(containingFile) ? oldProgram && oldProgram.getSourceFile(containingFile.fileName) : void 0;
119861
- const canReuseResolutions = !isString(containingFile) ? containingFile === oldSourceFile && !hasInvalidatedResolutions(containingFile.path) : !hasInvalidatedResolutions(toPath3(containingFile));
119862
- for (let i = 0; i < typeDirectiveNames.length; i++) {
119863
- const entry = typeDirectiveNames[i];
119864
- if (canReuseResolutions) {
119865
- const typeDirectiveName = getTypeReferenceResolutionName(entry);
119866
- const mode = getModeForFileReference(entry, containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat);
119867
- const oldResolution = !isString(containingFile) ? oldProgram == null ? void 0 : oldProgram.getResolvedTypeReferenceDirective(containingFile, typeDirectiveName, mode) : (_a2 = oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a2.get(typeDirectiveName, mode);
119868
- if (oldResolution == null ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
119868
+ const reuseResolutions = canReuseResolutionsInFile();
119869
+ for (let i = 0; i < entries.length; i++) {
119870
+ const entry = entries[i];
119871
+ if (reuseResolutions) {
119872
+ const name = nameAndModeGetter.getName(entry);
119873
+ const mode = nameAndModeGetter.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) ?? options);
119874
+ const oldResolution = getResolutionFromOldProgram(name, mode);
119875
+ const oldResolved = oldResolution && getResolved(oldResolution);
119876
+ if (oldResolved) {
119869
119877
  if (isTraceEnabled(options, host)) {
119870
119878
  trace(
119871
119879
  host,
119872
- oldResolution.resolvedTypeReferenceDirective.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
119873
- typeDirectiveName,
119874
- !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile,
119875
- oldResolution.resolvedTypeReferenceDirective.resolvedFileName,
119876
- oldResolution.resolvedTypeReferenceDirective.packageId && packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId)
119880
+ resolutionWorker === resolveModuleNamesWorker ? oldResolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : oldResolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
119881
+ name,
119882
+ containingSourceFile ? getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : containingFile,
119883
+ oldResolved.resolvedFileName,
119884
+ oldResolved.packageId && packageIdToString(oldResolved.packageId)
119877
119885
  );
119878
119886
  }
119879
- (result ?? (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
119887
+ (result ?? (result = new Array(entries.length)))[i] = oldResolution;
119880
119888
  (reusedNames ?? (reusedNames = [])).push(entry);
119881
119889
  continue;
119882
119890
  }
119883
119891
  }
119884
- (unknownTypeReferenceDirectiveNames ?? (unknownTypeReferenceDirectiveNames = [])).push(entry);
119885
- }
119886
- if (!unknownTypeReferenceDirectiveNames) return result || emptyArray;
119887
- const resolutions = resolveTypeReferenceDirectiveNamesWorker(
119888
- unknownTypeReferenceDirectiveNames,
119889
- containingFile,
119890
- reusedNames
119891
- );
119892
- if (!result) {
119893
- Debug.assert(resolutions.length === typeDirectiveNames.length);
119894
- return resolutions;
119895
- }
119896
- let j = 0;
119897
- for (let i = 0; i < result.length; i++) {
119898
- if (!result[i]) {
119899
- result[i] = resolutions[j];
119900
- j++;
119892
+ if (isEntryResolvingToAmbientModule == null ? void 0 : isEntryResolvingToAmbientModule(entry, containingFile)) {
119893
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119894
+ } else {
119895
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
119896
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119901
119897
  }
119902
119898
  }
119903
- Debug.assert(j === resolutions.length);
119899
+ if (!unknownEntries) return result;
119900
+ const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
119901
+ if (!result) return resolutions;
119902
+ resolutions.forEach((resolution, index) => result[unknownEntryIndices[index]] = resolution);
119904
119903
  return result;
119905
119904
  }
119906
119905
  function canReuseProjectReferences() {
@@ -124308,7 +124307,7 @@ function canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(fileOrDirPath) {
124308
124307
  function canWatchAffectingLocation(filePath) {
124309
124308
  return canWatchAffectedPackageJsonOrNodeModulesOfAtTypes(filePath);
124310
124309
  }
124311
- function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory) {
124310
+ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch) {
124312
124311
  const failedLookupPathComponents = getPathComponents(failedLookupLocationPath);
124313
124312
  failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
124314
124313
  const failedLookupComponents = getPathComponents(failedLookupLocation);
@@ -124340,10 +124339,11 @@ function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLoo
124340
124339
  perceivedOsRootLength,
124341
124340
  nodeModulesIndex,
124342
124341
  rootPathComponents,
124343
- lastNodeModulesIndex
124342
+ lastNodeModulesIndex,
124343
+ preferNonRecursiveWatch
124344
124344
  );
124345
124345
  }
124346
- function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents, lastNodeModulesIndex) {
124346
+ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dirPathComponents, dirPathComponentsLength, perceivedOsRootLength, nodeModulesIndex, rootPathComponents, lastNodeModulesIndex, preferNonRecursiveWatch) {
124347
124347
  if (nodeModulesIndex !== -1) {
124348
124348
  return getDirectoryOfFailedLookupWatch(
124349
124349
  dirComponents,
@@ -124354,11 +124354,13 @@ function getDirectoryToWatchFromFailedLookupLocationDirectory(dirComponents, dir
124354
124354
  }
124355
124355
  let nonRecursive = true;
124356
124356
  let length2 = dirPathComponentsLength;
124357
- for (let i = 0; i < dirPathComponentsLength; i++) {
124358
- if (dirPathComponents[i] !== rootPathComponents[i]) {
124359
- nonRecursive = false;
124360
- length2 = Math.max(i + 1, perceivedOsRootLength + 1);
124361
- break;
124357
+ if (!preferNonRecursiveWatch) {
124358
+ for (let i = 0; i < dirPathComponentsLength; i++) {
124359
+ if (dirPathComponents[i] !== rootPathComponents[i]) {
124360
+ nonRecursive = false;
124361
+ length2 = Math.max(i + 1, perceivedOsRootLength + 1);
124362
+ break;
124363
+ }
124362
124364
  }
124363
124365
  }
124364
124366
  return getDirectoryOfFailedLookupWatch(
@@ -124386,7 +124388,7 @@ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, lengt
124386
124388
  packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
124387
124389
  };
124388
124390
  }
124389
- function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, filterCustomPath) {
124391
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
124390
124392
  const typeRootPathComponents = getPathComponents(typeRootPath);
124391
124393
  if (isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
124392
124394
  return rootPath;
@@ -124399,7 +124401,8 @@ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootP
124399
124401
  perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
124400
124402
  typeRootPathComponents.indexOf("node_modules"),
124401
124403
  rootPathComponents,
124402
- typeRootPathComponents.lastIndexOf("node_modules")
124404
+ typeRootPathComponents.lastIndexOf("node_modules"),
124405
+ preferNonRecursiveWatch
124403
124406
  );
124404
124407
  return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
124405
124408
  }
@@ -124536,12 +124539,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124536
124539
  clear: clear2,
124537
124540
  onChangesAffectModuleResolution
124538
124541
  };
124539
- function getResolvedModule(resolution) {
124540
- return resolution.resolvedModule;
124541
- }
124542
- function getResolvedTypeReferenceDirective(resolution) {
124543
- return resolution.resolvedTypeReferenceDirective;
124544
- }
124545
124542
  function clear2() {
124546
124543
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
124547
124544
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -124623,7 +124620,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124623
124620
  stopWatchFailedLookupLocationOfResolution(
124624
124621
  resolution,
124625
124622
  resolutionHost.toPath(getInferredLibraryNameResolveFrom(resolutionHost.getCompilationSettings(), getCurrentDirectory(), libFileName)),
124626
- getResolvedModule
124623
+ getResolvedModuleFromResolution
124627
124624
  );
124628
124625
  resolvedLibraries.delete(libFileName);
124629
124626
  }
@@ -124803,7 +124800,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124803
124800
  getModuleResolutionHost(resolutionHost),
124804
124801
  typeReferenceDirectiveResolutionCache
124805
124802
  ),
124806
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
124803
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution,
124807
124804
  shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
124808
124805
  deferWatchingNonRelativeResolution: false
124809
124806
  });
@@ -124824,7 +124821,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124824
124821
  resolutionHost,
124825
124822
  moduleResolutionCache
124826
124823
  ),
124827
- getResolutionWithResolvedFileName: getResolvedModule,
124824
+ getResolutionWithResolvedFileName: getResolvedModuleFromResolution,
124828
124825
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
124829
124826
  logChanges: logChangesWhenResolvingModule,
124830
124827
  deferWatchingNonRelativeResolution: true
@@ -124842,17 +124839,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124842
124839
  libraryName,
124843
124840
  resolution,
124844
124841
  path,
124845
- getResolvedModule,
124842
+ getResolvedModuleFromResolution,
124846
124843
  /*deferWatchingNonRelativeResolution*/
124847
124844
  false
124848
124845
  );
124849
124846
  resolvedLibraries.set(libFileName, resolution);
124850
124847
  if (existingResolution) {
124851
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModule);
124848
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModuleFromResolution);
124852
124849
  }
124853
124850
  } else {
124854
124851
  if (isTraceEnabled(options, host)) {
124855
- const resolved = getResolvedModule(resolution);
124852
+ const resolved = getResolvedModuleFromResolution(resolution);
124856
124853
  trace(
124857
124854
  host,
124858
124855
  (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved,
@@ -124891,27 +124888,20 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124891
124888
  return endsWith(dirPath, "/node_modules/@types");
124892
124889
  }
124893
124890
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution) {
124894
- var _a;
124895
- if (resolution.refCount) {
124896
- resolution.refCount++;
124897
- Debug.assertIsDefined(resolution.files);
124891
+ (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
124892
+ if (resolution.files.size !== 1) return;
124893
+ if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
124894
+ watchFailedLookupLocationOfResolution(resolution);
124898
124895
  } else {
124899
- resolution.refCount = 1;
124900
- Debug.assert(!((_a = resolution.files) == null ? void 0 : _a.size));
124901
- if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
124902
- watchFailedLookupLocationOfResolution(resolution);
124903
- } else {
124904
- nonRelativeExternalModuleResolutions.add(name, resolution);
124905
- }
124906
- const resolved = getResolutionWithResolvedFileName(resolution);
124907
- if (resolved && resolved.resolvedFileName) {
124908
- const key = resolutionHost.toPath(resolved.resolvedFileName);
124909
- let resolutions = resolvedFileToResolution.get(key);
124910
- if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
124911
- resolutions.add(resolution);
124912
- }
124896
+ nonRelativeExternalModuleResolutions.add(name, resolution);
124897
+ }
124898
+ const resolved = getResolutionWithResolvedFileName(resolution);
124899
+ if (resolved && resolved.resolvedFileName) {
124900
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
124901
+ let resolutions = resolvedFileToResolution.get(key);
124902
+ if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
124903
+ resolutions.add(resolution);
124913
124904
  }
124914
- (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
124915
124905
  }
124916
124906
  function watchFailedLookupLocation(failedLookupLocation, setAtRoot) {
124917
124907
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
@@ -124921,7 +124911,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124921
124911
  rootDir,
124922
124912
  rootPath,
124923
124913
  rootPathComponents,
124924
- getCurrentDirectory
124914
+ getCurrentDirectory,
124915
+ resolutionHost.preferNonRecursiveWatch
124925
124916
  );
124926
124917
  if (toWatch) {
124927
124918
  const { dir, dirPath, nonRecursive, packageDir, packageDirPath } = toWatch;
@@ -124936,7 +124927,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124936
124927
  return setAtRoot;
124937
124928
  }
124938
124929
  function watchFailedLookupLocationOfResolution(resolution) {
124939
- Debug.assert(!!resolution.refCount);
124930
+ var _a;
124931
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
124940
124932
  const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
124941
124933
  if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !alternateResult) return;
124942
124934
  if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || alternateResult) resolutionsWithFailedLookups.add(resolution);
@@ -124962,7 +124954,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124962
124954
  watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !alternateResult);
124963
124955
  }
124964
124956
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
124965
- Debug.assert(!!resolution.refCount);
124957
+ var _a;
124958
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
124966
124959
  const { affectingLocations } = resolution;
124967
124960
  if (!(affectingLocations == null ? void 0 : affectingLocations.length)) return;
124968
124961
  if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.add(resolution);
@@ -125118,7 +125111,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125118
125111
  rootDir,
125119
125112
  rootPath,
125120
125113
  rootPathComponents,
125121
- getCurrentDirectory
125114
+ getCurrentDirectory,
125115
+ resolutionHost.preferNonRecursiveWatch
125122
125116
  );
125123
125117
  if (toWatch) {
125124
125118
  const { dirPath, packageDirPath } = toWatch;
@@ -125149,10 +125143,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125149
125143
  }
125150
125144
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125151
125145
  Debug.checkDefined(resolution.files).delete(filePath);
125152
- resolution.refCount--;
125153
- if (resolution.refCount) {
125154
- return;
125155
- }
125146
+ if (resolution.files.size) return;
125147
+ resolution.files = void 0;
125156
125148
  const resolved = getResolutionWithResolvedFileName(resolution);
125157
125149
  if (resolved && resolved.resolvedFileName) {
125158
125150
  const key = resolutionHost.toPath(resolved.resolvedFileName);
@@ -125217,8 +125209,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125217
125209
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
125218
125210
  }
125219
125211
  function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
125220
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule, syncDirWatcherRemove);
125221
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective, syncDirWatcherRemove);
125212
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
125213
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
125222
125214
  }
125223
125215
  function invalidateResolutions(resolutions, canInvalidate) {
125224
125216
  if (!resolutions) return false;
@@ -125348,6 +125340,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125348
125340
  rootPath,
125349
125341
  rootPathComponents,
125350
125342
  getCurrentDirectory,
125343
+ resolutionHost.preferNonRecursiveWatch,
125351
125344
  (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
125352
125345
  );
125353
125346
  if (dirPath) {
@@ -125816,7 +125809,8 @@ function createWatchHost(system = sys, reportWatchStatus2) {
125816
125809
  watchFile: maybeBind(system, system.watchFile) || returnNoopFileWatcher,
125817
125810
  watchDirectory: maybeBind(system, system.watchDirectory) || returnNoopFileWatcher,
125818
125811
  setTimeout: maybeBind(system, system.setTimeout) || noop,
125819
- clearTimeout: maybeBind(system, system.clearTimeout) || noop
125812
+ clearTimeout: maybeBind(system, system.clearTimeout) || noop,
125813
+ preferNonRecursiveWatch: system.preferNonRecursiveWatch
125820
125814
  };
125821
125815
  }
125822
125816
  var WatchType = {
@@ -126122,6 +126116,7 @@ function createWatchProgram(host) {
126122
126116
  compilerHost.toPath = toPath3;
126123
126117
  compilerHost.getCompilationSettings = () => compilerOptions;
126124
126118
  compilerHost.useSourceOfProjectReferenceRedirect = maybeBind(host, host.useSourceOfProjectReferenceRedirect);
126119
+ compilerHost.preferNonRecursiveWatch = host.preferNonRecursiveWatch;
126125
126120
  compilerHost.watchDirectoryOfFailedLookupLocation = (dir, cb, flags) => watchDirectory(dir, cb, flags, watchOptions, WatchType.FailedLookupLocations);
126126
126121
  compilerHost.watchAffectingFileLocation = (file, cb) => watchFile2(file, cb, 2e3 /* High */, watchOptions, WatchType.AffectingFileLocation);
126127
126122
  compilerHost.watchTypeRootsDirectory = (dir, cb, flags) => watchDirectory(dir, cb, flags, watchOptions, WatchType.TypeRoots);
@@ -2651,6 +2651,7 @@ declare namespace ts {
2651
2651
  interface ServerHost extends System {
2652
2652
  watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
2653
2653
  watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
2654
+ preferNonRecursiveWatch?: boolean;
2654
2655
  setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
2655
2656
  clearTimeout(timeoutId: any): void;
2656
2657
  setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
@@ -2659,6 +2660,18 @@ declare namespace ts {
2659
2660
  trace?(s: string): void;
2660
2661
  require?(initialPath: string, moduleName: string): ModuleImportResult;
2661
2662
  }
2663
+ interface InstallPackageOptionsWithProject extends InstallPackageOptions {
2664
+ projectName: string;
2665
+ projectRootPath: Path;
2666
+ }
2667
+ interface ITypingsInstaller {
2668
+ isKnownTypesPackageName(name: string): boolean;
2669
+ installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
2670
+ enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
2671
+ attach(projectService: ProjectService): void;
2672
+ onProjectClosed(p: Project): void;
2673
+ readonly globalTypingsCacheLocation: string | undefined;
2674
+ }
2662
2675
  function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
2663
2676
  function toNormalizedPath(fileName: string): NormalizedPath;
2664
2677
  function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path;
@@ -2751,19 +2764,6 @@ declare namespace ts {
2751
2764
  positionToLineOffset(position: number): protocol.Location;
2752
2765
  isJavaScript(): boolean;
2753
2766
  }
2754
- interface InstallPackageOptionsWithProject extends InstallPackageOptions {
2755
- projectName: string;
2756
- projectRootPath: Path;
2757
- }
2758
- interface ITypingsInstaller {
2759
- isKnownTypesPackageName(name: string): boolean;
2760
- installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
2761
- enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
2762
- attach(projectService: ProjectService): void;
2763
- onProjectClosed(p: Project): void;
2764
- readonly globalTypingsCacheLocation: string | undefined;
2765
- }
2766
- const nullTypingsInstaller: ITypingsInstaller;
2767
2767
  function allRootFilesAreJsOrDts(project: Project): boolean;
2768
2768
  function allFilesAreJsOrDts(project: Project): boolean;
2769
2769
  enum ProjectKind {
@@ -2817,6 +2817,7 @@ declare namespace ts {
2817
2817
  private lastReportedVersion;
2818
2818
  protected projectErrors: Diagnostic[] | undefined;
2819
2819
  protected isInitialLoadPending: () => boolean;
2820
+ private typingsCache;
2820
2821
  private typingWatchers;
2821
2822
  private readonly cancellationToken;
2822
2823
  isNonTsProject(): boolean;
@@ -2829,7 +2830,6 @@ declare namespace ts {
2829
2830
  readonly jsDocParsingMode: JSDocParsingMode | undefined;
2830
2831
  isKnownTypesPackageName(name: string): boolean;
2831
2832
  installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
2832
- private get typingsCache();
2833
2833
  getCompilationSettings(): ts.CompilerOptions;
2834
2834
  getCompilerOptions(): ts.CompilerOptions;
2835
2835
  getNewLine(): string;
@@ -3148,6 +3148,7 @@ declare namespace ts {
3148
3148
  configFileName?: NormalizedPath;
3149
3149
  configFileErrors?: readonly Diagnostic[];
3150
3150
  }
3151
+ const nullTypingsInstaller: ITypingsInstaller;
3151
3152
  interface ProjectServiceOptions {
3152
3153
  host: ServerHost;
3153
3154
  logger: Logger;
@@ -9591,6 +9592,7 @@ declare namespace ts {
9591
9592
  setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
9592
9593
  /** If provided, will be used to reset existing delayed compilation */
9593
9594
  clearTimeout?(timeoutId: any): void;
9595
+ preferNonRecursiveWatch?: boolean;
9594
9596
  }
9595
9597
  interface ProgramHost<T extends BuilderProgram> {
9596
9598
  /**