typescript 5.5.0-dev.20240520 → 5.5.0-dev.20240522

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/typescript.js CHANGED
@@ -532,6 +532,7 @@ __export(typescript_exports, {
532
532
  emitNewLineBeforeLeadingCommentOfPosition: () => emitNewLineBeforeLeadingCommentOfPosition,
533
533
  emitNewLineBeforeLeadingComments: () => emitNewLineBeforeLeadingComments,
534
534
  emitNewLineBeforeLeadingCommentsOfPosition: () => emitNewLineBeforeLeadingCommentsOfPosition,
535
+ emitResolverSkipsTypeChecking: () => emitResolverSkipsTypeChecking,
535
536
  emitSkippedWithNoDiagnostics: () => emitSkippedWithNoDiagnostics,
536
537
  emptyArray: () => emptyArray,
537
538
  emptyFileSystemEntries: () => emptyFileSystemEntries,
@@ -2368,7 +2369,7 @@ module.exports = __toCommonJS(typescript_exports);
2368
2369
 
2369
2370
  // src/compiler/corePublic.ts
2370
2371
  var versionMajorMinor = "5.5";
2371
- var version = `${versionMajorMinor}.0-dev.20240520`;
2372
+ var version = `${versionMajorMinor}.0-dev.20240522`;
2372
2373
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2373
2374
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2374
2375
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -15259,7 +15260,7 @@ function getTextOfJSDocComment(comment) {
15259
15260
  function formatJSDocLink(link) {
15260
15261
  const kind = link.kind === 324 /* JSDocLink */ ? "link" : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" : "linkplain";
15261
15262
  const name = link.name ? entityNameToString(link.name) : "";
15262
- const space = link.name && link.text.startsWith("://") ? "" : " ";
15263
+ const space = link.name && (link.text === "" || link.text.startsWith("://")) ? "" : " ";
15263
15264
  return `{@${kind} ${name}${space}${link.text}}`;
15264
15265
  }
15265
15266
  function getEffectiveTypeParameterDeclarations(node) {
@@ -48837,13 +48838,14 @@ function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importin
48837
48838
  )) || getLocalModuleSpecifier(toFileName2, info, compilerOptions, host, options.overrideImportMode || getDefaultResolutionModeForFile(importingSourceFile, host, compilerOptions), preferences);
48838
48839
  }
48839
48840
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options = {}) {
48840
- return tryGetModuleSpecifiersFromCacheWorker(
48841
+ const result = tryGetModuleSpecifiersFromCacheWorker(
48841
48842
  moduleSymbol,
48842
48843
  importingSourceFile,
48843
48844
  host,
48844
48845
  userPreferences,
48845
48846
  options
48846
- )[0];
48847
+ );
48848
+ return result[1] && { kind: result[0], moduleSpecifiers: result[1], computedWithoutCache: false };
48847
48849
  }
48848
48850
  function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile, host, userPreferences, options = {}) {
48849
48851
  var _a;
@@ -48853,7 +48855,7 @@ function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile
48853
48855
  }
48854
48856
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
48855
48857
  const cached = cache == null ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences, options);
48856
- return [cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
48858
+ return [cached == null ? void 0 : cached.kind, cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
48857
48859
  }
48858
48860
  function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) {
48859
48861
  return getModuleSpecifiersWithCacheInfo(
@@ -48871,16 +48873,16 @@ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSo
48871
48873
  function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
48872
48874
  let computedWithoutCache = false;
48873
48875
  const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
48874
- if (ambient) return { moduleSpecifiers: [ambient], computedWithoutCache };
48875
- let [specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
48876
+ if (ambient) return { kind: "ambient", moduleSpecifiers: [ambient], computedWithoutCache };
48877
+ let [kind, specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
48876
48878
  moduleSymbol,
48877
48879
  importingSourceFile,
48878
48880
  host,
48879
48881
  userPreferences,
48880
48882
  options
48881
48883
  );
48882
- if (specifiers) return { moduleSpecifiers: specifiers, computedWithoutCache };
48883
- if (!moduleSourceFile) return { moduleSpecifiers: emptyArray, computedWithoutCache };
48884
+ if (specifiers) return { kind, moduleSpecifiers: specifiers, computedWithoutCache };
48885
+ if (!moduleSourceFile) return { kind: void 0, moduleSpecifiers: emptyArray, computedWithoutCache };
48884
48886
  computedWithoutCache = true;
48885
48887
  modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host, compilerOptions, options));
48886
48888
  const result = computeModuleSpecifiers(
@@ -48892,8 +48894,8 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
48892
48894
  options,
48893
48895
  forAutoImport
48894
48896
  );
48895
- cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result);
48896
- return { moduleSpecifiers: result, computedWithoutCache };
48897
+ cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, result.kind, modulePaths, result.moduleSpecifiers);
48898
+ return result;
48897
48899
  }
48898
48900
  function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName, compilerOptions, host, options = {}) {
48899
48901
  const info = getInfo(importingFile.fileName, host);
@@ -48924,8 +48926,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
48924
48926
  }
48925
48927
  ));
48926
48928
  if (existingSpecifier) {
48927
- const moduleSpecifiers = [existingSpecifier];
48928
- return moduleSpecifiers;
48929
+ return { kind: void 0, moduleSpecifiers: [existingSpecifier], computedWithoutCache: true };
48929
48930
  }
48930
48931
  const importedFileIsInNodeModules = some(modulePaths, (p) => p.isInNodeModules);
48931
48932
  let nodeModulesSpecifiers;
@@ -48946,7 +48947,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
48946
48947
  ) : void 0;
48947
48948
  nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier);
48948
48949
  if (specifier && modulePath.isRedirect) {
48949
- return nodeModulesSpecifiers;
48950
+ return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
48950
48951
  }
48951
48952
  if (!specifier) {
48952
48953
  const local = getLocalModuleSpecifier(
@@ -48975,7 +48976,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
48975
48976
  }
48976
48977
  }
48977
48978
  }
48978
- return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? redirectPathsSpecifiers : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : Debug.checkDefined(relativeSpecifiers);
48979
+ return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? { kind: "paths", moduleSpecifiers: pathsSpecifiers, computedWithoutCache: true } : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? { kind: "redirect", moduleSpecifiers: redirectPathsSpecifiers, computedWithoutCache: true } : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true } : { kind: "relative", moduleSpecifiers: Debug.checkDefined(relativeSpecifiers), computedWithoutCache: true };
48979
48980
  }
48980
48981
  function getInfo(importingSourceFileName, host) {
48981
48982
  importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
@@ -50885,8 +50886,8 @@ function createTypeChecker(host) {
50885
50886
  void 0
50886
50887
  );
50887
50888
  }
50888
- function getEmitResolver(sourceFile, cancellationToken2) {
50889
- getDiagnostics2(sourceFile, cancellationToken2);
50889
+ function getEmitResolver(sourceFile, cancellationToken2, skipDiagnostics) {
50890
+ if (!skipDiagnostics) getDiagnostics2(sourceFile, cancellationToken2);
50890
50891
  return emitResolver;
50891
50892
  }
50892
50893
  function lookupOrIssueError(location, message, ...args) {
@@ -53814,8 +53815,15 @@ function createTypeChecker(host) {
53814
53815
  ).accessibility === 0 /* Accessible */) {
53815
53816
  return { accessibility: 0 /* Accessible */ };
53816
53817
  }
53817
- return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
53818
- accessibility: 3 /* NotResolved */,
53818
+ if (!symbol) {
53819
+ return {
53820
+ accessibility: 3 /* NotResolved */,
53821
+ errorSymbolName: getTextOfNode(firstIdentifier),
53822
+ errorNode: firstIdentifier
53823
+ };
53824
+ }
53825
+ return hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
53826
+ accessibility: 1 /* NotAccessible */,
53819
53827
  errorSymbolName: getTextOfNode(firstIdentifier),
53820
53828
  errorNode: firstIdentifier
53821
53829
  };
@@ -117448,6 +117456,9 @@ function getFirstProjectOutput(configFile, ignoreCase) {
117448
117456
  if (buildInfoPath) return buildInfoPath;
117449
117457
  return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`);
117450
117458
  }
117459
+ function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
117460
+ return !!forceDtsEmit && !!emitOnly;
117461
+ }
117451
117462
  function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
117452
117463
  var compilerOptions = host.getCompilerOptions();
117453
117464
  var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
@@ -117565,7 +117576,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
117565
117576
  const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
117566
117577
  const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson);
117567
117578
  const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit;
117568
- if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck) {
117579
+ if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck || emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)) {
117569
117580
  filesForEmit.forEach(collectLinkedAliases);
117570
117581
  }
117571
117582
  const declarationTransform = transformNodes(
@@ -124547,17 +124558,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
124547
124558
  const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
124548
124559
  if (result) return result;
124549
124560
  }
124550
- const emitResolver = getTypeChecker().getEmitResolver(options.outFile ? void 0 : sourceFile, cancellationToken);
124561
+ const typeChecker2 = getTypeChecker();
124562
+ const emitResolver = typeChecker2.getEmitResolver(
124563
+ options.outFile ? void 0 : sourceFile,
124564
+ cancellationToken,
124565
+ emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)
124566
+ );
124551
124567
  mark("beforeEmit");
124552
- const emitResult = emitFiles(
124553
- emitResolver,
124554
- getEmitHost(writeFileCallback),
124555
- sourceFile,
124556
- getTransformers(options, customTransformers, emitOnly),
124557
- emitOnly,
124558
- /*onlyBuildInfo*/
124559
- false,
124560
- forceDtsEmit
124568
+ const emitResult = typeChecker2.runWithCancellationToken(
124569
+ cancellationToken,
124570
+ () => emitFiles(
124571
+ emitResolver,
124572
+ getEmitHost(writeFileCallback),
124573
+ sourceFile,
124574
+ getTransformers(options, customTransformers, emitOnly),
124575
+ emitOnly,
124576
+ /*onlyBuildInfo*/
124577
+ false,
124578
+ forceDtsEmit
124579
+ )
124561
124580
  );
124562
124581
  mark("afterEmit");
124563
124582
  measure("Emit", "beforeEmit", "afterEmit");
@@ -125297,7 +125316,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
125297
125316
  return file2 || void 0;
125298
125317
  }
125299
125318
  let redirectedPath;
125300
- if (isReferencedFile(reason) && !useSourceOfProjectReferenceRedirect) {
125319
+ if (!useSourceOfProjectReferenceRedirect) {
125301
125320
  const redirectProject = getProjectReferenceRedirectProject(fileName);
125302
125321
  if (redirectProject) {
125303
125322
  if (redirectProject.commandLine.options.outFile) {
@@ -127534,7 +127553,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
127534
127553
  host
127535
127554
  );
127536
127555
  }
127537
- function handleDtsMayChangeOf(state, path, cancellationToken, host) {
127556
+ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
127538
127557
  removeSemanticDiagnosticsOf(state, path);
127539
127558
  if (!state.changedFilesSet.has(path)) {
127540
127559
  const program = Debug.checkDefined(state.program);
@@ -127549,7 +127568,9 @@ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
127549
127568
  /*useFileVersionAsSignature*/
127550
127569
  true
127551
127570
  );
127552
- if (getEmitDeclarations(state.compilerOptions)) {
127571
+ if (invalidateJsFiles) {
127572
+ addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
127573
+ } else if (getEmitDeclarations(state.compilerOptions)) {
127553
127574
  addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
127554
127575
  }
127555
127576
  }
@@ -127568,7 +127589,7 @@ function isChangedSignature(state, path) {
127568
127589
  const newSignature = Debug.checkDefined(state.fileInfos.get(path)).signature;
127569
127590
  return newSignature !== oldSignature;
127570
127591
  }
127571
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
127592
+ function handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host) {
127572
127593
  var _a;
127573
127594
  if (!((_a = state.fileInfos.get(filePath)) == null ? void 0 : _a.affectsGlobalScope)) return false;
127574
127595
  BuilderState.getAllFilesExcludingDefaultLibraryFile(
@@ -127580,6 +127601,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
127580
127601
  (file) => handleDtsMayChangeOf(
127581
127602
  state,
127582
127603
  file.resolvedPath,
127604
+ invalidateJsFiles,
127583
127605
  cancellationToken,
127584
127606
  host
127585
127607
  )
@@ -127588,7 +127610,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
127588
127610
  return true;
127589
127611
  }
127590
127612
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
127591
- var _a;
127613
+ var _a, _b;
127592
127614
  if (!state.referencedMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return;
127593
127615
  if (!isChangedSignature(state, affectedFile.resolvedPath)) return;
127594
127616
  if (getIsolatedModules(state.compilerOptions)) {
@@ -127599,8 +127621,22 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
127599
127621
  const currentPath = queue.pop();
127600
127622
  if (!seenFileNamesMap.has(currentPath)) {
127601
127623
  seenFileNamesMap.set(currentPath, true);
127602
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host)) return;
127603
- handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
127624
+ if (handleDtsMayChangeOfGlobalScope(
127625
+ state,
127626
+ currentPath,
127627
+ /*invalidateJsFiles*/
127628
+ false,
127629
+ cancellationToken,
127630
+ host
127631
+ )) return;
127632
+ handleDtsMayChangeOf(
127633
+ state,
127634
+ currentPath,
127635
+ /*invalidateJsFiles*/
127636
+ false,
127637
+ cancellationToken,
127638
+ host
127639
+ );
127604
127640
  if (isChangedSignature(state, currentPath)) {
127605
127641
  const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
127606
127642
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -127609,27 +127645,38 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
127609
127645
  }
127610
127646
  }
127611
127647
  const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
127612
- (_a = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a.forEach((exportedFromPath) => {
127613
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host)) return true;
127648
+ const invalidateJsFiles = !!((_a = affectedFile.symbol) == null ? void 0 : _a.exports) && !!forEachEntry(
127649
+ affectedFile.symbol.exports,
127650
+ (exported) => {
127651
+ if ((exported.flags & 128 /* ConstEnum */) !== 0) return true;
127652
+ const aliased = skipAlias(exported, state.program.getTypeChecker());
127653
+ if (aliased === exported) return false;
127654
+ return (aliased.flags & 128 /* ConstEnum */) !== 0 && some(aliased.declarations, (d) => getSourceFileOfNode(d) === affectedFile);
127655
+ }
127656
+ );
127657
+ (_b = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _b.forEach((exportedFromPath) => {
127658
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, invalidateJsFiles, cancellationToken, host)) return true;
127614
127659
  const references = state.referencedMap.getKeys(exportedFromPath);
127615
127660
  return references && forEachKey(references, (filePath) => handleDtsMayChangeOfFileAndExportsOfFile(
127616
127661
  state,
127617
127662
  filePath,
127663
+ invalidateJsFiles,
127618
127664
  seenFileAndExportsOfFile,
127619
127665
  cancellationToken,
127620
127666
  host
127621
127667
  ));
127622
127668
  });
127623
127669
  }
127624
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
127670
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsFiles, seenFileAndExportsOfFile, cancellationToken, host) {
127625
127671
  var _a;
127626
127672
  if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) return void 0;
127627
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host)) return true;
127628
- handleDtsMayChangeOf(state, filePath, cancellationToken, host);
127673
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host)) return true;
127674
+ handleDtsMayChangeOf(state, filePath, invalidateJsFiles, cancellationToken, host);
127629
127675
  (_a = state.referencedMap.getKeys(filePath)) == null ? void 0 : _a.forEach(
127630
127676
  (referencingFilePath) => handleDtsMayChangeOfFileAndExportsOfFile(
127631
127677
  state,
127632
127678
  referencingFilePath,
127679
+ invalidateJsFiles,
127633
127680
  seenFileAndExportsOfFile,
127634
127681
  cancellationToken,
127635
127682
  host
@@ -127668,6 +127715,7 @@ function getBuildInfo2(state) {
127668
127715
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
127669
127716
  const fileNames = [];
127670
127717
  const fileNameToFileId = /* @__PURE__ */ new Map();
127718
+ const rootFileNames = new Set(state.program.getRootFileNames().map((f) => toPath(f, currentDirectory, state.program.getCanonicalFileName)));
127671
127719
  const root = [];
127672
127720
  if (state.compilerOptions.outFile) {
127673
127721
  const fileInfos2 = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
@@ -127679,6 +127727,7 @@ function getBuildInfo2(state) {
127679
127727
  fileNames,
127680
127728
  fileInfos: fileInfos2,
127681
127729
  root,
127730
+ resolvedRoot: toResolvedRoot(),
127682
127731
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
127683
127732
  outSignature: state.outSignature,
127684
127733
  latestChangedDtsFile,
@@ -127708,7 +127757,8 @@ function getBuildInfo2(state) {
127708
127757
  if (!isJsonSourceFile(file) && sourceFileMayBeEmitted(file, state.program)) {
127709
127758
  const emitSignature = (_b = state.emitSignatures) == null ? void 0 : _b.get(key);
127710
127759
  if (emitSignature !== actualSignature) {
127711
- (emitSignatures || (emitSignatures = [])).push(
127760
+ emitSignatures = append(
127761
+ emitSignatures,
127712
127762
  emitSignature === void 0 ? fileId : (
127713
127763
  // There is no emit, encode as false
127714
127764
  // fileId, signature: emptyArray if signature only differs in dtsMap option than our own compilerOptions otherwise EmitSignature
@@ -127755,7 +127805,8 @@ function getBuildInfo2(state) {
127755
127805
  const file = state.program.getSourceFileByPath(path);
127756
127806
  if (!file || !sourceFileMayBeEmitted(file, state.program)) continue;
127757
127807
  const fileId = toFileId(path), pendingEmit = state.affectedFilesPendingEmit.get(path);
127758
- (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push(
127808
+ affectedFilesPendingEmit = append(
127809
+ affectedFilesPendingEmit,
127759
127810
  pendingEmit === fullEmitForOptions ? fileId : (
127760
127811
  // Pending full emit per options
127761
127812
  pendingEmit === 8 /* Dts */ ? [fileId] : (
@@ -127771,7 +127822,7 @@ function getBuildInfo2(state) {
127771
127822
  let changeFileSet;
127772
127823
  if (state.changedFilesSet.size) {
127773
127824
  for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
127774
- (changeFileSet || (changeFileSet = [])).push(toFileId(path));
127825
+ changeFileSet = append(changeFileSet, toFileId(path));
127775
127826
  }
127776
127827
  }
127777
127828
  const emitDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.emitDiagnosticsPerFile);
@@ -127779,6 +127830,7 @@ function getBuildInfo2(state) {
127779
127830
  fileNames,
127780
127831
  fileInfos,
127781
127832
  root,
127833
+ resolvedRoot: toResolvedRoot(),
127782
127834
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
127783
127835
  fileIdsList,
127784
127836
  referencedMap,
@@ -127809,8 +127861,8 @@ function getBuildInfo2(state) {
127809
127861
  const key = fileIds.join();
127810
127862
  let fileIdListId = fileNamesToFileIdListId == null ? void 0 : fileNamesToFileIdListId.get(key);
127811
127863
  if (fileIdListId === void 0) {
127812
- (fileIdsList || (fileIdsList = [])).push(fileIds);
127813
- (fileNamesToFileIdListId || (fileNamesToFileIdListId = /* @__PURE__ */ new Map())).set(key, fileIdListId = fileIdsList.length);
127864
+ fileIdsList = append(fileIdsList, fileIds);
127865
+ (fileNamesToFileIdListId ?? (fileNamesToFileIdListId = /* @__PURE__ */ new Map())).set(key, fileIdListId = fileIdsList.length);
127814
127866
  }
127815
127867
  return fileIdListId;
127816
127868
  }
@@ -127827,6 +127879,16 @@ function getBuildInfo2(state) {
127827
127879
  root[root.length - 2] = [lastButOne, fileId];
127828
127880
  return root.length = root.length - 1;
127829
127881
  }
127882
+ function toResolvedRoot() {
127883
+ let result;
127884
+ rootFileNames.forEach((path) => {
127885
+ const file = state.program.getSourceFileByPath(path);
127886
+ if (file && path !== file.resolvedPath) {
127887
+ result = append(result, [toFileId(file.resolvedPath), toFileId(path)]);
127888
+ }
127889
+ });
127890
+ return result;
127891
+ }
127830
127892
  function convertToProgramBuildInfoCompilerOptions(options) {
127831
127893
  let result;
127832
127894
  const { optionsNameMap } = getOptionsNameMap();
@@ -127860,7 +127922,8 @@ function getBuildInfo2(state) {
127860
127922
  if (diagnostics) {
127861
127923
  for (const key of arrayFrom(diagnostics.keys()).sort(compareStringsCaseSensitive)) {
127862
127924
  const value = diagnostics.get(key);
127863
- (result || (result = [])).push(
127925
+ result = append(
127926
+ result,
127864
127927
  value.length ? [
127865
127928
  toFileId(key),
127866
127929
  convertToReusableDiagnostics(value)
@@ -128354,7 +128417,8 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
128354
128417
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
128355
128418
  const fileInfos = /* @__PURE__ */ new Map();
128356
128419
  let rootIndex = 0;
128357
- const roots = [];
128420
+ const roots = /* @__PURE__ */ new Map();
128421
+ const resolvedRoots = new Map(program.resolvedRoot);
128358
128422
  program.fileInfos.forEach((fileInfo, index) => {
128359
128423
  const path = toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
128360
128424
  const version2 = isString(fileInfo) ? fileInfo : fileInfo.version;
@@ -128364,16 +128428,24 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
128364
128428
  const fileId = index + 1;
128365
128429
  if (isArray(current)) {
128366
128430
  if (current[0] <= fileId && fileId <= current[1]) {
128367
- roots.push(path);
128431
+ addRoot(fileId, path);
128368
128432
  if (current[1] === fileId) rootIndex++;
128369
128433
  }
128370
128434
  } else if (current === fileId) {
128371
- roots.push(path);
128435
+ addRoot(fileId, path);
128372
128436
  rootIndex++;
128373
128437
  }
128374
128438
  }
128375
128439
  });
128376
128440
  return { fileInfos, roots };
128441
+ function addRoot(fileId, path) {
128442
+ const root = resolvedRoots.get(fileId);
128443
+ if (root) {
128444
+ roots.set(toPath(program.fileNames[root - 1], buildInfoDirectory, getCanonicalFileName), path);
128445
+ } else {
128446
+ roots.set(path, void 0);
128447
+ }
128448
+ }
128377
128449
  }
128378
128450
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
128379
128451
  return {
@@ -132029,13 +132101,15 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
132029
132101
  reason: `${inputFile} does not exist`
132030
132102
  };
132031
132103
  }
132104
+ const inputPath = buildInfoProgram ? toPath2(state, inputFile) : void 0;
132032
132105
  if (buildInfoTime && buildInfoTime < inputTime) {
132033
132106
  let version2;
132034
132107
  let currentVersion;
132035
132108
  if (buildInfoProgram) {
132036
132109
  if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
132037
- version2 = buildInfoVersionMap.fileInfos.get(toPath2(state, inputFile));
132038
- const text = version2 ? state.readFileWithCache(inputFile) : void 0;
132110
+ const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath);
132111
+ version2 = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath);
132112
+ const text = version2 ? state.readFileWithCache(resolvedInputPath ?? inputFile) : void 0;
132039
132113
  currentVersion = text !== void 0 ? getSourceFileVersionAsHashFromText(host, text) : void 0;
132040
132114
  if (version2 && version2 === currentVersion) pseudoInputUpToDate = true;
132041
132115
  }
@@ -132051,18 +132125,21 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
132051
132125
  newestInputFileName = inputFile;
132052
132126
  newestInputFileTime = inputTime;
132053
132127
  }
132054
- if (buildInfoProgram) seenRoots.add(toPath2(state, inputFile));
132128
+ if (buildInfoProgram) seenRoots.add(inputPath);
132055
132129
  }
132056
132130
  if (buildInfoProgram) {
132057
132131
  if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
132058
- for (const existingRoot of buildInfoVersionMap.roots) {
132059
- if (!seenRoots.has(existingRoot)) {
132060
- return {
132061
- type: 9 /* OutOfDateRoots */,
132062
- buildInfoFile: buildInfoPath,
132063
- inputFile: existingRoot
132064
- };
132065
- }
132132
+ const existingRoot = forEachEntry(
132133
+ buildInfoVersionMap.roots,
132134
+ // File was root file when project was built but its not any more
132135
+ (_resolved, existingRoot2) => !seenRoots.has(existingRoot2) ? existingRoot2 : void 0
132136
+ );
132137
+ if (existingRoot) {
132138
+ return {
132139
+ type: 9 /* OutOfDateRoots */,
132140
+ buildInfoFile: buildInfoPath,
132141
+ inputFile: existingRoot
132142
+ };
132066
132143
  }
132067
132144
  }
132068
132145
  if (!buildInfoPath) {
@@ -153690,6 +153767,7 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
153690
153767
  );
153691
153768
  const fix = {
153692
153769
  kind: 3 /* AddNew */,
153770
+ moduleSpecifierKind: "relative",
153693
153771
  moduleSpecifier,
153694
153772
  importKind,
153695
153773
  addAsTypeOnly,
@@ -154032,7 +154110,7 @@ function createImportSpecifierResolver(importingFile, program, host, preferences
154032
154110
  importMap,
154033
154111
  fromCacheOnly
154034
154112
  );
154035
- const result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host);
154113
+ const result = getBestFix(fixes, importingFile, program, packageJsonImportFilter, host, preferences);
154036
154114
  return result && { ...result, computedWithoutCacheCount };
154037
154115
  }
154038
154116
  }
@@ -154079,7 +154157,7 @@ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, ho
154079
154157
  }
154080
154158
  function getImportFixForSymbol(sourceFile, exportInfos, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
154081
154159
  const packageJsonImportFilter = createPackageJsonImportFilter(sourceFile, preferences, host);
154082
- return getBestFix(getImportFixes(exportInfos, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host);
154160
+ return getBestFix(getImportFixes(exportInfos, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host, preferences);
154083
154161
  }
154084
154162
  function codeFixActionToCodeAction({ description: description3, changes, commands }) {
154085
154163
  return { description: description3, changes, commands };
@@ -154154,7 +154232,7 @@ function tryUseExistingNamespaceImport(existingImports, position) {
154154
154232
  const namespacePrefix = getNamespaceLikeImportText(declaration);
154155
154233
  const moduleSpecifier = namespacePrefix && ((_a = tryGetModuleSpecifierFromDeclaration(declaration)) == null ? void 0 : _a.text);
154156
154234
  if (moduleSpecifier) {
154157
- return { kind: 0 /* UseNamespace */, namespacePrefix, usagePosition: position, moduleSpecifier };
154235
+ return { kind: 0 /* UseNamespace */, namespacePrefix, usagePosition: position, moduleSpecifierKind: void 0, moduleSpecifier };
154158
154236
  }
154159
154237
  });
154160
154238
  }
@@ -154198,7 +154276,7 @@ function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker
154198
154276
  return void 0;
154199
154277
  }
154200
154278
  if (declaration.kind === 260 /* VariableDeclaration */) {
154201
- return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 206 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } : void 0;
154279
+ return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 206 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind, moduleSpecifierKind: void 0, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } : void 0;
154202
154280
  }
154203
154281
  const { importClause } = declaration;
154204
154282
  if (!importClause || !isStringLiteralLike(declaration.moduleSpecifier)) {
@@ -154228,6 +154306,7 @@ function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker
154228
154306
  kind: 2 /* AddToExisting */,
154229
154307
  importClauseOrBindingPattern: importClause,
154230
154308
  importKind,
154309
+ moduleSpecifierKind: void 0,
154231
154310
  moduleSpecifier: declaration.moduleSpecifier.text,
154232
154311
  addAsTypeOnly
154233
154312
  };
@@ -154289,7 +154368,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
154289
154368
  const getChecker = createGetChecker(program, host);
154290
154369
  const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
154291
154370
  const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution);
154292
- const getModuleSpecifiers2 = fromCacheOnly ? (exportInfo2) => ({ moduleSpecifiers: ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(exportInfo2.moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (exportInfo2, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
154371
+ const getModuleSpecifiers2 = fromCacheOnly ? (exportInfo2) => ts_moduleSpecifiers_exports.tryGetModuleSpecifiersFromCache(exportInfo2.moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences) : (exportInfo2, checker) => ts_moduleSpecifiers_exports.getModuleSpecifiersWithCacheInfo(
154293
154372
  exportInfo2.moduleSymbol,
154294
154373
  checker,
154295
154374
  compilerOptions,
@@ -154304,7 +154383,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
154304
154383
  let computedWithoutCacheCount = 0;
154305
154384
  const fixes = flatMap(exportInfo, (exportInfo2, i) => {
154306
154385
  const checker = getChecker(exportInfo2.isFromPackageJson);
154307
- const { computedWithoutCache, moduleSpecifiers } = getModuleSpecifiers2(exportInfo2, checker);
154386
+ const { computedWithoutCache, moduleSpecifiers, kind: moduleSpecifierKind } = getModuleSpecifiers2(exportInfo2, checker) ?? {};
154308
154387
  const importedSymbolHasValueMeaning = !!(exportInfo2.targetFlags & 111551 /* Value */);
154309
154388
  const addAsTypeOnly = getAddAsTypeOnly(
154310
154389
  isValidTypeOnlyUseSite,
@@ -154321,7 +154400,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
154321
154400
  return void 0;
154322
154401
  }
154323
154402
  if (!importedSymbolHasValueMeaning && isJs && usagePosition !== void 0) {
154324
- return { kind: 1 /* JsdocTypeImport */, moduleSpecifier, usagePosition, exportInfo: exportInfo2, isReExport: i > 0 };
154403
+ return { kind: 1 /* JsdocTypeImport */, moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo: exportInfo2, isReExport: i > 0 };
154325
154404
  }
154326
154405
  const importKind = getImportKind(sourceFile, exportInfo2.exportKind, program);
154327
154406
  let qualification;
@@ -154348,6 +154427,7 @@ function getNewImportFixes(program, sourceFile, usagePosition, isValidTypeOnlyUs
154348
154427
  }
154349
154428
  return {
154350
154429
  kind: 3 /* AddNew */,
154430
+ moduleSpecifierKind,
154351
154431
  moduleSpecifier,
154352
154432
  importKind,
154353
154433
  useRequire,
@@ -154377,7 +154457,7 @@ function newImportInfoFromExistingSpecifier({ declaration, importKind, symbol, t
154377
154457
  checker,
154378
154458
  compilerOptions
154379
154459
  );
154380
- return { kind: 3 /* AddNew */, moduleSpecifier, importKind, addAsTypeOnly, useRequire };
154460
+ return { kind: 3 /* AddNew */, moduleSpecifierKind: void 0, moduleSpecifier, importKind, addAsTypeOnly, useRequire };
154381
154461
  }
154382
154462
  }
154383
154463
  function getFixInfos(context, errorCode, pos, useAutoImportProvider) {
@@ -154395,18 +154475,18 @@ function getFixInfos(context, errorCode, pos, useAutoImportProvider) {
154395
154475
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
154396
154476
  }
154397
154477
  const packageJsonImportFilter = createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
154398
- return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
154478
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host, context.preferences);
154399
154479
  }
154400
- function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host) {
154480
+ function sortFixInfo(fixes, sourceFile, program, packageJsonImportFilter, host, preferences) {
154401
154481
  const _toPath = (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
154402
- return sort(fixes, (a, b) => compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) || compareValues(a.fix.kind, b.fix.kind) || compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, _toPath));
154482
+ return sort(fixes, (a, b) => compareBooleans(!!a.isJsxNamespaceFix, !!b.isJsxNamespaceFix) || compareValues(a.fix.kind, b.fix.kind) || compareModuleSpecifiers(a.fix, b.fix, sourceFile, program, preferences, packageJsonImportFilter.allowsImportingSpecifier, _toPath));
154403
154483
  }
154404
154484
  function getFixInfosWithoutDiagnostic(context, symbolToken, useAutoImportProvider) {
154405
154485
  const info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
154406
154486
  const packageJsonImportFilter = createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
154407
- return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host);
154487
+ return info && sortFixInfo(info, context.sourceFile, context.program, packageJsonImportFilter, context.host, context.preferences);
154408
154488
  }
154409
- function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
154489
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host, preferences) {
154410
154490
  if (!some(fixes)) return;
154411
154491
  if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
154412
154492
  return fixes[0];
@@ -154419,21 +154499,31 @@ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter, host) {
154419
154499
  best,
154420
154500
  sourceFile,
154421
154501
  program,
154502
+ preferences,
154422
154503
  packageJsonImportFilter.allowsImportingSpecifier,
154423
154504
  (fileName) => toPath(fileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host))
154424
154505
  ) === -1 /* LessThan */ ? fix : best
154425
154506
  )
154426
154507
  );
154427
154508
  }
154428
- function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath3) {
154509
+ function compareModuleSpecifiers(a, b, importingFile, program, preferences, allowsImportingSpecifier, toPath3) {
154429
154510
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
154430
- return compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || compareBooleans(
154511
+ return compareBooleans(
154512
+ b.moduleSpecifierKind !== "node_modules" || allowsImportingSpecifier(b.moduleSpecifier),
154513
+ a.moduleSpecifierKind !== "node_modules" || allowsImportingSpecifier(a.moduleSpecifier)
154514
+ ) || compareModuleSpecifierRelativity(a, b, preferences) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || compareBooleans(
154431
154515
  isFixPossiblyReExportingImportingFile(a, importingFile.path, toPath3),
154432
154516
  isFixPossiblyReExportingImportingFile(b, importingFile.path, toPath3)
154433
154517
  ) || compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
154434
154518
  }
154435
154519
  return 0 /* EqualTo */;
154436
154520
  }
154521
+ function compareModuleSpecifierRelativity(a, b, preferences) {
154522
+ if (preferences.importModuleSpecifierPreference === "non-relative" || preferences.importModuleSpecifierPreference === "project-relative") {
154523
+ return compareBooleans(a.moduleSpecifierKind === "relative", b.moduleSpecifierKind === "relative");
154524
+ }
154525
+ return 0 /* EqualTo */;
154526
+ }
154437
154527
  function isFixPossiblyReExportingImportingFile(fix, importingFilePath, toPath3) {
154438
154528
  var _a;
154439
154529
  if (fix.isReExport && ((_a = fix.exportInfo) == null ? void 0 : _a.moduleFileName) && isIndexFileName(fix.exportInfo.moduleFileName)) {
@@ -177341,13 +177431,6 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
177341
177431
  if (pastedText.length !== pasteLocations.length) {
177342
177432
  actualPastedText = pastedText.length === 1 ? pastedText : [pastedText.join("\n")];
177343
177433
  }
177344
- pasteLocations.forEach((paste, i) => {
177345
- changes.replaceRangeWithText(
177346
- targetFile,
177347
- { pos: paste.pos, end: paste.end },
177348
- actualPastedText ? actualPastedText[0] : pastedText[i]
177349
- );
177350
- });
177351
177434
  const statements = [];
177352
177435
  let newText = targetFile.text;
177353
177436
  for (let i = pasteLocations.length - 1; i >= 0; i--) {
@@ -177395,6 +177478,13 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
177395
177478
  }
177396
177479
  importAdder.writeFixes(changes, getQuotePreference(copiedFrom ? copiedFrom.file : targetFile, preferences));
177397
177480
  });
177481
+ pasteLocations.forEach((paste, i) => {
177482
+ changes.replaceRangeWithText(
177483
+ targetFile,
177484
+ { pos: paste.pos, end: paste.end },
177485
+ actualPastedText ? actualPastedText[0] : pastedText[i]
177486
+ );
177487
+ });
177398
177488
  }
177399
177489
 
177400
177490
  // src/server/_namespaces/ts.ts
@@ -177896,6 +177986,7 @@ __export(ts_exports2, {
177896
177986
  emitNewLineBeforeLeadingCommentOfPosition: () => emitNewLineBeforeLeadingCommentOfPosition,
177897
177987
  emitNewLineBeforeLeadingComments: () => emitNewLineBeforeLeadingComments,
177898
177988
  emitNewLineBeforeLeadingCommentsOfPosition: () => emitNewLineBeforeLeadingCommentsOfPosition,
177989
+ emitResolverSkipsTypeChecking: () => emitResolverSkipsTypeChecking,
177899
177990
  emitSkippedWithNoDiagnostics: () => emitSkippedWithNoDiagnostics,
177900
177991
  emptyArray: () => emptyArray,
177901
177992
  emptyFileSystemEntries: () => emptyFileSystemEntries,
@@ -181408,7 +181499,6 @@ var Project3 = class _Project {
181408
181499
  this.compilerOptions = compilerOptions;
181409
181500
  this.compileOnSaveEnabled = compileOnSaveEnabled;
181410
181501
  this.watchOptions = watchOptions;
181411
- this.rootFiles = [];
181412
181502
  this.rootFilesMap = /* @__PURE__ */ new Map();
181413
181503
  /** @internal */
181414
181504
  this.plugins = [];
@@ -181610,7 +181700,7 @@ var Project3 = class _Project {
181610
181700
  return void 0;
181611
181701
  }
181612
181702
  getScriptFileNames() {
181613
- if (!this.rootFiles) {
181703
+ if (!this.rootFilesMap.size) {
181614
181704
  return emptyArray;
181615
181705
  }
181616
181706
  let result;
@@ -181632,7 +181722,6 @@ var Project3 = class _Project {
181632
181722
  if (scriptInfo) {
181633
181723
  const existingValue = this.rootFilesMap.get(scriptInfo.path);
181634
181724
  if (existingValue && existingValue.info !== scriptInfo) {
181635
- this.rootFiles.push(scriptInfo);
181636
181725
  existingValue.info = scriptInfo;
181637
181726
  }
181638
181727
  scriptInfo.attachToProject(this);
@@ -181985,11 +182074,11 @@ var Project3 = class _Project {
181985
182074
  this.closeWatchingTypingLocations();
181986
182075
  this.cleanupProgram();
181987
182076
  forEach(this.externalFiles, (externalFile) => this.detachScriptInfoIfNotRoot(externalFile));
181988
- for (const root of this.rootFiles) {
181989
- root.detachFromProject(this);
181990
- }
182077
+ this.rootFilesMap.forEach((root) => {
182078
+ var _a2;
182079
+ return (_a2 = root.info) == null ? void 0 : _a2.detachFromProject(this);
182080
+ });
181991
182081
  this.projectService.pendingEnsureProjectForOpenFiles = true;
181992
- this.rootFiles = void 0;
181993
182082
  this.rootFilesMap = void 0;
181994
182083
  this.externalFiles = void 0;
181995
182084
  this.program = void 0;
@@ -182032,28 +182121,32 @@ var Project3 = class _Project {
182032
182121
  }
182033
182122
  }
182034
182123
  isClosed() {
182035
- return this.rootFiles === void 0;
182124
+ return this.rootFilesMap === void 0;
182036
182125
  }
182037
182126
  hasRoots() {
182038
- return this.rootFiles && this.rootFiles.length > 0;
182127
+ var _a;
182128
+ return !!((_a = this.rootFilesMap) == null ? void 0 : _a.size);
182039
182129
  }
182040
182130
  /** @internal */
182041
182131
  isOrphan() {
182042
182132
  return false;
182043
182133
  }
182044
182134
  getRootFiles() {
182045
- return this.rootFiles && this.rootFiles.map((info) => info.fileName);
182135
+ return this.rootFilesMap && arrayFrom(mapDefinedIterator(this.rootFilesMap.values(), (value) => {
182136
+ var _a;
182137
+ return (_a = value.info) == null ? void 0 : _a.fileName;
182138
+ }));
182046
182139
  }
182047
182140
  /** @internal */
182048
182141
  getRootFilesMap() {
182049
182142
  return this.rootFilesMap;
182050
182143
  }
182051
182144
  getRootScriptInfos() {
182052
- return this.rootFiles;
182145
+ return arrayFrom(mapDefinedIterator(this.rootFilesMap.values(), (value) => value.info));
182053
182146
  }
182054
182147
  getScriptInfos() {
182055
182148
  if (!this.languageServiceEnabled) {
182056
- return this.rootFiles;
182149
+ return this.getRootScriptInfos();
182057
182150
  }
182058
182151
  return map(this.program.getSourceFiles(), (sourceFile) => {
182059
182152
  const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.resolvedPath);
@@ -182137,13 +182230,12 @@ var Project3 = class _Project {
182137
182230
  return false;
182138
182231
  }
182139
182232
  isRoot(info) {
182140
- var _a;
182141
- return this.rootFilesMap && ((_a = this.rootFilesMap.get(info.path)) == null ? void 0 : _a.info) === info;
182233
+ var _a, _b;
182234
+ return ((_b = (_a = this.rootFilesMap) == null ? void 0 : _a.get(info.path)) == null ? void 0 : _b.info) === info;
182142
182235
  }
182143
182236
  // add a root file to project
182144
182237
  addRoot(info, fileName) {
182145
182238
  Debug.assert(!this.isRoot(info));
182146
- this.rootFiles.push(info);
182147
182239
  this.rootFilesMap.set(info.path, { fileName: fileName || info.fileName, info });
182148
182240
  info.attachToProject(this);
182149
182241
  this.markAsDirty();
@@ -182409,6 +182501,15 @@ var Project3 = class _Project {
182409
182501
  }
182410
182502
  });
182411
182503
  }
182504
+ this.rootFilesMap.forEach((value, path) => {
182505
+ var _a2;
182506
+ const file = this.program.getSourceFileByPath(path);
182507
+ const info = value.info;
182508
+ if (!file || ((_a2 = value.info) == null ? void 0 : _a2.path) === file.resolvedPath) return;
182509
+ value.info = this.projectService.getScriptInfo(file.fileName);
182510
+ Debug.assert(value.info.isAttached(this));
182511
+ info == null ? void 0 : info.detachFromProject(this);
182512
+ });
182412
182513
  updateMissingFilePathsWatch(
182413
182514
  this.program,
182414
182515
  this.missingFilesMap || (this.missingFilesMap = /* @__PURE__ */ new Map()),
@@ -182801,7 +182902,6 @@ var Project3 = class _Project {
182801
182902
  }
182802
182903
  // remove a root file from project
182803
182904
  removeRoot(info) {
182804
- orderedRemoveItem(this.rootFiles, info);
182805
182905
  this.rootFilesMap.delete(info.path);
182806
182906
  }
182807
182907
  /** @internal */
@@ -182993,14 +183093,14 @@ var Project3 = class _Project {
182993
183093
  }
182994
183094
  /** @internal */
182995
183095
  runWithTemporaryFileUpdate(rootFile, updatedText, cb) {
182996
- var _a, _b, _c, _d, _e;
183096
+ var _a, _b, _c, _d;
182997
183097
  const originalProgram = this.program;
182998
- const originalText = (_b = (_a = this.program) == null ? void 0 : _a.getSourceFile(rootFile)) == null ? void 0 : _b.getText();
182999
- Debug.assert(this.program && this.program.getSourceFile(rootFile) && originalText);
183000
- (_c = this.getScriptInfo(rootFile)) == null ? void 0 : _c.editContent(0, this.program.getSourceFile(rootFile).getText().length, updatedText);
183098
+ const rootSourceFile = Debug.checkDefined((_a = this.program) == null ? void 0 : _a.getSourceFile(rootFile), "Expected file to be part of program");
183099
+ const originalText = Debug.checkDefined(rootSourceFile.getText());
183100
+ (_b = this.getScriptInfo(rootFile)) == null ? void 0 : _b.editContent(0, originalText.length, updatedText);
183001
183101
  this.updateGraph();
183002
- cb(this.program, originalProgram, (_d = this.program) == null ? void 0 : _d.getSourceFile(rootFile));
183003
- (_e = this.getScriptInfo(rootFile)) == null ? void 0 : _e.editContent(0, this.program.getSourceFile(rootFile).getText().length, originalText);
183102
+ cb(this.program, originalProgram, (_c = this.program) == null ? void 0 : _c.getSourceFile(rootFile));
183103
+ (_d = this.getScriptInfo(rootFile)) == null ? void 0 : _d.editContent(0, this.program.getSourceFile(rootFile).getText().length, originalText);
183004
183104
  }
183005
183105
  /** @internal */
183006
183106
  getCompilerOptionsForNoDtsResolutionProject() {
@@ -185496,6 +185596,7 @@ var _ProjectService = class _ProjectService {
185496
185596
  configFileExistenceInfo.config.watchedDirectoriesStale = void 0;
185497
185597
  }
185498
185598
  updateNonInferredProjectFiles(project, files, propertyReader) {
185599
+ var _a;
185499
185600
  const projectRootFilesMap = project.getRootFilesMap();
185500
185601
  const newRootScriptInfoMap = /* @__PURE__ */ new Map();
185501
185602
  for (const f of files) {
@@ -185507,7 +185608,7 @@ var _ProjectService = class _ProjectService {
185507
185608
  path = normalizedPathToPath(fileName, this.currentDirectory, this.toCanonicalFileName);
185508
185609
  const existingValue = projectRootFilesMap.get(path);
185509
185610
  if (existingValue) {
185510
- if (existingValue.info) {
185611
+ if (((_a = existingValue.info) == null ? void 0 : _a.path) === path) {
185511
185612
  project.removeFile(
185512
185613
  existingValue.info,
185513
185614
  /*fileExists*/
@@ -187300,8 +187401,9 @@ function createModuleSpecifierCache(host) {
187300
187401
  if (!cache || currentKey !== key(fromFileName, preferences, options)) return void 0;
187301
187402
  return cache.get(toFileName2);
187302
187403
  },
187303
- set(fromFileName, toFileName2, preferences, options, modulePaths, moduleSpecifiers) {
187404
+ set(fromFileName, toFileName2, preferences, options, kind, modulePaths, moduleSpecifiers) {
187304
187405
  ensureCache(fromFileName, preferences, options).set(toFileName2, createInfo(
187406
+ kind,
187305
187407
  modulePaths,
187306
187408
  moduleSpecifiers,
187307
187409
  /*isBlockedByPackageJsonDependencies*/
@@ -187329,6 +187431,8 @@ function createModuleSpecifierCache(host) {
187329
187431
  info.modulePaths = modulePaths;
187330
187432
  } else {
187331
187433
  cache2.set(toFileName2, createInfo(
187434
+ /*kind*/
187435
+ void 0,
187332
187436
  modulePaths,
187333
187437
  /*moduleSpecifiers*/
187334
187438
  void 0,
@@ -187344,6 +187448,8 @@ function createModuleSpecifierCache(host) {
187344
187448
  info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
187345
187449
  } else {
187346
187450
  cache2.set(toFileName2, createInfo(
187451
+ /*kind*/
187452
+ void 0,
187347
187453
  /*modulePaths*/
187348
187454
  void 0,
187349
187455
  /*moduleSpecifiers*/
@@ -187377,8 +187483,8 @@ function createModuleSpecifierCache(host) {
187377
187483
  function key(fromFileName, preferences, options) {
187378
187484
  return `${fromFileName},${preferences.importModuleSpecifierEnding},${preferences.importModuleSpecifierPreference},${options.overrideImportMode}`;
187379
187485
  }
187380
- function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
187381
- return { modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies };
187486
+ function createInfo(kind, modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) {
187487
+ return { kind, modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies };
187382
187488
  }
187383
187489
  }
187384
187490
 
@@ -192287,6 +192393,7 @@ if (typeof console !== "undefined") {
192287
192393
  emitNewLineBeforeLeadingCommentOfPosition,
192288
192394
  emitNewLineBeforeLeadingComments,
192289
192395
  emitNewLineBeforeLeadingCommentsOfPosition,
192396
+ emitResolverSkipsTypeChecking,
192290
192397
  emitSkippedWithNoDiagnostics,
192291
192398
  emptyArray,
192292
192399
  emptyFileSystemEntries,