typescript 5.4.0-dev.20231127 → 5.4.0-dev.20231129

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.4";
21
- var version = `${versionMajorMinor}.0-dev.20231127`;
21
+ var version = `${versionMajorMinor}.0-dev.20231129`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -15951,19 +15951,19 @@ function clearMap(map2, onDeleteValue) {
15951
15951
  function mutateMapSkippingNewValues(map2, newMap, options) {
15952
15952
  const { onDeleteValue, onExistingValue } = options;
15953
15953
  map2.forEach((existingValue, key) => {
15954
- const valueInNewMap = newMap.get(key);
15955
- if (valueInNewMap === void 0) {
15954
+ var _a;
15955
+ if (!(newMap == null ? void 0 : newMap.has(key))) {
15956
15956
  map2.delete(key);
15957
15957
  onDeleteValue(existingValue, key);
15958
15958
  } else if (onExistingValue) {
15959
- onExistingValue(existingValue, valueInNewMap, key);
15959
+ onExistingValue(existingValue, (_a = newMap.get) == null ? void 0 : _a.call(newMap, key), key);
15960
15960
  }
15961
15961
  });
15962
15962
  }
15963
15963
  function mutateMap(map2, newMap, options) {
15964
15964
  mutateMapSkippingNewValues(map2, newMap, options);
15965
15965
  const { createNewValue } = options;
15966
- newMap.forEach((valueInNewMap, key) => {
15966
+ newMap == null ? void 0 : newMap.forEach((valueInNewMap, key) => {
15967
15967
  if (!map2.has(key)) {
15968
15968
  map2.set(key, createNewValue(key, valueInNewMap));
15969
15969
  }
@@ -31214,8 +31214,9 @@ var Parser;
31214
31214
  function nextTokenIsStringLiteral() {
31215
31215
  return nextToken() === 11 /* StringLiteral */;
31216
31216
  }
31217
- function nextTokenIsFromKeyword() {
31218
- return nextToken() === 161 /* FromKeyword */;
31217
+ function nextTokenIsFromKeywordOrEqualsToken() {
31218
+ nextToken();
31219
+ return token() === 161 /* FromKeyword */ || token() === 64 /* EqualsToken */;
31219
31220
  }
31220
31221
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
31221
31222
  nextToken();
@@ -31912,7 +31913,7 @@ var Parser;
31912
31913
  identifier = parseIdentifier();
31913
31914
  }
31914
31915
  let isTypeOnly = false;
31915
- if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31916
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeywordOrEqualsToken)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31916
31917
  isTypeOnly = true;
31917
31918
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
31918
31919
  }
@@ -32695,18 +32696,7 @@ var Parser;
32695
32696
  }
32696
32697
  nextTokenJSDoc();
32697
32698
  skipWhitespace();
32698
- const p2 = getNodePos();
32699
- let name = tokenIsIdentifierOrKeyword(token()) ? parseEntityName(
32700
- /*allowReservedWords*/
32701
- true
32702
- ) : void 0;
32703
- if (name) {
32704
- while (token() === 81 /* PrivateIdentifier */) {
32705
- reScanHashToken();
32706
- nextTokenJSDoc();
32707
- name = finishNode(factory2.createJSDocMemberName(name, parseIdentifier()), p2);
32708
- }
32709
- }
32699
+ const name = parseJSDocLinkName();
32710
32700
  const text = [];
32711
32701
  while (token() !== 20 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) {
32712
32702
  text.push(scanner.getTokenText());
@@ -32715,6 +32705,26 @@ var Parser;
32715
32705
  const create = linkType === "link" ? factory2.createJSDocLink : linkType === "linkcode" ? factory2.createJSDocLinkCode : factory2.createJSDocLinkPlain;
32716
32706
  return finishNode(create(name, text.join("")), start2, scanner.getTokenEnd());
32717
32707
  }
32708
+ function parseJSDocLinkName() {
32709
+ if (tokenIsIdentifierOrKeyword(token())) {
32710
+ const pos = getNodePos();
32711
+ let name = parseIdentifierName();
32712
+ while (parseOptional(25 /* DotToken */)) {
32713
+ name = finishNode(factory2.createQualifiedName(name, token() === 81 /* PrivateIdentifier */ ? createMissingNode(
32714
+ 80 /* Identifier */,
32715
+ /*reportAtCurrentPosition*/
32716
+ false
32717
+ ) : parseIdentifier()), pos);
32718
+ }
32719
+ while (token() === 81 /* PrivateIdentifier */) {
32720
+ reScanHashToken();
32721
+ nextTokenJSDoc();
32722
+ name = finishNode(factory2.createJSDocMemberName(name, parseIdentifier()), pos);
32723
+ }
32724
+ return name;
32725
+ }
32726
+ return void 0;
32727
+ }
32718
32728
  function parseJSDocLinkPrefix() {
32719
32729
  skipWhitespaceOrAsterisk();
32720
32730
  if (token() === 19 /* OpenBraceToken */ && nextTokenJSDoc() === 60 /* AtToken */ && tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
@@ -36783,34 +36793,39 @@ function specToDiagnostic(spec, disallowTrailingRecursion) {
36783
36793
  return [Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
36784
36794
  }
36785
36795
  }
36786
- function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, path, useCaseSensitiveFileNames2) {
36787
- const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude");
36796
+ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, basePath, useCaseSensitiveFileNames2) {
36797
+ const rawExcludeRegex = getRegularExpressionForWildcard(exclude, basePath, "exclude");
36788
36798
  const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames2 ? "" : "i");
36789
36799
  const wildcardDirectories = {};
36800
+ const wildCardKeyToPath = /* @__PURE__ */ new Map();
36790
36801
  if (include !== void 0) {
36791
36802
  const recursiveKeys = [];
36792
36803
  for (const file of include) {
36793
- const spec = normalizePath(combinePaths(path, file));
36804
+ const spec = normalizePath(combinePaths(basePath, file));
36794
36805
  if (excludeRegex && excludeRegex.test(spec)) {
36795
36806
  continue;
36796
36807
  }
36797
36808
  const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2);
36798
36809
  if (match) {
36799
- const { key, flags } = match;
36800
- const existingFlags = wildcardDirectories[key];
36810
+ const { key, path, flags } = match;
36811
+ const existingPath = wildCardKeyToPath.get(key);
36812
+ const existingFlags = existingPath !== void 0 ? wildcardDirectories[existingPath] : void 0;
36801
36813
  if (existingFlags === void 0 || existingFlags < flags) {
36802
- wildcardDirectories[key] = flags;
36814
+ wildcardDirectories[existingPath !== void 0 ? existingPath : path] = flags;
36815
+ if (existingPath === void 0)
36816
+ wildCardKeyToPath.set(key, path);
36803
36817
  if (flags === 1 /* Recursive */) {
36804
36818
  recursiveKeys.push(key);
36805
36819
  }
36806
36820
  }
36807
36821
  }
36808
36822
  }
36809
- for (const key in wildcardDirectories) {
36810
- if (hasProperty(wildcardDirectories, key)) {
36823
+ for (const path in wildcardDirectories) {
36824
+ if (hasProperty(wildcardDirectories, path)) {
36811
36825
  for (const recursiveKey of recursiveKeys) {
36812
- if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames2)) {
36813
- delete wildcardDirectories[key];
36826
+ const key = toCanonicalKey(path, useCaseSensitiveFileNames2);
36827
+ if (key !== recursiveKey && containsPath(recursiveKey, key, basePath, !useCaseSensitiveFileNames2)) {
36828
+ delete wildcardDirectories[path];
36814
36829
  }
36815
36830
  }
36816
36831
  }
@@ -36818,6 +36833,9 @@ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExclu
36818
36833
  }
36819
36834
  return wildcardDirectories;
36820
36835
  }
36836
+ function toCanonicalKey(path, useCaseSensitiveFileNames2) {
36837
+ return useCaseSensitiveFileNames2 ? path : toFileNameLowerCase(path);
36838
+ }
36821
36839
  function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36822
36840
  const match = wildcardDirectoryPattern.exec(spec);
36823
36841
  if (match) {
@@ -36825,13 +36843,16 @@ function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36825
36843
  const starWildcardIndex = spec.indexOf("*");
36826
36844
  const lastDirectorySeperatorIndex = spec.lastIndexOf(directorySeparator);
36827
36845
  return {
36828
- key: useCaseSensitiveFileNames2 ? match[0] : toFileNameLowerCase(match[0]),
36846
+ key: toCanonicalKey(match[0], useCaseSensitiveFileNames2),
36847
+ path: match[0],
36829
36848
  flags: questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex || starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex ? 1 /* Recursive */ : 0 /* None */
36830
36849
  };
36831
36850
  }
36832
36851
  if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
36852
+ const path = removeTrailingDirectorySeparator(spec);
36833
36853
  return {
36834
- key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames2 ? spec : toFileNameLowerCase(spec)),
36854
+ key: toCanonicalKey(path, useCaseSensitiveFileNames2),
36855
+ path,
36835
36856
  flags: 1 /* Recursive */
36836
36857
  };
36837
36858
  }
@@ -37409,6 +37430,9 @@ function getAutomaticTypeDirectiveNames(options, host) {
37409
37430
  }
37410
37431
  return result;
37411
37432
  }
37433
+ function isPackageJsonInfo(entry) {
37434
+ return !!(entry == null ? void 0 : entry.contents);
37435
+ }
37412
37436
  function compilerOptionValueToString(value) {
37413
37437
  var _a;
37414
37438
  if (value === null || typeof value !== "object") {
@@ -37513,7 +37537,7 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
37513
37537
  }
37514
37538
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
37515
37539
  let cache;
37516
- return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, entries, getInternalMap };
37540
+ return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, getInternalMap };
37517
37541
  function getPackageJsonInfo2(packageJsonPath) {
37518
37542
  return cache == null ? void 0 : cache.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
37519
37543
  }
@@ -37523,10 +37547,6 @@ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
37523
37547
  function clear2() {
37524
37548
  cache = void 0;
37525
37549
  }
37526
- function entries() {
37527
- const iter = cache == null ? void 0 : cache.entries();
37528
- return iter ? arrayFrom(iter) : [];
37529
- }
37530
37550
  function getInternalMap() {
37531
37551
  return cache;
37532
37552
  }
@@ -38406,13 +38426,13 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
38406
38426
  }
38407
38427
  const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
38408
38428
  if (existing !== void 0) {
38409
- if (typeof existing !== "boolean") {
38429
+ if (isPackageJsonInfo(existing)) {
38410
38430
  if (traceEnabled)
38411
38431
  trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
38412
38432
  (_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
38413
38433
  return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
38414
38434
  } else {
38415
- if (existing && traceEnabled)
38435
+ if (existing.directoryExists && traceEnabled)
38416
38436
  trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
38417
38437
  (_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
38418
38438
  return void 0;
@@ -38434,7 +38454,7 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
38434
38454
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
38435
38455
  }
38436
38456
  if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
38437
- state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists);
38457
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, { packageDirectory, directoryExists });
38438
38458
  (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
38439
38459
  }
38440
38460
  }
@@ -42407,7 +42427,7 @@ function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourc
42407
42427
  }
42408
42428
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, preferences, userPreferences, options = {}) {
42409
42429
  const info = getInfo(importingSourceFileName, host);
42410
- const modulePaths = getAllModulePaths(importingSourceFileName, toFileName2, host, userPreferences, options);
42430
+ const modulePaths = getAllModulePaths(info, toFileName2, host, userPreferences, options);
42411
42431
  return firstDefined(modulePaths, (modulePath) => tryGetModuleNameAsNodeModule(
42412
42432
  modulePath,
42413
42433
  info,
@@ -42460,7 +42480,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42460
42480
  if (!moduleSourceFile)
42461
42481
  return { moduleSpecifiers: emptyArray, computedWithoutCache };
42462
42482
  computedWithoutCache = true;
42463
- modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host));
42483
+ modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host));
42464
42484
  const result = computeModuleSpecifiers(
42465
42485
  modulePaths,
42466
42486
  compilerOptions,
@@ -42474,7 +42494,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42474
42494
  return { moduleSpecifiers: result, computedWithoutCache };
42475
42495
  }
42476
42496
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
42477
- const info = getInfo(importingSourceFile.path, host);
42497
+ const info = getInfo(importingSourceFile.fileName, host);
42478
42498
  const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
42479
42499
  const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
42480
42500
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
@@ -42538,16 +42558,22 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
42538
42558
  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);
42539
42559
  }
42540
42560
  function getInfo(importingSourceFileName, host) {
42561
+ importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
42541
42562
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
42542
42563
  const sourceDirectory = getDirectoryPath(importingSourceFileName);
42543
- return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
42564
+ return {
42565
+ getCanonicalFileName,
42566
+ importingSourceFileName,
42567
+ sourceDirectory,
42568
+ canonicalSourceDirectory: getCanonicalFileName(sourceDirectory)
42569
+ };
42544
42570
  }
42545
42571
  function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }, pathsOnly) {
42546
42572
  const { baseUrl, paths, rootDirs } = compilerOptions;
42547
42573
  if (pathsOnly && !paths) {
42548
42574
  return void 0;
42549
42575
  }
42550
- const { sourceDirectory, getCanonicalFileName } = info;
42576
+ const { sourceDirectory, canonicalSourceDirectory, getCanonicalFileName } = info;
42551
42577
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
42552
42578
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
42553
42579
  if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
@@ -42572,7 +42598,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42572
42598
  if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
42573
42599
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
42574
42600
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
42575
- const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
42601
+ const sourceIsInternal = startsWith(canonicalSourceDirectory, projectDirectory);
42576
42602
  const targetIsInternal = startsWith(modulePath, projectDirectory);
42577
42603
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
42578
42604
  return maybeNonRelative;
@@ -42645,8 +42671,9 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
42645
42671
  });
42646
42672
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
42647
42673
  }
42648
- function getAllModulePaths(importingFilePath, importedFileName, host, preferences, options = {}) {
42674
+ function getAllModulePaths(info, importedFileName, host, preferences, options = {}) {
42649
42675
  var _a;
42676
+ const importingFilePath = toPath(info.importingSourceFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42650
42677
  const importedFilePath = toPath(importedFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42651
42678
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
42652
42679
  if (cache) {
@@ -42654,30 +42681,29 @@ function getAllModulePaths(importingFilePath, importedFileName, host, preference
42654
42681
  if (cached == null ? void 0 : cached.modulePaths)
42655
42682
  return cached.modulePaths;
42656
42683
  }
42657
- const modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host);
42684
+ const modulePaths = getAllModulePathsWorker(info, importedFileName, host);
42658
42685
  if (cache) {
42659
42686
  cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
42660
42687
  }
42661
42688
  return modulePaths;
42662
42689
  }
42663
- function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42664
- const getCanonicalFileName = hostGetCanonicalFileName(host);
42690
+ function getAllModulePathsWorker(info, importedFileName, host) {
42665
42691
  const allFileNames = /* @__PURE__ */ new Map();
42666
42692
  let importedFileFromNodeModules = false;
42667
42693
  forEachFileNameOfModule(
42668
- importingFileName,
42694
+ info.importingSourceFileName,
42669
42695
  importedFileName,
42670
42696
  host,
42671
42697
  /*preferSymlinks*/
42672
42698
  true,
42673
42699
  (path, isRedirect) => {
42674
42700
  const isInNodeModules = pathContainsNodeModules(path);
42675
- allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect, isInNodeModules });
42701
+ allFileNames.set(path, { path: info.getCanonicalFileName(path), isRedirect, isInNodeModules });
42676
42702
  importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
42677
42703
  }
42678
42704
  );
42679
42705
  const sortedPaths = [];
42680
- for (let directory = getDirectoryPath(importingFileName); allFileNames.size !== 0; ) {
42706
+ for (let directory = info.canonicalSourceDirectory; allFileNames.size !== 0; ) {
42681
42707
  const directoryStart = ensureTrailingDirectorySeparator(directory);
42682
42708
  let pathsInDirectory;
42683
42709
  allFileNames.forEach(({ path, isRedirect, isInNodeModules }, fileName) => {
@@ -42698,7 +42724,10 @@ function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42698
42724
  directory = newDirectory;
42699
42725
  }
42700
42726
  if (allFileNames.size) {
42701
- const remainingPaths = arrayFrom(allFileNames.values());
42727
+ const remainingPaths = arrayFrom(
42728
+ allFileNames.entries(),
42729
+ ([fileName, { isRedirect, isInNodeModules }]) => ({ path: fileName, isRedirect, isInNodeModules })
42730
+ );
42702
42731
  if (remainingPaths.length > 1)
42703
42732
  remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
42704
42733
  sortedPaths.push(...remainingPaths);
@@ -42858,7 +42887,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
42858
42887
  }
42859
42888
  return processEnding(shortest, allowedEndings, compilerOptions);
42860
42889
  }
42861
- function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
42890
+ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, canonicalSourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
42862
42891
  if (!host.fileExists || !host.readFile) {
42863
42892
  return void 0;
42864
42893
  }
@@ -42902,7 +42931,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42902
42931
  }
42903
42932
  const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
42904
42933
  const pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
42905
- if (!(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42934
+ if (!(startsWith(canonicalSourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42906
42935
  return void 0;
42907
42936
  }
42908
42937
  const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
@@ -42915,7 +42944,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42915
42944
  let moduleFileToTry = path;
42916
42945
  let maybeBlockedByTypesVersions = false;
42917
42946
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
42918
- if (typeof cachedPackageJson === "object" || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
42947
+ if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
42919
42948
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
42920
42949
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
42921
42950
  if (getResolvePackageJsonExports(options)) {
@@ -54502,9 +54531,13 @@ function createTypeChecker(host) {
54502
54531
  function getConstraintOfTypeParameter(typeParameter) {
54503
54532
  return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : void 0;
54504
54533
  }
54534
+ function isConstMappedType(type, depth) {
54535
+ const typeVariable = getHomomorphicTypeVariable(type);
54536
+ return !!typeVariable && isConstTypeVariable(typeVariable, depth);
54537
+ }
54505
54538
  function isConstTypeVariable(type, depth = 0) {
54506
54539
  var _a;
54507
- return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 4096 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
54540
+ return depth < 5 && !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 4096 /* Const */)) || type.flags & 3145728 /* UnionOrIntersection */ && some(type.types, (t) => isConstTypeVariable(t, depth)) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType, depth + 1) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type), depth + 1) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType, depth) || getObjectFlags(type) & 32 /* Mapped */ && isConstMappedType(type, depth) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t, depth)) >= 0));
54508
54541
  }
54509
54542
  function getConstraintOfIndexedAccess(type) {
54510
54543
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -66877,14 +66910,15 @@ function createTypeChecker(host) {
66877
66910
  if (declaration) {
66878
66911
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
66879
66912
  const parent = declaration.parent.parent;
66880
- if (parent.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(declaration) & 6 /* Constant */ || parent.kind === 169 /* Parameter */) {
66913
+ const rootDeclaration = getRootDeclaration(parent);
66914
+ if (rootDeclaration.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(rootDeclaration) & 6 /* Constant */ || rootDeclaration.kind === 169 /* Parameter */) {
66881
66915
  const links = getNodeLinks(parent);
66882
66916
  if (!(links.flags & 4194304 /* InCheckIdentifier */)) {
66883
66917
  links.flags |= 4194304 /* InCheckIdentifier */;
66884
66918
  const parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
66885
66919
  const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
66886
66920
  links.flags &= ~4194304 /* InCheckIdentifier */;
66887
- if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(parent.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
66921
+ if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(rootDeclaration.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
66888
66922
  const pattern = declaration.parent;
66889
66923
  const narrowedType = getFlowTypeOfReference(
66890
66924
  pattern,
@@ -107971,8 +108005,8 @@ function transformDeclarations(context) {
107971
108005
  const specifier = getModuleSpecifier(
107972
108006
  options,
107973
108007
  currentSourceFile,
107974
- toPath(outputFilePath2, host.getCurrentDirectory(), host.getCanonicalFileName),
107975
- toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName),
108008
+ getNormalizedAbsolutePath(outputFilePath2, host.getCurrentDirectory()),
108009
+ getNormalizedAbsolutePath(declFileName, host.getCurrentDirectory()),
107976
108010
  host
107977
108011
  );
107978
108012
  if (!pathIsRelative(specifier)) {
@@ -115398,8 +115432,8 @@ function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensi
115398
115432
  }
115399
115433
  const baseName = getBaseNameOfFileName(fileOrDirectory);
115400
115434
  const fsQueryResult = {
115401
- fileExists: host.fileExists(fileOrDirectoryPath),
115402
- directoryExists: host.directoryExists(fileOrDirectoryPath)
115435
+ fileExists: host.fileExists(fileOrDirectory),
115436
+ directoryExists: host.directoryExists(fileOrDirectory)
115403
115437
  };
115404
115438
  if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
115405
115439
  clearCache();
@@ -115482,11 +115516,9 @@ function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, t
115482
115516
  });
115483
115517
  }
115484
115518
  function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
115485
- const missingFilePaths = program.getMissingFilePaths();
115486
- const newMissingFilePathMap = arrayToMap(missingFilePaths, identity, returnTrue);
115487
115519
  mutateMap(
115488
115520
  missingFileWatches,
115489
- newMissingFilePathMap,
115521
+ program.getMissingFilePaths(),
115490
115522
  {
115491
115523
  // Watch the missing files
115492
115524
  createNewValue: createMissingFileWatch,
@@ -115497,18 +115529,22 @@ function updateMissingFilePathsWatch(program, missingFileWatches, createMissingF
115497
115529
  );
115498
115530
  }
115499
115531
  function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
115500
- mutateMap(
115501
- existingWatchedForWildcards,
115502
- wildcardDirectories,
115503
- {
115504
- // Create new watch and recursive info
115505
- createNewValue: createWildcardDirectoryWatcher,
115506
- // Close existing watch thats not needed any more
115507
- onDeleteValue: closeFileWatcherOf,
115508
- // Close existing watch that doesnt match in the flags
115509
- onExistingValue: updateWildcardDirectoryWatcher
115510
- }
115511
- );
115532
+ if (wildcardDirectories) {
115533
+ mutateMap(
115534
+ existingWatchedForWildcards,
115535
+ new Map(Object.entries(wildcardDirectories)),
115536
+ {
115537
+ // Create new watch and recursive info
115538
+ createNewValue: createWildcardDirectoryWatcher,
115539
+ // Close existing watch thats not needed any more
115540
+ onDeleteValue: closeFileWatcherOf,
115541
+ // Close existing watch that doesnt match in the flags
115542
+ onExistingValue: updateWildcardDirectoryWatcher
115543
+ }
115544
+ );
115545
+ } else {
115546
+ clearMap(existingWatchedForWildcards, closeFileWatcherOf);
115547
+ }
115512
115548
  function createWildcardDirectoryWatcher(directory, flags) {
115513
115549
  return {
115514
115550
  watcher: watchDirectory(directory, flags),
@@ -116313,7 +116349,8 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
116313
116349
  return false;
116314
116350
  if (program.getSourceFiles().some(sourceFileNotUptoDate))
116315
116351
  return false;
116316
- if (program.getMissingFilePaths().some(fileExists))
116352
+ const missingPaths = program.getMissingFilePaths();
116353
+ if (missingPaths && forEachEntry(missingPaths, fileExists))
116317
116354
  return false;
116318
116355
  const currentOptions = program.getCompilerOptions();
116319
116356
  if (!compareDataObjects(currentOptions, newOptions))
@@ -116613,7 +116650,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116613
116650
  let redirectTargetsMap = createMultiMap();
116614
116651
  let usesUriStyleNodeCoreModules = false;
116615
116652
  const filesByName = /* @__PURE__ */ new Map();
116616
- let missingFilePaths;
116653
+ let missingFileNames = /* @__PURE__ */ new Map();
116617
116654
  const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? /* @__PURE__ */ new Map() : void 0;
116618
116655
  let resolvedProjectReferences;
116619
116656
  let projectReferenceRedirects;
@@ -116732,12 +116769,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116732
116769
  });
116733
116770
  }
116734
116771
  }
116735
- missingFilePaths = arrayFrom(mapDefinedIterator(filesByName.entries(), ([path, file]) => file === void 0 ? path : void 0));
116736
116772
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
116737
116773
  processingDefaultLibFiles = void 0;
116738
116774
  processingOtherFiles = void 0;
116739
116775
  }
116740
- Debug.assert(!!missingFilePaths);
116741
116776
  if (oldProgram && host.onReleaseOldSourceFile) {
116742
116777
  const oldSourceFiles = oldProgram.getSourceFiles();
116743
116778
  for (const oldSourceFile of oldSourceFiles) {
@@ -116782,8 +116817,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116782
116817
  getSourceFile,
116783
116818
  getSourceFileByPath,
116784
116819
  getSourceFiles: () => files,
116785
- getMissingFilePaths: () => missingFilePaths,
116786
- // TODO: GH#18217
116820
+ getMissingFilePaths: () => missingFileNames,
116787
116821
  getModuleResolutionCache: () => moduleResolutionCache,
116788
116822
  getFilesByNameMap: () => filesByName,
116789
116823
  getCompilerOptions: () => options,
@@ -117210,7 +117244,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117210
117244
  const newSourceFiles = [];
117211
117245
  const modifiedSourceFiles = [];
117212
117246
  structureIsReused = 2 /* Completely */;
117213
- if (oldProgram.getMissingFilePaths().some((missingFilePath) => host.fileExists(missingFilePath))) {
117247
+ if (forEachEntry(oldProgram.getMissingFilePaths(), (missingFileName) => host.fileExists(missingFileName))) {
117214
117248
  return 0 /* Not */;
117215
117249
  }
117216
117250
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -117350,7 +117384,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117350
117384
  if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
117351
117385
  return 1 /* SafeModules */;
117352
117386
  }
117353
- missingFilePaths = oldProgram.getMissingFilePaths();
117387
+ missingFileNames = oldProgram.getMissingFilePaths();
117354
117388
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
117355
117389
  for (const newSourceFile of newSourceFiles) {
117356
117390
  filesByName.set(newSourceFile.path, newSourceFile);
@@ -117407,7 +117441,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117407
117441
  const path = toPath3(f);
117408
117442
  if (getSourceFileByPath(path))
117409
117443
  return true;
117410
- if (contains(missingFilePaths, path))
117444
+ if (missingFileNames.has(path))
117411
117445
  return false;
117412
117446
  return host.fileExists(f);
117413
117447
  },
@@ -118219,6 +118253,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118219
118253
  addFileToFilesByName(
118220
118254
  file2,
118221
118255
  path,
118256
+ fileName,
118222
118257
  /*redirectedPath*/
118223
118258
  void 0
118224
118259
  );
@@ -118291,7 +118326,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118291
118326
  if (fileFromPackageId) {
118292
118327
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
118293
118328
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
118294
- addFileToFilesByName(dupFile, path, redirectedPath);
118329
+ addFileToFilesByName(dupFile, path, fileName, redirectedPath);
118295
118330
  addFileIncludeReason(dupFile, reason);
118296
118331
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118297
118332
  processingOtherFiles.push(dupFile);
@@ -118301,7 +118336,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118301
118336
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118302
118337
  }
118303
118338
  }
118304
- addFileToFilesByName(file, path, redirectedPath);
118339
+ addFileToFilesByName(file, path, fileName, redirectedPath);
118305
118340
  if (file) {
118306
118341
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
118307
118342
  file.fileName = fileName;
@@ -118341,14 +118376,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118341
118376
  if (file)
118342
118377
  fileReasons.add(file.path, reason);
118343
118378
  }
118344
- function addFileToFilesByName(file, path, redirectedPath) {
118379
+ function addFileToFilesByName(file, path, fileName, redirectedPath) {
118345
118380
  if (redirectedPath) {
118346
- filesByName.set(redirectedPath, file);
118347
- filesByName.set(path, file || false);
118381
+ updateFilesByNameMap(fileName, redirectedPath, file);
118382
+ updateFilesByNameMap(fileName, path, file || false);
118348
118383
  } else {
118349
- filesByName.set(path, file);
118384
+ updateFilesByNameMap(fileName, path, file);
118350
118385
  }
118351
118386
  }
118387
+ function updateFilesByNameMap(fileName, path, file) {
118388
+ filesByName.set(path, file);
118389
+ if (file !== void 0)
118390
+ missingFileNames.delete(path);
118391
+ else
118392
+ missingFileNames.set(path, fileName);
118393
+ }
118352
118394
  function getProjectReferenceRedirect(fileName) {
118353
118395
  const referencedProject = getProjectReferenceRedirectProject(fileName);
118354
118396
  return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
@@ -118669,6 +118711,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118669
118711
  /*file*/
118670
118712
  void 0,
118671
118713
  sourceFilePath,
118714
+ refPath,
118672
118715
  /*redirectedPath*/
118673
118716
  void 0
118674
118717
  );
@@ -118680,6 +118723,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118680
118723
  addFileToFilesByName(
118681
118724
  sourceFile,
118682
118725
  sourceFilePath,
118726
+ refPath,
118683
118727
  /*redirectedPath*/
118684
118728
  void 0
118685
118729
  );
@@ -118689,6 +118733,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118689
118733
  addFileToFilesByName(
118690
118734
  sourceFile,
118691
118735
  sourceFilePath,
118736
+ refPath,
118692
118737
  /*redirectedPath*/
118693
118738
  void 0
118694
118739
  );
@@ -122474,8 +122519,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122474
122519
  function closeTypeRootsWatch() {
122475
122520
  clearMap(typeRootsWatches, closeFileWatcher);
122476
122521
  }
122477
- function createTypeRootsWatch(typeRootPath, typeRoot) {
122478
- return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
122522
+ function createTypeRootsWatch(typeRoot) {
122523
+ return canWatchTypeRootPath(typeRoot) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
122479
122524
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
122480
122525
  if (cachedDirectoryStructureHost) {
122481
122526
  cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
@@ -122484,7 +122529,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122484
122529
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
122485
122530
  const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
122486
122531
  typeRoot,
122487
- typeRootPath,
122532
+ resolutionHost.toPath(typeRoot),
122488
122533
  rootPath,
122489
122534
  rootPathComponents,
122490
122535
  getCurrentDirectory,
@@ -122505,7 +122550,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122505
122550
  if (typeRoots) {
122506
122551
  mutateMap(
122507
122552
  typeRootsWatches,
122508
- arrayToMap(typeRoots, (tr) => resolutionHost.toPath(tr)),
122553
+ new Set(typeRoots),
122509
122554
  {
122510
122555
  createNewValue: createTypeRootsWatch,
122511
122556
  onDeleteValue: closeFileWatcher
@@ -123434,7 +123479,11 @@ function createWatchProgram(host) {
123434
123479
  const oldProgram = getCurrentProgram();
123435
123480
  builderProgram = createProgram2(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
123436
123481
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
123437
- updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()), watchMissingFilePath);
123482
+ updateMissingFilePathsWatch(
123483
+ builderProgram.getProgram(),
123484
+ missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()),
123485
+ watchMissingFilePath
123486
+ );
123438
123487
  if (needsUpdateInTypeRootWatch) {
123439
123488
  resolutionCache.updateTypeRootsWatch();
123440
123489
  }
@@ -123727,8 +123776,15 @@ function createWatchProgram(host) {
123727
123776
  cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
123728
123777
  }
123729
123778
  }
123730
- function watchMissingFilePath(missingFilePath) {
123731
- return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, 500 /* Medium */, watchOptions, WatchType.MissingFile);
123779
+ function watchMissingFilePath(missingFilePath, missingFileName) {
123780
+ return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(
123781
+ missingFilePath,
123782
+ missingFileName,
123783
+ onMissingFileChange,
123784
+ 500 /* Medium */,
123785
+ watchOptions,
123786
+ WatchType.MissingFile
123787
+ );
123732
123788
  }
123733
123789
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
123734
123790
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
@@ -123740,15 +123796,11 @@ function createWatchProgram(host) {
123740
123796
  }
123741
123797
  }
123742
123798
  function watchConfigFileWildCardDirectories() {
123743
- if (wildcardDirectories) {
123744
- updateWatchingWildcardDirectories(
123745
- watchedWildcardDirectories || (watchedWildcardDirectories = /* @__PURE__ */ new Map()),
123746
- new Map(Object.entries(wildcardDirectories)),
123747
- watchWildcardDirectory
123748
- );
123749
- } else if (watchedWildcardDirectories) {
123750
- clearMap(watchedWildcardDirectories, closeFileWatcherOf);
123751
- }
123799
+ updateWatchingWildcardDirectories(
123800
+ watchedWildcardDirectories || (watchedWildcardDirectories = /* @__PURE__ */ new Map()),
123801
+ wildcardDirectories,
123802
+ watchWildcardDirectory
123803
+ );
123752
123804
  }
123753
123805
  function watchWildcardDirectory(directory, flags) {
123754
123806
  return watchDirectory(
@@ -123820,7 +123872,7 @@ function createWatchProgram(host) {
123820
123872
  );
123821
123873
  }
123822
123874
  function watchReferencedProject(configFileName2, configPath, commandLine) {
123823
- var _a, _b, _c, _d, _e;
123875
+ var _a, _b, _c, _d;
123824
123876
  commandLine.watcher || (commandLine.watcher = watchFile2(
123825
123877
  configFileName2,
123826
123878
  (_fileName, eventKind) => {
@@ -123835,55 +123887,50 @@ function createWatchProgram(host) {
123835
123887
  ((_a = commandLine.parsedCommandLine) == null ? void 0 : _a.watchOptions) || watchOptions,
123836
123888
  WatchType.ConfigFileOfReferencedProject
123837
123889
  ));
123838
- if ((_b = commandLine.parsedCommandLine) == null ? void 0 : _b.wildcardDirectories) {
123839
- updateWatchingWildcardDirectories(
123840
- commandLine.watchedDirectories || (commandLine.watchedDirectories = /* @__PURE__ */ new Map()),
123841
- new Map(Object.entries((_c = commandLine.parsedCommandLine) == null ? void 0 : _c.wildcardDirectories)),
123842
- (directory, flags) => {
123843
- var _a2;
123844
- return watchDirectory(
123845
- directory,
123846
- (fileOrDirectory) => {
123847
- const fileOrDirectoryPath = toPath3(fileOrDirectory);
123848
- if (cachedDirectoryStructureHost) {
123849
- cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
123850
- }
123851
- nextSourceFileVersion(fileOrDirectoryPath);
123852
- const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
123853
- if (!(config == null ? void 0 : config.parsedCommandLine))
123854
- return;
123855
- if (isIgnoredFileFromWildCardWatching({
123856
- watchedDirPath: toPath3(directory),
123857
- fileOrDirectory,
123858
- fileOrDirectoryPath,
123859
- configFileName: configFileName2,
123860
- options: config.parsedCommandLine.options,
123861
- program: config.parsedCommandLine.fileNames,
123862
- currentDirectory,
123863
- useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
123864
- writeLog,
123865
- toPath: toPath3
123866
- }))
123867
- return;
123868
- if (config.updateLevel !== 2 /* Full */) {
123869
- config.updateLevel = 1 /* RootNamesAndUpdate */;
123870
- scheduleProgramUpdate();
123871
- }
123872
- },
123873
- flags,
123874
- ((_a2 = commandLine.parsedCommandLine) == null ? void 0 : _a2.watchOptions) || watchOptions,
123875
- WatchType.WildcardDirectoryOfReferencedProject
123876
- );
123877
- }
123878
- );
123879
- } else if (commandLine.watchedDirectories) {
123880
- clearMap(commandLine.watchedDirectories, closeFileWatcherOf);
123881
- commandLine.watchedDirectories = void 0;
123882
- }
123890
+ updateWatchingWildcardDirectories(
123891
+ commandLine.watchedDirectories || (commandLine.watchedDirectories = /* @__PURE__ */ new Map()),
123892
+ (_b = commandLine.parsedCommandLine) == null ? void 0 : _b.wildcardDirectories,
123893
+ (directory, flags) => {
123894
+ var _a2;
123895
+ return watchDirectory(
123896
+ directory,
123897
+ (fileOrDirectory) => {
123898
+ const fileOrDirectoryPath = toPath3(fileOrDirectory);
123899
+ if (cachedDirectoryStructureHost) {
123900
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
123901
+ }
123902
+ nextSourceFileVersion(fileOrDirectoryPath);
123903
+ const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
123904
+ if (!(config == null ? void 0 : config.parsedCommandLine))
123905
+ return;
123906
+ if (isIgnoredFileFromWildCardWatching({
123907
+ watchedDirPath: toPath3(directory),
123908
+ fileOrDirectory,
123909
+ fileOrDirectoryPath,
123910
+ configFileName: configFileName2,
123911
+ options: config.parsedCommandLine.options,
123912
+ program: config.parsedCommandLine.fileNames,
123913
+ currentDirectory,
123914
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
123915
+ writeLog,
123916
+ toPath: toPath3
123917
+ }))
123918
+ return;
123919
+ if (config.updateLevel !== 2 /* Full */) {
123920
+ config.updateLevel = 1 /* RootNamesAndUpdate */;
123921
+ scheduleProgramUpdate();
123922
+ }
123923
+ },
123924
+ flags,
123925
+ ((_a2 = commandLine.parsedCommandLine) == null ? void 0 : _a2.watchOptions) || watchOptions,
123926
+ WatchType.WildcardDirectoryOfReferencedProject
123927
+ );
123928
+ }
123929
+ );
123883
123930
  updateExtendedConfigFilesWatches(
123884
123931
  configPath,
123885
- (_d = commandLine.parsedCommandLine) == null ? void 0 : _d.options,
123886
- ((_e = commandLine.parsedCommandLine) == null ? void 0 : _e.watchOptions) || watchOptions,
123932
+ (_c = commandLine.parsedCommandLine) == null ? void 0 : _c.options,
123933
+ ((_d = commandLine.parsedCommandLine) == null ? void 0 : _d.watchOptions) || watchOptions,
123887
123934
  WatchType.ExtendedConfigOfReferencedProject
123888
123935
  );
123889
123936
  }
@@ -124189,9 +124236,9 @@ function getBuildOrder(state) {
124189
124236
  function createStateBuildOrder(state) {
124190
124237
  const buildOrder = createBuildOrder(state, state.rootNames.map((f) => resolveProjectName(state, f)));
124191
124238
  state.resolvedConfigFilePaths.clear();
124192
- const currentProjects = new Map(
124239
+ const currentProjects = new Set(
124193
124240
  getBuildOrderFromAnyBuildOrder(buildOrder).map(
124194
- (resolved) => [toResolvedConfigFilePath(state, resolved), true]
124241
+ (resolved) => toResolvedConfigFilePath(state, resolved)
124195
124242
  )
124196
124243
  );
124197
124244
  const noopOnDelete = { onDeleteValue: noop };
@@ -124203,6 +124250,7 @@ function createStateBuildOrder(state) {
124203
124250
  mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124204
124251
  mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124205
124252
  mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124253
+ mutateMapSkippingNewValues(state.lastCachedPackageJsonLookups, currentProjects, noopOnDelete);
124206
124254
  if (state.watch) {
124207
124255
  mutateMapSkippingNewValues(
124208
124256
  state.allWatchedConfigFiles,
@@ -124451,7 +124499,7 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124451
124499
  return withProgramOrUndefined(action) || emptyArray;
124452
124500
  }
124453
124501
  function createProgram2() {
124454
- var _a, _b;
124502
+ var _a, _b, _c;
124455
124503
  Debug.assert(program === void 0);
124456
124504
  if (state.options.dry) {
124457
124505
  reportStatus(state, Diagnostics.A_non_dry_build_would_build_project_0, project);
@@ -124480,12 +124528,13 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124480
124528
  config.projectReferences
124481
124529
  );
124482
124530
  if (state.watch) {
124531
+ const internalMap = (_c = state.moduleResolutionCache) == null ? void 0 : _c.getPackageJsonInfoCache().getInternalMap();
124483
124532
  state.lastCachedPackageJsonLookups.set(
124484
124533
  projectPath,
124485
- state.moduleResolutionCache && map(
124486
- state.moduleResolutionCache.getPackageJsonInfoCache().entries(),
124487
- ([path, data]) => [state.host.realpath && data ? toPath2(state, state.host.realpath(path)) : path, data]
124488
- )
124534
+ internalMap && new Set(arrayFrom(
124535
+ internalMap.values(),
124536
+ (data) => state.host.realpath && (isPackageJsonInfo(data) || data.directoryExists) ? state.host.realpath(combinePaths(data.packageDirectory, "package.json")) : combinePaths(data.packageDirectory, "package.json")
124537
+ ))
124489
124538
  );
124490
124539
  state.builderPrograms.set(projectPath, program);
124491
124540
  }
@@ -125218,9 +125267,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
125218
125267
  const extendedConfigStatus = forEach(project.options.configFile.extendedSourceFiles || emptyArray, (configFile) => checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName));
125219
125268
  if (extendedConfigStatus)
125220
125269
  return extendedConfigStatus;
125221
- const dependentPackageFileStatus = forEach(
125222
- state.lastCachedPackageJsonLookups.get(resolvedPath) || emptyArray,
125223
- ([path]) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125270
+ const packageJsonLookups = state.lastCachedPackageJsonLookups.get(resolvedPath);
125271
+ const dependentPackageFileStatus = packageJsonLookups && forEachKey(
125272
+ packageJsonLookups,
125273
+ (path) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125224
125274
  );
125225
125275
  if (dependentPackageFileStatus)
125226
125276
  return dependentPackageFileStatus;
@@ -125577,7 +125627,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
125577
125627
  return;
125578
125628
  updateWatchingWildcardDirectories(
125579
125629
  getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath),
125580
- new Map(Object.entries(parsed.wildcardDirectories)),
125630
+ parsed.wildcardDirectories,
125581
125631
  (dir, flags) => state.watchDirectory(
125582
125632
  dir,
125583
125633
  (fileOrDirectory) => {
@@ -125609,9 +125659,9 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) {
125609
125659
  return;
125610
125660
  mutateMap(
125611
125661
  getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath),
125612
- arrayToMap(parsed.fileNames, (fileName) => toPath2(state, fileName)),
125662
+ new Set(parsed.fileNames),
125613
125663
  {
125614
- createNewValue: (_path, input) => watchFile(
125664
+ createNewValue: (input) => watchFile(
125615
125665
  state,
125616
125666
  input,
125617
125667
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
@@ -125629,11 +125679,11 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) {
125629
125679
  return;
125630
125680
  mutateMap(
125631
125681
  getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath),
125632
- new Map(state.lastCachedPackageJsonLookups.get(resolvedPath)),
125682
+ state.lastCachedPackageJsonLookups.get(resolvedPath),
125633
125683
  {
125634
- createNewValue: (path, _input) => watchFile(
125684
+ createNewValue: (input) => watchFile(
125635
125685
  state,
125636
- path,
125686
+ input,
125637
125687
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
125638
125688
  2e3 /* High */,
125639
125689
  parsed == null ? void 0 : parsed.watchOptions,