typescript 5.6.0-dev.20240626 → 5.6.0-dev.20240627

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.20240627`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12544,6 +12544,12 @@ function projectReferenceIsEqualTo(oldRef, newRef) {
12544
12544
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
12545
12545
  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
12546
  }
12547
+ function getResolvedModuleFromResolution(resolution) {
12548
+ return resolution.resolvedModule;
12549
+ }
12550
+ function getResolvedTypeReferenceDirectiveFromResolution(resolution) {
12551
+ return resolution.resolvedTypeReferenceDirective;
12552
+ }
12547
12553
  function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
12548
12554
  var _a;
12549
12555
  const alternateResult = (_a = host.getResolvedModule(sourceFile, moduleReference, mode)) == null ? void 0 : _a.alternateResult;
@@ -86894,6 +86900,7 @@ function createTypeChecker(host) {
86894
86900
  }
86895
86901
  case 7 /* ES2022 */:
86896
86902
  case 99 /* ESNext */:
86903
+ case 200 /* Preserve */:
86897
86904
  case 4 /* System */:
86898
86905
  if (languageVersion >= 4 /* ES2017 */) {
86899
86906
  break;
@@ -119674,12 +119681,18 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119674
119681
  }
119675
119682
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
119676
119683
  var _a2, _b2;
119677
- if (!moduleNames.length) return emptyArray;
119678
119684
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
119679
119685
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
119680
119686
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
119681
119687
  mark("beforeResolveModule");
119682
- const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames);
119688
+ const result = actualResolveModuleNamesWorker(
119689
+ moduleNames,
119690
+ containingFileName,
119691
+ redirectedReference,
119692
+ options,
119693
+ containingFile,
119694
+ reusedNames
119695
+ );
119683
119696
  mark("afterResolveModule");
119684
119697
  measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
119685
119698
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -119687,13 +119700,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119687
119700
  }
119688
119701
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, reusedNames) {
119689
119702
  var _a2, _b2;
119690
- if (!typeDirectiveNames.length) return [];
119691
119703
  const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119692
119704
  const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
119693
119705
  const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile);
119694
119706
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
119695
119707
  mark("beforeResolveTypeReference");
119696
- const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames);
119708
+ const result = actualResolveTypeReferenceDirectiveNamesWorker(
119709
+ typeDirectiveNames,
119710
+ containingFileName,
119711
+ redirectedReference,
119712
+ options,
119713
+ containingSourceFile,
119714
+ reusedNames
119715
+ );
119697
119716
  mark("afterResolveTypeReference");
119698
119717
  measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
119699
119718
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -119763,144 +119782,123 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119763
119782
  }
119764
119783
  return classifiableNames;
119765
119784
  }
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);
119785
+ function resolveModuleNamesReusingOldState(moduleNames, containingFile) {
119786
+ return resolveNamesReusingOldState({
119787
+ entries: moduleNames,
119788
+ containingFile,
119789
+ containingSourceFile: containingFile,
119790
+ redirectedReference: getRedirectReferenceForResolution(containingFile),
119791
+ nameAndModeGetter: moduleResolutionNameAndModeGetter,
119792
+ resolutionWorker: resolveModuleNamesWorker,
119793
+ getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
119794
+ getResolved: getResolvedModuleFromResolution,
119795
+ canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
119796
+ isEntryResolvingToAmbientModule: moduleNameResolvesToAmbientModule
119797
+ });
119798
+ }
119799
+ function moduleNameResolvesToAmbientModule(moduleName, file) {
119800
+ if (contains(file.ambientModuleNames, moduleName.text)) {
119801
+ if (isTraceEnabled(options, host)) {
119802
+ trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
119813
119803
  }
119804
+ return true;
119805
+ } else {
119806
+ return moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file);
119814
119807
  }
119815
- const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray;
119816
- if (!result) {
119817
- Debug.assert(resolutions.length === moduleNames.length);
119818
- return resolutions;
119808
+ }
119809
+ function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, file) {
119810
+ var _a2;
119811
+ const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
119812
+ const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
119813
+ if (resolutionToFile && resolvedFile) {
119814
+ return false;
119819
119815
  }
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
- }
119816
+ const unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName.text);
119817
+ if (!unmodifiedFile) {
119818
+ return false;
119826
119819
  }
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;
119820
+ if (isTraceEnabled(options, host)) {
119821
+ trace(host, Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName.text, unmodifiedFile);
119844
119822
  }
119823
+ return true;
119845
119824
  }
119846
119825
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
119847
- var _a2;
119848
- if (structureIsReused === 0 /* Not */) {
119849
- return resolveTypeReferenceDirectiveNamesWorker(
119850
- typeDirectiveNames,
119826
+ const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
119827
+ return resolveNamesReusingOldState({
119828
+ entries: typeDirectiveNames,
119829
+ containingFile,
119830
+ containingSourceFile,
119831
+ redirectedReference: containingSourceFile && getRedirectReferenceForResolution(containingSourceFile),
119832
+ nameAndModeGetter: typeReferenceResolutionNameAndModeGetter,
119833
+ resolutionWorker: resolveTypeReferenceDirectiveNamesWorker,
119834
+ getResolutionFromOldProgram: (name, mode) => {
119835
+ var _a2;
119836
+ 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);
119837
+ },
119838
+ getResolved: getResolvedTypeReferenceDirectiveFromResolution,
119839
+ canReuseResolutionsInFile: () => containingSourceFile ? containingSourceFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName)) && !hasInvalidatedResolutions(containingSourceFile.path) : !hasInvalidatedResolutions(toPath3(containingFile))
119840
+ });
119841
+ }
119842
+ function resolveNamesReusingOldState({
119843
+ entries,
119844
+ containingFile,
119845
+ containingSourceFile,
119846
+ redirectedReference,
119847
+ nameAndModeGetter,
119848
+ resolutionWorker,
119849
+ getResolutionFromOldProgram,
119850
+ getResolved,
119851
+ canReuseResolutionsInFile,
119852
+ isEntryResolvingToAmbientModule
119853
+ }) {
119854
+ if (!entries.length) return emptyArray;
119855
+ if (structureIsReused === 0 /* Not */ && (!isEntryResolvingToAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
119856
+ return resolutionWorker(
119857
+ entries,
119851
119858
  containingFile,
119852
119859
  /*reusedNames*/
119853
119860
  void 0
119854
119861
  );
119855
119862
  }
119856
- let unknownTypeReferenceDirectiveNames;
119863
+ let unknownEntries;
119864
+ let unknownEntryIndices;
119857
119865
  let result;
119858
119866
  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) {
119867
+ const reuseResolutions = canReuseResolutionsInFile();
119868
+ for (let i = 0; i < entries.length; i++) {
119869
+ const entry = entries[i];
119870
+ if (reuseResolutions) {
119871
+ const name = nameAndModeGetter.getName(entry);
119872
+ const mode = nameAndModeGetter.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) ?? options);
119873
+ const oldResolution = getResolutionFromOldProgram(name, mode);
119874
+ const oldResolved = oldResolution && getResolved(oldResolution);
119875
+ if (oldResolved) {
119869
119876
  if (isTraceEnabled(options, host)) {
119870
119877
  trace(
119871
119878
  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)
119879
+ 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,
119880
+ name,
119881
+ containingSourceFile ? getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : containingFile,
119882
+ oldResolved.resolvedFileName,
119883
+ oldResolved.packageId && packageIdToString(oldResolved.packageId)
119877
119884
  );
119878
119885
  }
119879
- (result ?? (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
119886
+ (result ?? (result = new Array(entries.length)))[i] = oldResolution;
119880
119887
  (reusedNames ?? (reusedNames = [])).push(entry);
119881
119888
  continue;
119882
119889
  }
119883
119890
  }
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++;
119891
+ if (isEntryResolvingToAmbientModule == null ? void 0 : isEntryResolvingToAmbientModule(entry, containingFile)) {
119892
+ (result ?? (result = new Array(entries.length)))[i] = emptyResolution;
119893
+ } else {
119894
+ (unknownEntries ?? (unknownEntries = [])).push(entry);
119895
+ (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
119901
119896
  }
119902
119897
  }
119903
- Debug.assert(j === resolutions.length);
119898
+ if (!unknownEntries) return result;
119899
+ const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
119900
+ if (!result) return resolutions;
119901
+ resolutions.forEach((resolution, index) => result[unknownEntryIndices[index]] = resolution);
119904
119902
  return result;
119905
119903
  }
119906
119904
  function canReuseProjectReferences() {
@@ -124536,12 +124534,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124536
124534
  clear: clear2,
124537
124535
  onChangesAffectModuleResolution
124538
124536
  };
124539
- function getResolvedModule(resolution) {
124540
- return resolution.resolvedModule;
124541
- }
124542
- function getResolvedTypeReferenceDirective(resolution) {
124543
- return resolution.resolvedTypeReferenceDirective;
124544
- }
124545
124537
  function clear2() {
124546
124538
  clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
124547
124539
  clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
@@ -124623,7 +124615,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124623
124615
  stopWatchFailedLookupLocationOfResolution(
124624
124616
  resolution,
124625
124617
  resolutionHost.toPath(getInferredLibraryNameResolveFrom(resolutionHost.getCompilationSettings(), getCurrentDirectory(), libFileName)),
124626
- getResolvedModule
124618
+ getResolvedModuleFromResolution
124627
124619
  );
124628
124620
  resolvedLibraries.delete(libFileName);
124629
124621
  }
@@ -124803,7 +124795,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124803
124795
  getModuleResolutionHost(resolutionHost),
124804
124796
  typeReferenceDirectiveResolutionCache
124805
124797
  ),
124806
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
124798
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution,
124807
124799
  shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
124808
124800
  deferWatchingNonRelativeResolution: false
124809
124801
  });
@@ -124824,7 +124816,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124824
124816
  resolutionHost,
124825
124817
  moduleResolutionCache
124826
124818
  ),
124827
- getResolutionWithResolvedFileName: getResolvedModule,
124819
+ getResolutionWithResolvedFileName: getResolvedModuleFromResolution,
124828
124820
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
124829
124821
  logChanges: logChangesWhenResolvingModule,
124830
124822
  deferWatchingNonRelativeResolution: true
@@ -124842,17 +124834,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124842
124834
  libraryName,
124843
124835
  resolution,
124844
124836
  path,
124845
- getResolvedModule,
124837
+ getResolvedModuleFromResolution,
124846
124838
  /*deferWatchingNonRelativeResolution*/
124847
124839
  false
124848
124840
  );
124849
124841
  resolvedLibraries.set(libFileName, resolution);
124850
124842
  if (existingResolution) {
124851
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModule);
124843
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModuleFromResolution);
124852
124844
  }
124853
124845
  } else {
124854
124846
  if (isTraceEnabled(options, host)) {
124855
- const resolved = getResolvedModule(resolution);
124847
+ const resolved = getResolvedModuleFromResolution(resolution);
124856
124848
  trace(
124857
124849
  host,
124858
124850
  (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 +124883,20 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124891
124883
  return endsWith(dirPath, "/node_modules/@types");
124892
124884
  }
124893
124885
  function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution) {
124894
- var _a;
124895
- if (resolution.refCount) {
124896
- resolution.refCount++;
124897
- Debug.assertIsDefined(resolution.files);
124886
+ (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
124887
+ if (resolution.files.size !== 1) return;
124888
+ if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
124889
+ watchFailedLookupLocationOfResolution(resolution);
124898
124890
  } 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
- }
124891
+ nonRelativeExternalModuleResolutions.add(name, resolution);
124892
+ }
124893
+ const resolved = getResolutionWithResolvedFileName(resolution);
124894
+ if (resolved && resolved.resolvedFileName) {
124895
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
124896
+ let resolutions = resolvedFileToResolution.get(key);
124897
+ if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
124898
+ resolutions.add(resolution);
124913
124899
  }
124914
- (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
124915
124900
  }
124916
124901
  function watchFailedLookupLocation(failedLookupLocation, setAtRoot) {
124917
124902
  const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
@@ -124936,7 +124921,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124936
124921
  return setAtRoot;
124937
124922
  }
124938
124923
  function watchFailedLookupLocationOfResolution(resolution) {
124939
- Debug.assert(!!resolution.refCount);
124924
+ var _a;
124925
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
124940
124926
  const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
124941
124927
  if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !alternateResult) return;
124942
124928
  if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || alternateResult) resolutionsWithFailedLookups.add(resolution);
@@ -124962,7 +124948,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
124962
124948
  watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !alternateResult);
124963
124949
  }
124964
124950
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
124965
- Debug.assert(!!resolution.refCount);
124951
+ var _a;
124952
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
124966
124953
  const { affectingLocations } = resolution;
124967
124954
  if (!(affectingLocations == null ? void 0 : affectingLocations.length)) return;
124968
124955
  if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.add(resolution);
@@ -125149,10 +125136,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125149
125136
  }
125150
125137
  function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName, syncDirWatcherRemove) {
125151
125138
  Debug.checkDefined(resolution.files).delete(filePath);
125152
- resolution.refCount--;
125153
- if (resolution.refCount) {
125154
- return;
125155
- }
125139
+ if (resolution.files.size) return;
125140
+ resolution.files = void 0;
125156
125141
  const resolved = getResolutionWithResolvedFileName(resolution);
125157
125142
  if (resolved && resolved.resolvedFileName) {
125158
125143
  const key = resolutionHost.toPath(resolved.resolvedFileName);
@@ -125217,8 +125202,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
125217
125202
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
125218
125203
  }
125219
125204
  function removeResolutionsOfFile(filePath, syncDirWatcherRemove) {
125220
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule, syncDirWatcherRemove);
125221
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective, syncDirWatcherRemove);
125205
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution, syncDirWatcherRemove);
125206
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution, syncDirWatcherRemove);
125222
125207
  }
125223
125208
  function invalidateResolutions(resolutions, canInvalidate) {
125224
125209
  if (!resolutions) return false;
@@ -2659,6 +2659,18 @@ declare namespace ts {
2659
2659
  trace?(s: string): void;
2660
2660
  require?(initialPath: string, moduleName: string): ModuleImportResult;
2661
2661
  }
2662
+ interface InstallPackageOptionsWithProject extends InstallPackageOptions {
2663
+ projectName: string;
2664
+ projectRootPath: Path;
2665
+ }
2666
+ interface ITypingsInstaller {
2667
+ isKnownTypesPackageName(name: string): boolean;
2668
+ installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
2669
+ enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string> | undefined): void;
2670
+ attach(projectService: ProjectService): void;
2671
+ onProjectClosed(p: Project): void;
2672
+ readonly globalTypingsCacheLocation: string | undefined;
2673
+ }
2662
2674
  function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
2663
2675
  function toNormalizedPath(fileName: string): NormalizedPath;
2664
2676
  function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path;
@@ -2751,19 +2763,6 @@ declare namespace ts {
2751
2763
  positionToLineOffset(position: number): protocol.Location;
2752
2764
  isJavaScript(): boolean;
2753
2765
  }
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
2766
  function allRootFilesAreJsOrDts(project: Project): boolean;
2768
2767
  function allFilesAreJsOrDts(project: Project): boolean;
2769
2768
  enum ProjectKind {
@@ -2817,6 +2816,7 @@ declare namespace ts {
2817
2816
  private lastReportedVersion;
2818
2817
  protected projectErrors: Diagnostic[] | undefined;
2819
2818
  protected isInitialLoadPending: () => boolean;
2819
+ private typingsCache;
2820
2820
  private typingWatchers;
2821
2821
  private readonly cancellationToken;
2822
2822
  isNonTsProject(): boolean;
@@ -2829,7 +2829,6 @@ declare namespace ts {
2829
2829
  readonly jsDocParsingMode: JSDocParsingMode | undefined;
2830
2830
  isKnownTypesPackageName(name: string): boolean;
2831
2831
  installPackage(options: InstallPackageOptions): Promise<ApplyCodeActionCommandResult>;
2832
- private get typingsCache();
2833
2832
  getCompilationSettings(): ts.CompilerOptions;
2834
2833
  getCompilerOptions(): ts.CompilerOptions;
2835
2834
  getNewLine(): string;
@@ -3148,6 +3147,7 @@ declare namespace ts {
3148
3147
  configFileName?: NormalizedPath;
3149
3148
  configFileErrors?: readonly Diagnostic[];
3150
3149
  }
3150
+ const nullTypingsInstaller: ITypingsInstaller;
3151
3151
  interface ProjectServiceOptions {
3152
3152
  host: ServerHost;
3153
3153
  logger: Logger;