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/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.5";
21
- var version = `${versionMajorMinor}.0-dev.20240520`;
21
+ var version = `${versionMajorMinor}.0-dev.20240522`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -11521,7 +11521,7 @@ function getTextOfJSDocComment(comment) {
11521
11521
  function formatJSDocLink(link) {
11522
11522
  const kind = link.kind === 324 /* JSDocLink */ ? "link" : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" : "linkplain";
11523
11523
  const name = link.name ? entityNameToString(link.name) : "";
11524
- const space = link.name && link.text.startsWith("://") ? "" : " ";
11524
+ const space = link.name && (link.text === "" || link.text.startsWith("://")) ? "" : " ";
11525
11525
  return `{@${kind} ${name}${space}${link.text}}`;
11526
11526
  }
11527
11527
  function getEffectiveTypeParameterDeclarations(node) {
@@ -16877,6 +16877,9 @@ function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
16877
16877
  }
16878
16878
  return 0;
16879
16879
  }
16880
+ function skipAlias(symbol, checker) {
16881
+ return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
16882
+ }
16880
16883
  function getCombinedLocalAndExportSymbolFlags(symbol) {
16881
16884
  return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
16882
16885
  }
@@ -44085,7 +44088,7 @@ function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile
44085
44088
  }
44086
44089
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
44087
44090
  const cached = cache == null ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences, options);
44088
- return [cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
44091
+ return [cached == null ? void 0 : cached.kind, cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
44089
44092
  }
44090
44093
  function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) {
44091
44094
  return getModuleSpecifiersWithCacheInfo(
@@ -44103,16 +44106,16 @@ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSo
44103
44106
  function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
44104
44107
  let computedWithoutCache = false;
44105
44108
  const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
44106
- if (ambient) return { moduleSpecifiers: [ambient], computedWithoutCache };
44107
- let [specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
44109
+ if (ambient) return { kind: "ambient", moduleSpecifiers: [ambient], computedWithoutCache };
44110
+ let [kind, specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
44108
44111
  moduleSymbol,
44109
44112
  importingSourceFile,
44110
44113
  host,
44111
44114
  userPreferences,
44112
44115
  options
44113
44116
  );
44114
- if (specifiers) return { moduleSpecifiers: specifiers, computedWithoutCache };
44115
- if (!moduleSourceFile) return { moduleSpecifiers: emptyArray, computedWithoutCache };
44117
+ if (specifiers) return { kind, moduleSpecifiers: specifiers, computedWithoutCache };
44118
+ if (!moduleSourceFile) return { kind: void 0, moduleSpecifiers: emptyArray, computedWithoutCache };
44116
44119
  computedWithoutCache = true;
44117
44120
  modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host, compilerOptions, options));
44118
44121
  const result = computeModuleSpecifiers(
@@ -44124,8 +44127,8 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
44124
44127
  options,
44125
44128
  forAutoImport
44126
44129
  );
44127
- cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result);
44128
- return { moduleSpecifiers: result, computedWithoutCache };
44130
+ cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, result.kind, modulePaths, result.moduleSpecifiers);
44131
+ return result;
44129
44132
  }
44130
44133
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
44131
44134
  const info = getInfo(importingSourceFile.fileName, host);
@@ -44144,8 +44147,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
44144
44147
  }
44145
44148
  ));
44146
44149
  if (existingSpecifier) {
44147
- const moduleSpecifiers = [existingSpecifier];
44148
- return moduleSpecifiers;
44150
+ return { kind: void 0, moduleSpecifiers: [existingSpecifier], computedWithoutCache: true };
44149
44151
  }
44150
44152
  const importedFileIsInNodeModules = some(modulePaths, (p) => p.isInNodeModules);
44151
44153
  let nodeModulesSpecifiers;
@@ -44166,7 +44168,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
44166
44168
  ) : void 0;
44167
44169
  nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier);
44168
44170
  if (specifier && modulePath.isRedirect) {
44169
- return nodeModulesSpecifiers;
44171
+ return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
44170
44172
  }
44171
44173
  if (!specifier) {
44172
44174
  const local = getLocalModuleSpecifier(
@@ -44195,7 +44197,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
44195
44197
  }
44196
44198
  }
44197
44199
  }
44198
- 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);
44200
+ 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 };
44199
44201
  }
44200
44202
  function getInfo(importingSourceFileName, host) {
44201
44203
  importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
@@ -46090,8 +46092,8 @@ function createTypeChecker(host) {
46090
46092
  void 0
46091
46093
  );
46092
46094
  }
46093
- function getEmitResolver(sourceFile, cancellationToken2) {
46094
- getDiagnostics(sourceFile, cancellationToken2);
46095
+ function getEmitResolver(sourceFile, cancellationToken2, skipDiagnostics) {
46096
+ if (!skipDiagnostics) getDiagnostics(sourceFile, cancellationToken2);
46095
46097
  return emitResolver;
46096
46098
  }
46097
46099
  function lookupOrIssueError(location, message, ...args) {
@@ -49019,8 +49021,15 @@ function createTypeChecker(host) {
49019
49021
  ).accessibility === 0 /* Accessible */) {
49020
49022
  return { accessibility: 0 /* Accessible */ };
49021
49023
  }
49022
- return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
49023
- accessibility: 3 /* NotResolved */,
49024
+ if (!symbol) {
49025
+ return {
49026
+ accessibility: 3 /* NotResolved */,
49027
+ errorSymbolName: getTextOfNode(firstIdentifier),
49028
+ errorNode: firstIdentifier
49029
+ };
49030
+ }
49031
+ return hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
49032
+ accessibility: 1 /* NotAccessible */,
49024
49033
  errorSymbolName: getTextOfNode(firstIdentifier),
49025
49034
  errorNode: firstIdentifier
49026
49035
  };
@@ -112460,6 +112469,9 @@ function getFirstProjectOutput(configFile, ignoreCase) {
112460
112469
  if (buildInfoPath) return buildInfoPath;
112461
112470
  return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`);
112462
112471
  }
112472
+ function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
112473
+ return !!forceDtsEmit && !!emitOnly;
112474
+ }
112463
112475
  function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
112464
112476
  var compilerOptions = host.getCompilerOptions();
112465
112477
  var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
@@ -112577,7 +112589,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
112577
112589
  const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
112578
112590
  const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson);
112579
112591
  const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit;
112580
- if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck) {
112592
+ if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck || emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)) {
112581
112593
  filesForEmit.forEach(collectLinkedAliases);
112582
112594
  }
112583
112595
  const declarationTransform = transformNodes(
@@ -119513,17 +119525,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
119513
119525
  const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
119514
119526
  if (result) return result;
119515
119527
  }
119516
- const emitResolver = getTypeChecker().getEmitResolver(options.outFile ? void 0 : sourceFile, cancellationToken);
119528
+ const typeChecker2 = getTypeChecker();
119529
+ const emitResolver = typeChecker2.getEmitResolver(
119530
+ options.outFile ? void 0 : sourceFile,
119531
+ cancellationToken,
119532
+ emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)
119533
+ );
119517
119534
  mark("beforeEmit");
119518
- const emitResult = emitFiles(
119519
- emitResolver,
119520
- getEmitHost(writeFileCallback),
119521
- sourceFile,
119522
- getTransformers(options, customTransformers, emitOnly),
119523
- emitOnly,
119524
- /*onlyBuildInfo*/
119525
- false,
119526
- forceDtsEmit
119535
+ const emitResult = typeChecker2.runWithCancellationToken(
119536
+ cancellationToken,
119537
+ () => emitFiles(
119538
+ emitResolver,
119539
+ getEmitHost(writeFileCallback),
119540
+ sourceFile,
119541
+ getTransformers(options, customTransformers, emitOnly),
119542
+ emitOnly,
119543
+ /*onlyBuildInfo*/
119544
+ false,
119545
+ forceDtsEmit
119546
+ )
119527
119547
  );
119528
119548
  mark("afterEmit");
119529
119549
  measure("Emit", "beforeEmit", "afterEmit");
@@ -120263,7 +120283,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120263
120283
  return file2 || void 0;
120264
120284
  }
120265
120285
  let redirectedPath;
120266
- if (isReferencedFile(reason) && !useSourceOfProjectReferenceRedirect) {
120286
+ if (!useSourceOfProjectReferenceRedirect) {
120267
120287
  const redirectProject = getProjectReferenceRedirectProject(fileName);
120268
120288
  if (redirectProject) {
120269
120289
  if (redirectProject.commandLine.options.outFile) {
@@ -122474,7 +122494,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
122474
122494
  host
122475
122495
  );
122476
122496
  }
122477
- function handleDtsMayChangeOf(state, path, cancellationToken, host) {
122497
+ function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
122478
122498
  removeSemanticDiagnosticsOf(state, path);
122479
122499
  if (!state.changedFilesSet.has(path)) {
122480
122500
  const program = Debug.checkDefined(state.program);
@@ -122489,7 +122509,9 @@ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
122489
122509
  /*useFileVersionAsSignature*/
122490
122510
  true
122491
122511
  );
122492
- if (getEmitDeclarations(state.compilerOptions)) {
122512
+ if (invalidateJsFiles) {
122513
+ addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
122514
+ } else if (getEmitDeclarations(state.compilerOptions)) {
122493
122515
  addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
122494
122516
  }
122495
122517
  }
@@ -122508,7 +122530,7 @@ function isChangedSignature(state, path) {
122508
122530
  const newSignature = Debug.checkDefined(state.fileInfos.get(path)).signature;
122509
122531
  return newSignature !== oldSignature;
122510
122532
  }
122511
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
122533
+ function handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host) {
122512
122534
  var _a;
122513
122535
  if (!((_a = state.fileInfos.get(filePath)) == null ? void 0 : _a.affectsGlobalScope)) return false;
122514
122536
  BuilderState.getAllFilesExcludingDefaultLibraryFile(
@@ -122520,6 +122542,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
122520
122542
  (file) => handleDtsMayChangeOf(
122521
122543
  state,
122522
122544
  file.resolvedPath,
122545
+ invalidateJsFiles,
122523
122546
  cancellationToken,
122524
122547
  host
122525
122548
  )
@@ -122528,7 +122551,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
122528
122551
  return true;
122529
122552
  }
122530
122553
  function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
122531
- var _a;
122554
+ var _a, _b;
122532
122555
  if (!state.referencedMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return;
122533
122556
  if (!isChangedSignature(state, affectedFile.resolvedPath)) return;
122534
122557
  if (getIsolatedModules(state.compilerOptions)) {
@@ -122539,8 +122562,22 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
122539
122562
  const currentPath = queue.pop();
122540
122563
  if (!seenFileNamesMap.has(currentPath)) {
122541
122564
  seenFileNamesMap.set(currentPath, true);
122542
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host)) return;
122543
- handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
122565
+ if (handleDtsMayChangeOfGlobalScope(
122566
+ state,
122567
+ currentPath,
122568
+ /*invalidateJsFiles*/
122569
+ false,
122570
+ cancellationToken,
122571
+ host
122572
+ )) return;
122573
+ handleDtsMayChangeOf(
122574
+ state,
122575
+ currentPath,
122576
+ /*invalidateJsFiles*/
122577
+ false,
122578
+ cancellationToken,
122579
+ host
122580
+ );
122544
122581
  if (isChangedSignature(state, currentPath)) {
122545
122582
  const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
122546
122583
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -122549,27 +122586,38 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
122549
122586
  }
122550
122587
  }
122551
122588
  const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
122552
- (_a = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a.forEach((exportedFromPath) => {
122553
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host)) return true;
122589
+ const invalidateJsFiles = !!((_a = affectedFile.symbol) == null ? void 0 : _a.exports) && !!forEachEntry(
122590
+ affectedFile.symbol.exports,
122591
+ (exported) => {
122592
+ if ((exported.flags & 128 /* ConstEnum */) !== 0) return true;
122593
+ const aliased = skipAlias(exported, state.program.getTypeChecker());
122594
+ if (aliased === exported) return false;
122595
+ return (aliased.flags & 128 /* ConstEnum */) !== 0 && some(aliased.declarations, (d) => getSourceFileOfNode(d) === affectedFile);
122596
+ }
122597
+ );
122598
+ (_b = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _b.forEach((exportedFromPath) => {
122599
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, invalidateJsFiles, cancellationToken, host)) return true;
122554
122600
  const references = state.referencedMap.getKeys(exportedFromPath);
122555
122601
  return references && forEachKey(references, (filePath) => handleDtsMayChangeOfFileAndExportsOfFile(
122556
122602
  state,
122557
122603
  filePath,
122604
+ invalidateJsFiles,
122558
122605
  seenFileAndExportsOfFile,
122559
122606
  cancellationToken,
122560
122607
  host
122561
122608
  ));
122562
122609
  });
122563
122610
  }
122564
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
122611
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsFiles, seenFileAndExportsOfFile, cancellationToken, host) {
122565
122612
  var _a;
122566
122613
  if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) return void 0;
122567
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host)) return true;
122568
- handleDtsMayChangeOf(state, filePath, cancellationToken, host);
122614
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host)) return true;
122615
+ handleDtsMayChangeOf(state, filePath, invalidateJsFiles, cancellationToken, host);
122569
122616
  (_a = state.referencedMap.getKeys(filePath)) == null ? void 0 : _a.forEach(
122570
122617
  (referencingFilePath) => handleDtsMayChangeOfFileAndExportsOfFile(
122571
122618
  state,
122572
122619
  referencingFilePath,
122620
+ invalidateJsFiles,
122573
122621
  seenFileAndExportsOfFile,
122574
122622
  cancellationToken,
122575
122623
  host
@@ -122608,6 +122656,7 @@ function getBuildInfo2(state) {
122608
122656
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
122609
122657
  const fileNames = [];
122610
122658
  const fileNameToFileId = /* @__PURE__ */ new Map();
122659
+ const rootFileNames = new Set(state.program.getRootFileNames().map((f) => toPath(f, currentDirectory, state.program.getCanonicalFileName)));
122611
122660
  const root = [];
122612
122661
  if (state.compilerOptions.outFile) {
122613
122662
  const fileInfos2 = arrayFrom(state.fileInfos.entries(), ([key, value]) => {
@@ -122619,6 +122668,7 @@ function getBuildInfo2(state) {
122619
122668
  fileNames,
122620
122669
  fileInfos: fileInfos2,
122621
122670
  root,
122671
+ resolvedRoot: toResolvedRoot(),
122622
122672
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
122623
122673
  outSignature: state.outSignature,
122624
122674
  latestChangedDtsFile,
@@ -122648,7 +122698,8 @@ function getBuildInfo2(state) {
122648
122698
  if (!isJsonSourceFile(file) && sourceFileMayBeEmitted(file, state.program)) {
122649
122699
  const emitSignature = (_b = state.emitSignatures) == null ? void 0 : _b.get(key);
122650
122700
  if (emitSignature !== actualSignature) {
122651
- (emitSignatures || (emitSignatures = [])).push(
122701
+ emitSignatures = append(
122702
+ emitSignatures,
122652
122703
  emitSignature === void 0 ? fileId : (
122653
122704
  // There is no emit, encode as false
122654
122705
  // fileId, signature: emptyArray if signature only differs in dtsMap option than our own compilerOptions otherwise EmitSignature
@@ -122695,7 +122746,8 @@ function getBuildInfo2(state) {
122695
122746
  const file = state.program.getSourceFileByPath(path);
122696
122747
  if (!file || !sourceFileMayBeEmitted(file, state.program)) continue;
122697
122748
  const fileId = toFileId(path), pendingEmit = state.affectedFilesPendingEmit.get(path);
122698
- (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push(
122749
+ affectedFilesPendingEmit = append(
122750
+ affectedFilesPendingEmit,
122699
122751
  pendingEmit === fullEmitForOptions ? fileId : (
122700
122752
  // Pending full emit per options
122701
122753
  pendingEmit === 8 /* Dts */ ? [fileId] : (
@@ -122711,7 +122763,7 @@ function getBuildInfo2(state) {
122711
122763
  let changeFileSet;
122712
122764
  if (state.changedFilesSet.size) {
122713
122765
  for (const path of arrayFrom(state.changedFilesSet.keys()).sort(compareStringsCaseSensitive)) {
122714
- (changeFileSet || (changeFileSet = [])).push(toFileId(path));
122766
+ changeFileSet = append(changeFileSet, toFileId(path));
122715
122767
  }
122716
122768
  }
122717
122769
  const emitDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics(state.emitDiagnosticsPerFile);
@@ -122719,6 +122771,7 @@ function getBuildInfo2(state) {
122719
122771
  fileNames,
122720
122772
  fileInfos,
122721
122773
  root,
122774
+ resolvedRoot: toResolvedRoot(),
122722
122775
  options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions),
122723
122776
  fileIdsList,
122724
122777
  referencedMap,
@@ -122749,8 +122802,8 @@ function getBuildInfo2(state) {
122749
122802
  const key = fileIds.join();
122750
122803
  let fileIdListId = fileNamesToFileIdListId == null ? void 0 : fileNamesToFileIdListId.get(key);
122751
122804
  if (fileIdListId === void 0) {
122752
- (fileIdsList || (fileIdsList = [])).push(fileIds);
122753
- (fileNamesToFileIdListId || (fileNamesToFileIdListId = /* @__PURE__ */ new Map())).set(key, fileIdListId = fileIdsList.length);
122805
+ fileIdsList = append(fileIdsList, fileIds);
122806
+ (fileNamesToFileIdListId ?? (fileNamesToFileIdListId = /* @__PURE__ */ new Map())).set(key, fileIdListId = fileIdsList.length);
122754
122807
  }
122755
122808
  return fileIdListId;
122756
122809
  }
@@ -122767,6 +122820,16 @@ function getBuildInfo2(state) {
122767
122820
  root[root.length - 2] = [lastButOne, fileId];
122768
122821
  return root.length = root.length - 1;
122769
122822
  }
122823
+ function toResolvedRoot() {
122824
+ let result;
122825
+ rootFileNames.forEach((path) => {
122826
+ const file = state.program.getSourceFileByPath(path);
122827
+ if (file && path !== file.resolvedPath) {
122828
+ result = append(result, [toFileId(file.resolvedPath), toFileId(path)]);
122829
+ }
122830
+ });
122831
+ return result;
122832
+ }
122770
122833
  function convertToProgramBuildInfoCompilerOptions(options) {
122771
122834
  let result;
122772
122835
  const { optionsNameMap } = getOptionsNameMap();
@@ -122800,7 +122863,8 @@ function getBuildInfo2(state) {
122800
122863
  if (diagnostics) {
122801
122864
  for (const key of arrayFrom(diagnostics.keys()).sort(compareStringsCaseSensitive)) {
122802
122865
  const value = diagnostics.get(key);
122803
- (result || (result = [])).push(
122866
+ result = append(
122867
+ result,
122804
122868
  value.length ? [
122805
122869
  toFileId(key),
122806
122870
  convertToReusableDiagnostics(value)
@@ -123289,7 +123353,8 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
123289
123353
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
123290
123354
  const fileInfos = /* @__PURE__ */ new Map();
123291
123355
  let rootIndex = 0;
123292
- const roots = [];
123356
+ const roots = /* @__PURE__ */ new Map();
123357
+ const resolvedRoots = new Map(program.resolvedRoot);
123293
123358
  program.fileInfos.forEach((fileInfo, index) => {
123294
123359
  const path = toPath(program.fileNames[index], buildInfoDirectory, getCanonicalFileName);
123295
123360
  const version2 = isString(fileInfo) ? fileInfo : fileInfo.version;
@@ -123299,16 +123364,24 @@ function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
123299
123364
  const fileId = index + 1;
123300
123365
  if (isArray(current)) {
123301
123366
  if (current[0] <= fileId && fileId <= current[1]) {
123302
- roots.push(path);
123367
+ addRoot(fileId, path);
123303
123368
  if (current[1] === fileId) rootIndex++;
123304
123369
  }
123305
123370
  } else if (current === fileId) {
123306
- roots.push(path);
123371
+ addRoot(fileId, path);
123307
123372
  rootIndex++;
123308
123373
  }
123309
123374
  }
123310
123375
  });
123311
123376
  return { fileInfos, roots };
123377
+ function addRoot(fileId, path) {
123378
+ const root = resolvedRoots.get(fileId);
123379
+ if (root) {
123380
+ roots.set(toPath(program.fileNames[root - 1], buildInfoDirectory, getCanonicalFileName), path);
123381
+ } else {
123382
+ roots.set(path, void 0);
123383
+ }
123384
+ }
123312
123385
  }
123313
123386
  function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) {
123314
123387
  return {
@@ -126904,13 +126977,15 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
126904
126977
  reason: `${inputFile} does not exist`
126905
126978
  };
126906
126979
  }
126980
+ const inputPath = buildInfoProgram ? toPath2(state, inputFile) : void 0;
126907
126981
  if (buildInfoTime && buildInfoTime < inputTime) {
126908
126982
  let version2;
126909
126983
  let currentVersion;
126910
126984
  if (buildInfoProgram) {
126911
126985
  if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
126912
- version2 = buildInfoVersionMap.fileInfos.get(toPath2(state, inputFile));
126913
- const text = version2 ? state.readFileWithCache(inputFile) : void 0;
126986
+ const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath);
126987
+ version2 = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath);
126988
+ const text = version2 ? state.readFileWithCache(resolvedInputPath ?? inputFile) : void 0;
126914
126989
  currentVersion = text !== void 0 ? getSourceFileVersionAsHashFromText(host, text) : void 0;
126915
126990
  if (version2 && version2 === currentVersion) pseudoInputUpToDate = true;
126916
126991
  }
@@ -126926,18 +127001,21 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
126926
127001
  newestInputFileName = inputFile;
126927
127002
  newestInputFileTime = inputTime;
126928
127003
  }
126929
- if (buildInfoProgram) seenRoots.add(toPath2(state, inputFile));
127004
+ if (buildInfoProgram) seenRoots.add(inputPath);
126930
127005
  }
126931
127006
  if (buildInfoProgram) {
126932
127007
  if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
126933
- for (const existingRoot of buildInfoVersionMap.roots) {
126934
- if (!seenRoots.has(existingRoot)) {
126935
- return {
126936
- type: 9 /* OutOfDateRoots */,
126937
- buildInfoFile: buildInfoPath,
126938
- inputFile: existingRoot
126939
- };
126940
- }
127008
+ const existingRoot = forEachEntry(
127009
+ buildInfoVersionMap.roots,
127010
+ // File was root file when project was built but its not any more
127011
+ (_resolved, existingRoot2) => !seenRoots.has(existingRoot2) ? existingRoot2 : void 0
127012
+ );
127013
+ if (existingRoot) {
127014
+ return {
127015
+ type: 9 /* OutOfDateRoots */,
127016
+ buildInfoFile: buildInfoPath,
127017
+ inputFile: existingRoot
127018
+ };
126941
127019
  }
126942
127020
  }
126943
127021
  if (!buildInfoPath) {
@@ -2756,7 +2756,6 @@ declare namespace ts {
2756
2756
  private compilerOptions;
2757
2757
  compileOnSaveEnabled: boolean;
2758
2758
  protected watchOptions: WatchOptions | undefined;
2759
- private rootFiles;
2760
2759
  private rootFilesMap;
2761
2760
  private program;
2762
2761
  private externalFiles;
@@ -2837,7 +2836,7 @@ declare namespace ts {
2837
2836
  private detachScriptInfoIfNotRoot;
2838
2837
  isClosed(): boolean;
2839
2838
  hasRoots(): boolean;
2840
- getRootFiles(): ts.server.NormalizedPath[];
2839
+ getRootFiles(): NormalizedPath[];
2841
2840
  getRootScriptInfos(): ts.server.ScriptInfo[];
2842
2841
  getScriptInfos(): ScriptInfo[];
2843
2842
  getExcludedFiles(): readonly NormalizedPath[];