@typescript-deploys/pr-build 5.4.0-pr-56434-11 → 5.4.0-pr-56476-3

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-insiders.20231117`;
21
+ var version = `${versionMajorMinor}.0-insiders.20231121`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -972,23 +972,6 @@ function compareStringsCaseSensitive(a, b) {
972
972
  function getStringComparer(ignoreCase) {
973
973
  return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
974
974
  }
975
- var createUIStringComparer = (() => {
976
- return createIntlCollatorStringComparer;
977
- function compareWithCallback(a, b, comparer) {
978
- if (a === b)
979
- return 0 /* EqualTo */;
980
- if (a === void 0)
981
- return -1 /* LessThan */;
982
- if (b === void 0)
983
- return 1 /* GreaterThan */;
984
- const value = comparer(a, b);
985
- return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
986
- }
987
- function createIntlCollatorStringComparer(locale) {
988
- const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
989
- return (a, b) => compareWithCallback(a, b, comparer);
990
- }
991
- })();
992
975
  var uiComparerCaseSensitive;
993
976
  var uiLocale;
994
977
  function setUILocale(value) {
@@ -5952,6 +5935,10 @@ var Diagnostics = {
5952
5935
  ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1286, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled_1286", "ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
5953
5936
  A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled: diag(1287, 1 /* Error */, "A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimM_1287", "A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled."),
5954
5937
  An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabled: diag(1288, 1 /* Error */, "An_import_alias_cannot_resolve_to_a_type_or_type_only_declaration_when_verbatimModuleSyntax_is_enabl_1288", "An import alias cannot resolve to a type or type-only declaration when 'verbatimModuleSyntax' is enabled."),
5938
+ _0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1289, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1289", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5939
+ _0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1290, 1 /* Error */, "_0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_1290", "'{0}' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5940
+ _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5941
+ _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5955
5942
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5956
5943
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5957
5944
  The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
@@ -36800,34 +36787,39 @@ function specToDiagnostic(spec, disallowTrailingRecursion) {
36800
36787
  return [Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
36801
36788
  }
36802
36789
  }
36803
- function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, path, useCaseSensitiveFileNames2) {
36804
- const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude");
36790
+ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, basePath, useCaseSensitiveFileNames2) {
36791
+ const rawExcludeRegex = getRegularExpressionForWildcard(exclude, basePath, "exclude");
36805
36792
  const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames2 ? "" : "i");
36806
36793
  const wildcardDirectories = {};
36794
+ const wildCardKeyToPath = /* @__PURE__ */ new Map();
36807
36795
  if (include !== void 0) {
36808
36796
  const recursiveKeys = [];
36809
36797
  for (const file of include) {
36810
- const spec = normalizePath(combinePaths(path, file));
36798
+ const spec = normalizePath(combinePaths(basePath, file));
36811
36799
  if (excludeRegex && excludeRegex.test(spec)) {
36812
36800
  continue;
36813
36801
  }
36814
36802
  const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2);
36815
36803
  if (match) {
36816
- const { key, flags } = match;
36817
- const existingFlags = wildcardDirectories[key];
36804
+ const { key, path, flags } = match;
36805
+ const existingPath = wildCardKeyToPath.get(key);
36806
+ const existingFlags = existingPath !== void 0 ? wildcardDirectories[existingPath] : void 0;
36818
36807
  if (existingFlags === void 0 || existingFlags < flags) {
36819
- wildcardDirectories[key] = flags;
36808
+ wildcardDirectories[existingPath !== void 0 ? existingPath : path] = flags;
36809
+ if (existingPath === void 0)
36810
+ wildCardKeyToPath.set(key, path);
36820
36811
  if (flags === 1 /* Recursive */) {
36821
36812
  recursiveKeys.push(key);
36822
36813
  }
36823
36814
  }
36824
36815
  }
36825
36816
  }
36826
- for (const key in wildcardDirectories) {
36827
- if (hasProperty(wildcardDirectories, key)) {
36817
+ for (const path in wildcardDirectories) {
36818
+ if (hasProperty(wildcardDirectories, path)) {
36828
36819
  for (const recursiveKey of recursiveKeys) {
36829
- if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames2)) {
36830
- delete wildcardDirectories[key];
36820
+ const key = toCanonicalKey(path, useCaseSensitiveFileNames2);
36821
+ if (key !== recursiveKey && containsPath(recursiveKey, key, basePath, !useCaseSensitiveFileNames2)) {
36822
+ delete wildcardDirectories[path];
36831
36823
  }
36832
36824
  }
36833
36825
  }
@@ -36835,6 +36827,9 @@ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExclu
36835
36827
  }
36836
36828
  return wildcardDirectories;
36837
36829
  }
36830
+ function toCanonicalKey(path, useCaseSensitiveFileNames2) {
36831
+ return useCaseSensitiveFileNames2 ? path : toFileNameLowerCase(path);
36832
+ }
36838
36833
  function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36839
36834
  const match = wildcardDirectoryPattern.exec(spec);
36840
36835
  if (match) {
@@ -36842,13 +36837,16 @@ function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36842
36837
  const starWildcardIndex = spec.indexOf("*");
36843
36838
  const lastDirectorySeperatorIndex = spec.lastIndexOf(directorySeparator);
36844
36839
  return {
36845
- key: useCaseSensitiveFileNames2 ? match[0] : toFileNameLowerCase(match[0]),
36840
+ key: toCanonicalKey(match[0], useCaseSensitiveFileNames2),
36841
+ path: match[0],
36846
36842
  flags: questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex || starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex ? 1 /* Recursive */ : 0 /* None */
36847
36843
  };
36848
36844
  }
36849
36845
  if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
36846
+ const path = removeTrailingDirectorySeparator(spec);
36850
36847
  return {
36851
- key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames2 ? spec : toFileNameLowerCase(spec)),
36848
+ key: toCanonicalKey(path, useCaseSensitiveFileNames2),
36849
+ path,
36852
36850
  flags: 1 /* Recursive */
36853
36851
  };
36854
36852
  }
@@ -37530,22 +37528,50 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
37530
37528
  }
37531
37529
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
37532
37530
  let cache;
37533
- return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, entries, getInternalMap };
37531
+ let canonicalPathToCacheKey;
37532
+ return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, deletePackageJsonInfo, clear: clear2, entries };
37534
37533
  function getPackageJsonInfo2(packageJsonPath) {
37535
- return cache == null ? void 0 : cache.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
37534
+ if (!cache)
37535
+ return void 0;
37536
+ const absolute = getNormalizedAbsolutePath(packageJsonPath, currentDirectory);
37537
+ const result = cache.get(absolute);
37538
+ if (result !== void 0)
37539
+ return result;
37540
+ if (!canonicalPathToCacheKey)
37541
+ return void 0;
37542
+ const path = getCanonicalFileName(absolute);
37543
+ if (path === absolute)
37544
+ return void 0;
37545
+ const cacheKey = canonicalPathToCacheKey.get(path);
37546
+ return cacheKey !== void 0 ? cache.get(cacheKey) : void 0;
37536
37547
  }
37537
37548
  function setPackageJsonInfo(packageJsonPath, info) {
37538
- (cache || (cache = /* @__PURE__ */ new Map())).set(toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info);
37549
+ const absolute = getNormalizedAbsolutePath(packageJsonPath, currentDirectory);
37550
+ (cache || (cache = /* @__PURE__ */ new Map())).set(absolute, info);
37551
+ const path = getCanonicalFileName(absolute);
37552
+ if (path !== absolute) {
37553
+ (canonicalPathToCacheKey ?? (canonicalPathToCacheKey = /* @__PURE__ */ new Map())).set(path, absolute);
37554
+ }
37555
+ }
37556
+ function deletePackageJsonInfo(packageJsonPath) {
37557
+ if (!cache)
37558
+ return;
37559
+ const absolute = getNormalizedAbsolutePath(packageJsonPath, currentDirectory);
37560
+ cache.delete(absolute);
37561
+ if (canonicalPathToCacheKey) {
37562
+ const path = getCanonicalFileName(absolute);
37563
+ const cacheKey = canonicalPathToCacheKey.get(path);
37564
+ if (cacheKey !== void 0) {
37565
+ cache.delete(cacheKey);
37566
+ canonicalPathToCacheKey.delete(path);
37567
+ }
37568
+ }
37539
37569
  }
37540
37570
  function clear2() {
37541
37571
  cache = void 0;
37542
37572
  }
37543
37573
  function entries() {
37544
- const iter = cache == null ? void 0 : cache.entries();
37545
- return iter ? arrayFrom(iter) : [];
37546
- }
37547
- function getInternalMap() {
37548
- return cache;
37574
+ return cache == null ? void 0 : cache.entries();
37549
37575
  }
37550
37576
  }
37551
37577
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
@@ -42477,7 +42503,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42477
42503
  if (!moduleSourceFile)
42478
42504
  return { moduleSpecifiers: emptyArray, computedWithoutCache };
42479
42505
  computedWithoutCache = true;
42480
- modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host));
42506
+ modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.fileName, moduleSourceFile.originalFileName, host));
42481
42507
  const result = computeModuleSpecifiers(
42482
42508
  modulePaths,
42483
42509
  compilerOptions,
@@ -42491,7 +42517,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42491
42517
  return { moduleSpecifiers: result, computedWithoutCache };
42492
42518
  }
42493
42519
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
42494
- const info = getInfo(importingSourceFile.path, host);
42520
+ const info = getInfo(importingSourceFile.fileName, host);
42495
42521
  const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
42496
42522
  const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
42497
42523
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
@@ -42555,6 +42581,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
42555
42581
  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);
42556
42582
  }
42557
42583
  function getInfo(importingSourceFileName, host) {
42584
+ importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
42558
42585
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
42559
42586
  const sourceDirectory = getDirectoryPath(importingSourceFileName);
42560
42587
  return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
@@ -42589,7 +42616,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42589
42616
  if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
42590
42617
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
42591
42618
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
42592
- const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
42619
+ const sourceIsInternal = startsWith(info.getCanonicalFileName(sourceDirectory), projectDirectory);
42593
42620
  const targetIsInternal = startsWith(modulePath, projectDirectory);
42594
42621
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
42595
42622
  return maybeNonRelative;
@@ -42662,8 +42689,9 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
42662
42689
  });
42663
42690
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
42664
42691
  }
42665
- function getAllModulePaths(importingFilePath, importedFileName, host, preferences, options = {}) {
42692
+ function getAllModulePaths(importingFileName, importedFileName, host, preferences, options = {}) {
42666
42693
  var _a;
42694
+ const importingFilePath = toPath(importingFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42667
42695
  const importedFilePath = toPath(importedFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42668
42696
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
42669
42697
  if (cache) {
@@ -42671,7 +42699,7 @@ function getAllModulePaths(importingFilePath, importedFileName, host, preference
42671
42699
  if (cached == null ? void 0 : cached.modulePaths)
42672
42700
  return cached.modulePaths;
42673
42701
  }
42674
- const modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host);
42702
+ const modulePaths = getAllModulePathsWorker(importingFileName, importedFileName, host);
42675
42703
  if (cache) {
42676
42704
  cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
42677
42705
  }
@@ -42694,7 +42722,7 @@ function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42694
42722
  }
42695
42723
  );
42696
42724
  const sortedPaths = [];
42697
- for (let directory = getDirectoryPath(importingFileName); allFileNames.size !== 0; ) {
42725
+ for (let directory = getDirectoryPath(getCanonicalFileName(importingFileName)); allFileNames.size !== 0; ) {
42698
42726
  const directoryStart = ensureTrailingDirectorySeparator(directory);
42699
42727
  let pathsInDirectory;
42700
42728
  allFileNames.forEach(({ path, isRedirect, isInNodeModules }, fileName) => {
@@ -42715,7 +42743,10 @@ function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42715
42743
  directory = newDirectory;
42716
42744
  }
42717
42745
  if (allFileNames.size) {
42718
- const remainingPaths = arrayFrom(allFileNames.values());
42746
+ const remainingPaths = arrayFrom(
42747
+ allFileNames.entries(),
42748
+ ([fileName, { isRedirect, isInNodeModules }]) => ({ path: fileName, isRedirect, isInNodeModules })
42749
+ );
42719
42750
  if (remainingPaths.length > 1)
42720
42751
  remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
42721
42752
  sortedPaths.push(...remainingPaths);
@@ -42919,7 +42950,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42919
42950
  }
42920
42951
  const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
42921
42952
  const pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
42922
- if (!(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42953
+ if (!(startsWith(getCanonicalFileName(sourceDirectory), pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42923
42954
  return void 0;
42924
42955
  }
42925
42956
  const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
@@ -54214,7 +54245,12 @@ function createTypeChecker(host) {
54214
54245
  const checkType = type.checkType;
54215
54246
  const constraint = getLowerBoundOfKeyType(checkType);
54216
54247
  if (constraint !== checkType) {
54217
- return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54248
+ return getConditionalTypeInstantiation(
54249
+ type,
54250
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54251
+ /*forConstraint*/
54252
+ false
54253
+ );
54218
54254
  }
54219
54255
  }
54220
54256
  return type;
@@ -54566,7 +54602,12 @@ function createTypeChecker(host) {
54566
54602
  );
54567
54603
  const constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
54568
54604
  if (constraint && constraint !== type.checkType) {
54569
- const instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
54605
+ const instantiated = getConditionalTypeInstantiation(
54606
+ type,
54607
+ prependTypeMapping(type.root.checkType, constraint, type.mapper),
54608
+ /*forConstraint*/
54609
+ true
54610
+ );
54570
54611
  if (!(instantiated.flags & 131072 /* Never */)) {
54571
54612
  type.resolvedConstraintOfDistributive = instantiated;
54572
54613
  return instantiated;
@@ -57434,19 +57475,17 @@ function createTypeChecker(host) {
57434
57475
  return constraintType;
57435
57476
  }
57436
57477
  const keyTypes = [];
57437
- if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57438
- if (!isGenericIndexType(constraintType)) {
57439
- const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
57440
- forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
57441
- } else {
57478
+ if (isGenericIndexType(constraintType)) {
57479
+ if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57442
57480
  return getIndexTypeForGenericType(type, indexFlags);
57443
57481
  }
57482
+ forEachType(constraintType, addMemberForKeyType);
57483
+ } else if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
57484
+ const modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
57485
+ forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, !!(indexFlags & 1 /* StringsOnly */), addMemberForKeyType);
57444
57486
  } else {
57445
57487
  forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
57446
57488
  }
57447
- if (isGenericIndexType(constraintType)) {
57448
- forEachType(constraintType, addMemberForKeyType);
57449
- }
57450
57489
  const result = indexFlags & 2 /* NoIndexSignatures */ ? filterType(getUnionType(keyTypes), (t) => !(t.flags & (1 /* Any */ | 4 /* String */))) : getUnionType(keyTypes);
57451
57490
  if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
57452
57491
  return constraintType;
@@ -58131,7 +58170,7 @@ function createTypeChecker(host) {
58131
58170
  function isDeferredType(type, checkTuples) {
58132
58171
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
58133
58172
  }
58134
- function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
58173
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
58135
58174
  let result;
58136
58175
  let extraTypes;
58137
58176
  let tailCount = 0;
@@ -58177,7 +58216,7 @@ function createTypeChecker(host) {
58177
58216
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
58178
58217
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
58179
58218
  if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
58180
- if (checkType.flags & 1 /* Any */) {
58219
+ if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
58181
58220
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
58182
58221
  }
58183
58222
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -58287,7 +58326,9 @@ function createTypeChecker(host) {
58287
58326
  links.resolvedType = getConditionalType(
58288
58327
  root,
58289
58328
  /*mapper*/
58290
- void 0
58329
+ void 0,
58330
+ /*forConstraint*/
58331
+ false
58291
58332
  );
58292
58333
  if (outerTypeParameters) {
58293
58334
  root.instantiations = /* @__PURE__ */ new Map();
@@ -59142,17 +59183,17 @@ function createTypeChecker(host) {
59142
59183
  result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
59143
59184
  return result;
59144
59185
  }
59145
- function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
59186
+ function getConditionalTypeInstantiation(type, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
59146
59187
  const root = type.root;
59147
59188
  if (root.outerTypeParameters) {
59148
59189
  const typeArguments = map(root.outerTypeParameters, (t) => getMappedType(t, mapper));
59149
- const id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59190
+ const id = (forConstraint ? "C" : "") + getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
59150
59191
  let result = root.instantiations.get(id);
59151
59192
  if (!result) {
59152
59193
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
59153
59194
  const checkType = root.checkType;
59154
59195
  const distributionType = root.isDistributive ? getMappedType(checkType, newMapper) : void 0;
59155
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper)), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
59196
+ result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(getReducedType(distributionType), (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
59156
59197
  root.instantiations.set(id, result);
59157
59198
  }
59158
59199
  return result;
@@ -59240,7 +59281,14 @@ function createTypeChecker(host) {
59240
59281
  );
59241
59282
  }
59242
59283
  if (flags & 16777216 /* Conditional */) {
59243
- return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
59284
+ return getConditionalTypeInstantiation(
59285
+ type,
59286
+ combineTypeMappers(type.mapper, mapper),
59287
+ /*forConstraint*/
59288
+ false,
59289
+ aliasSymbol,
59290
+ aliasTypeArguments
59291
+ );
59244
59292
  }
59245
59293
  if (flags & 33554432 /* Substitution */) {
59246
59294
  const newBaseType = instantiateType(type.baseType, mapper);
@@ -60884,7 +60932,7 @@ function createTypeChecker(host) {
60884
60932
  return relation === comparableRelation ? someTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState) : eachTypeRelatedToType(source2, target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */), intersectionState);
60885
60933
  }
60886
60934
  if (target2.flags & 1048576 /* Union */) {
60887
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */));
60935
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source2), target2, reportErrors2 && !(source2.flags & 402784252 /* Primitive */) && !(target2.flags & 402784252 /* Primitive */), intersectionState);
60888
60936
  }
60889
60937
  if (target2.flags & 2097152 /* Intersection */) {
60890
60938
  return typeRelatedToEachType(source2, target2, reportErrors2, 2 /* Target */);
@@ -60929,7 +60977,8 @@ function createTypeChecker(host) {
60929
60977
  sourceType,
60930
60978
  target2,
60931
60979
  /*reportErrors*/
60932
- false
60980
+ false,
60981
+ 0 /* None */
60933
60982
  );
60934
60983
  if (!related) {
60935
60984
  return 0 /* False */;
@@ -60938,7 +60987,7 @@ function createTypeChecker(host) {
60938
60987
  }
60939
60988
  return result2;
60940
60989
  }
60941
- function typeRelatedToSomeType(source2, target2, reportErrors2) {
60990
+ function typeRelatedToSomeType(source2, target2, reportErrors2, intersectionState) {
60942
60991
  const targetTypes = target2.types;
60943
60992
  if (target2.flags & 1048576 /* Union */) {
60944
60993
  if (containsType(targetTypes, source2)) {
@@ -60956,7 +61005,10 @@ function createTypeChecker(host) {
60956
61005
  match,
60957
61006
  2 /* Target */,
60958
61007
  /*reportErrors*/
60959
- false
61008
+ false,
61009
+ /*headMessage*/
61010
+ void 0,
61011
+ intersectionState
60960
61012
  );
60961
61013
  if (related) {
60962
61014
  return related;
@@ -60969,7 +61021,10 @@ function createTypeChecker(host) {
60969
61021
  type,
60970
61022
  2 /* Target */,
60971
61023
  /*reportErrors*/
60972
- false
61024
+ false,
61025
+ /*headMessage*/
61026
+ void 0,
61027
+ intersectionState
60973
61028
  );
60974
61029
  if (related) {
60975
61030
  return related;
@@ -60983,7 +61038,10 @@ function createTypeChecker(host) {
60983
61038
  bestMatchingType,
60984
61039
  2 /* Target */,
60985
61040
  /*reportErrors*/
60986
- true
61041
+ true,
61042
+ /*headMessage*/
61043
+ void 0,
61044
+ intersectionState
60987
61045
  );
60988
61046
  }
60989
61047
  }
@@ -61781,13 +61839,6 @@ function createTypeChecker(host) {
61781
61839
  return result2;
61782
61840
  }
61783
61841
  }
61784
- } else {
61785
- const distributiveConstraint = hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61786
- if (distributiveConstraint) {
61787
- if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61788
- return result2;
61789
- }
61790
- }
61791
61842
  }
61792
61843
  const defaultConstraint = getDefaultConstraintOfConditionalType(source2);
61793
61844
  if (defaultConstraint) {
@@ -61795,6 +61846,13 @@ function createTypeChecker(host) {
61795
61846
  return result2;
61796
61847
  }
61797
61848
  }
61849
+ const distributiveConstraint = !(targetFlags & 16777216 /* Conditional */) && hasNonCircularBaseConstraint(source2) ? getConstraintOfDistributiveConditionalType(source2) : void 0;
61850
+ if (distributiveConstraint) {
61851
+ resetErrorInfo(saveErrorInfo);
61852
+ if (result2 = isRelatedTo(distributiveConstraint, target2, 1 /* Source */, reportErrors2)) {
61853
+ return result2;
61854
+ }
61855
+ }
61798
61856
  } else {
61799
61857
  if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target2) && isEmptyObjectType(source2)) {
61800
61858
  return -1 /* True */;
@@ -80666,10 +80724,11 @@ function createTypeChecker(host) {
80666
80724
  node
80667
80725
  ));
80668
80726
  if (sym) {
80727
+ const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(sym, 111551 /* Value */);
80669
80728
  markAliasReferenced(sym, id);
80670
80729
  if (getSymbolFlags(sym) & 111551 /* Value */) {
80671
80730
  checkExpressionCached(id);
80672
- if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) {
80731
+ if (!isIllegalExportDefaultInCJS && !(node.flags & 33554432 /* Ambient */) && compilerOptions.verbatimModuleSyntax && typeOnlyDeclaration) {
80673
80732
  error(
80674
80733
  id,
80675
80734
  node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
@@ -80683,6 +80742,33 @@ function createTypeChecker(host) {
80683
80742
  idText(id)
80684
80743
  );
80685
80744
  }
80745
+ if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & 111551 /* Value */)) {
80746
+ if (sym.flags & 2097152 /* Alias */ && resolveAlias(sym) !== unknownSymbol && getSymbolFlags(
80747
+ sym,
80748
+ /*excludeTypeOnlyMeanings*/
80749
+ false,
80750
+ /*excludeLocalMeanings*/
80751
+ true
80752
+ ) & 788968 /* Type */ && (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))) {
80753
+ error(
80754
+ id,
80755
+ node.isExportEquals ? Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
80756
+ idText(id),
80757
+ isolatedModulesLikeFlagName
80758
+ );
80759
+ } else if (typeOnlyDeclaration && getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node)) {
80760
+ addTypeOnlyDeclarationRelatedInfo(
80761
+ error(
80762
+ id,
80763
+ node.isExportEquals ? Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported : Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default,
80764
+ idText(id),
80765
+ isolatedModulesLikeFlagName
80766
+ ),
80767
+ typeOnlyDeclaration,
80768
+ idText(id)
80769
+ );
80770
+ }
80771
+ }
80686
80772
  } else {
80687
80773
  checkExpressionCached(id);
80688
80774
  }
@@ -82077,7 +82163,11 @@ function createTypeChecker(host) {
82077
82163
  const exportClause = node.exportClause;
82078
82164
  return !!exportClause && (isNamespaceExport(exportClause) || some(exportClause.elements, isValueAliasDeclaration));
82079
82165
  case 277 /* ExportAssignment */:
82080
- return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfDeclaration(node)) : true;
82166
+ return node.expression && node.expression.kind === 80 /* Identifier */ ? isAliasResolvedToValue(
82167
+ getSymbolOfDeclaration(node),
82168
+ /*excludeTypeOnlyValues*/
82169
+ true
82170
+ ) : true;
82081
82171
  }
82082
82172
  return false;
82083
82173
  }
@@ -82095,7 +82185,7 @@ function createTypeChecker(host) {
82095
82185
  }
82096
82186
  const target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
82097
82187
  if (target === unknownSymbol) {
82098
- return true;
82188
+ return !excludeTypeOnlyValues || !getTypeOnlyAliasDeclaration(symbol);
82099
82189
  }
82100
82190
  return !!(getSymbolFlags(
82101
82191
  symbol,
@@ -107928,8 +108018,8 @@ function transformDeclarations(context) {
107928
108018
  const specifier = getModuleSpecifier(
107929
108019
  options,
107930
108020
  currentSourceFile,
107931
- toPath(outputFilePath2, host.getCurrentDirectory(), host.getCanonicalFileName),
107932
- toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName),
108021
+ getNormalizedAbsolutePath(outputFilePath2, host.getCurrentDirectory()),
108022
+ getNormalizedAbsolutePath(declFileName, host.getCurrentDirectory()),
107933
108023
  host
107934
108024
  );
107935
108025
  if (!pathIsRelative(specifier)) {
@@ -115355,8 +115445,8 @@ function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensi
115355
115445
  }
115356
115446
  const baseName = getBaseNameOfFileName(fileOrDirectory);
115357
115447
  const fsQueryResult = {
115358
- fileExists: host.fileExists(fileOrDirectoryPath),
115359
- directoryExists: host.directoryExists(fileOrDirectoryPath)
115448
+ fileExists: host.fileExists(fileOrDirectory),
115449
+ directoryExists: host.directoryExists(fileOrDirectory)
115360
115450
  };
115361
115451
  if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
115362
115452
  clearCache();
@@ -115439,11 +115529,9 @@ function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, t
115439
115529
  });
115440
115530
  }
115441
115531
  function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
115442
- const missingFilePaths = program.getMissingFilePaths();
115443
- const newMissingFilePathMap = arrayToMap(missingFilePaths, identity, returnTrue);
115444
115532
  mutateMap(
115445
115533
  missingFileWatches,
115446
- newMissingFilePathMap,
115534
+ program.getMissingFilePaths(),
115447
115535
  {
115448
115536
  // Watch the missing files
115449
115537
  createNewValue: createMissingFileWatch,
@@ -116270,7 +116358,8 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
116270
116358
  return false;
116271
116359
  if (program.getSourceFiles().some(sourceFileNotUptoDate))
116272
116360
  return false;
116273
- if (program.getMissingFilePaths().some(fileExists))
116361
+ const missingPaths = program.getMissingFilePaths();
116362
+ if (missingPaths && forEachEntry(missingPaths, fileExists))
116274
116363
  return false;
116275
116364
  const currentOptions = program.getCompilerOptions();
116276
116365
  if (!compareDataObjects(currentOptions, newOptions))
@@ -116570,7 +116659,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116570
116659
  let redirectTargetsMap = createMultiMap();
116571
116660
  let usesUriStyleNodeCoreModules = false;
116572
116661
  const filesByName = /* @__PURE__ */ new Map();
116573
- let missingFilePaths;
116662
+ let missingFileNames = /* @__PURE__ */ new Map();
116574
116663
  const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? /* @__PURE__ */ new Map() : void 0;
116575
116664
  let resolvedProjectReferences;
116576
116665
  let projectReferenceRedirects;
@@ -116689,12 +116778,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116689
116778
  });
116690
116779
  }
116691
116780
  }
116692
- missingFilePaths = arrayFrom(mapDefinedIterator(filesByName.entries(), ([path, file]) => file === void 0 ? path : void 0));
116693
116781
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
116694
116782
  processingDefaultLibFiles = void 0;
116695
116783
  processingOtherFiles = void 0;
116696
116784
  }
116697
- Debug.assert(!!missingFilePaths);
116698
116785
  if (oldProgram && host.onReleaseOldSourceFile) {
116699
116786
  const oldSourceFiles = oldProgram.getSourceFiles();
116700
116787
  for (const oldSourceFile of oldSourceFiles) {
@@ -116739,8 +116826,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116739
116826
  getSourceFile,
116740
116827
  getSourceFileByPath,
116741
116828
  getSourceFiles: () => files,
116742
- getMissingFilePaths: () => missingFilePaths,
116743
- // TODO: GH#18217
116829
+ getMissingFilePaths: () => missingFileNames,
116744
116830
  getModuleResolutionCache: () => moduleResolutionCache,
116745
116831
  getFilesByNameMap: () => filesByName,
116746
116832
  getCompilerOptions: () => options,
@@ -117167,7 +117253,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117167
117253
  const newSourceFiles = [];
117168
117254
  const modifiedSourceFiles = [];
117169
117255
  structureIsReused = 2 /* Completely */;
117170
- if (oldProgram.getMissingFilePaths().some((missingFilePath) => host.fileExists(missingFilePath))) {
117256
+ if (forEachEntry(oldProgram.getMissingFilePaths(), (missingFilePath) => host.fileExists(missingFilePath))) {
117171
117257
  return 0 /* Not */;
117172
117258
  }
117173
117259
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -117307,7 +117393,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117307
117393
  if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
117308
117394
  return 1 /* SafeModules */;
117309
117395
  }
117310
- missingFilePaths = oldProgram.getMissingFilePaths();
117396
+ missingFileNames = oldProgram.getMissingFilePaths();
117311
117397
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
117312
117398
  for (const newSourceFile of newSourceFiles) {
117313
117399
  filesByName.set(newSourceFile.path, newSourceFile);
@@ -117364,7 +117450,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117364
117450
  const path = toPath3(f);
117365
117451
  if (getSourceFileByPath(path))
117366
117452
  return true;
117367
- if (contains(missingFilePaths, path))
117453
+ if (missingFileNames.has(path))
117368
117454
  return false;
117369
117455
  return host.fileExists(f);
117370
117456
  },
@@ -118176,6 +118262,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118176
118262
  addFileToFilesByName(
118177
118263
  file2,
118178
118264
  path,
118265
+ fileName,
118179
118266
  /*redirectedPath*/
118180
118267
  void 0
118181
118268
  );
@@ -118248,7 +118335,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118248
118335
  if (fileFromPackageId) {
118249
118336
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
118250
118337
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
118251
- addFileToFilesByName(dupFile, path, redirectedPath);
118338
+ addFileToFilesByName(dupFile, path, fileName, redirectedPath);
118252
118339
  addFileIncludeReason(dupFile, reason);
118253
118340
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118254
118341
  processingOtherFiles.push(dupFile);
@@ -118258,7 +118345,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118258
118345
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118259
118346
  }
118260
118347
  }
118261
- addFileToFilesByName(file, path, redirectedPath);
118348
+ addFileToFilesByName(file, path, fileName, redirectedPath);
118262
118349
  if (file) {
118263
118350
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
118264
118351
  file.fileName = fileName;
@@ -118298,14 +118385,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118298
118385
  if (file)
118299
118386
  fileReasons.add(file.path, reason);
118300
118387
  }
118301
- function addFileToFilesByName(file, path, redirectedPath) {
118388
+ function addFileToFilesByName(file, path, fileName, redirectedPath) {
118302
118389
  if (redirectedPath) {
118303
- filesByName.set(redirectedPath, file);
118304
- filesByName.set(path, file || false);
118390
+ updateFilesByNameMap(fileName, redirectedPath, file);
118391
+ updateFilesByNameMap(fileName, path, file || false);
118305
118392
  } else {
118306
- filesByName.set(path, file);
118393
+ updateFilesByNameMap(fileName, path, file);
118307
118394
  }
118308
118395
  }
118396
+ function updateFilesByNameMap(fileName, path, file) {
118397
+ filesByName.set(path, file);
118398
+ if (file !== void 0)
118399
+ missingFileNames.delete(path);
118400
+ else
118401
+ missingFileNames.set(path, fileName);
118402
+ }
118309
118403
  function getProjectReferenceRedirect(fileName) {
118310
118404
  const referencedProject = getProjectReferenceRedirectProject(fileName);
118311
118405
  return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
@@ -118626,6 +118720,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118626
118720
  /*file*/
118627
118721
  void 0,
118628
118722
  sourceFilePath,
118723
+ refPath,
118629
118724
  /*redirectedPath*/
118630
118725
  void 0
118631
118726
  );
@@ -118637,6 +118732,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118637
118732
  addFileToFilesByName(
118638
118733
  sourceFile,
118639
118734
  sourceFilePath,
118735
+ refPath,
118640
118736
  /*redirectedPath*/
118641
118737
  void 0
118642
118738
  );
@@ -118646,6 +118742,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118646
118742
  addFileToFilesByName(
118647
118743
  sourceFile,
118648
118744
  sourceFilePath,
118745
+ refPath,
118649
118746
  /*redirectedPath*/
118650
118747
  void 0
118651
118748
  );
@@ -122147,7 +122244,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122147
122244
  const watcher = {
122148
122245
  watcher: canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
122149
122246
  cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
122150
- invalidateAffectingFileWatcher(locationToWatch, moduleResolutionCache.getPackageJsonInfoCache().getInternalMap());
122247
+ invalidateAffectingFileWatcher(locationToWatch, moduleResolutionCache.getPackageJsonInfoCache());
122151
122248
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122152
122249
  }) : noopFileWatcher,
122153
122250
  resolutions: isSymlink ? 0 : resolutions,
@@ -122187,7 +122284,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122187
122284
  if (watcher == null ? void 0 : watcher.files)
122188
122285
  (affectingPathChecksForFile ?? (affectingPathChecksForFile = /* @__PURE__ */ new Set())).add(path);
122189
122286
  (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
122190
- packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
122287
+ packageJsonMap.deletePackageJsonInfo(path);
122191
122288
  }
122192
122289
  function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
122193
122290
  const program = resolutionHost.getCurrentProgram();
@@ -122372,9 +122469,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122372
122469
  resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
122373
122470
  }
122374
122471
  function invalidatePackageJsonMap() {
122375
- const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
122472
+ const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().entries();
122376
122473
  if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
122377
- packageJsonMap.forEach((_value, path) => isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : void 0);
122474
+ for (const key of packageJsonMap) {
122475
+ const path = resolutionHost.toPath(key[0]);
122476
+ if (isInvalidatedFailedLookup(path)) {
122477
+ moduleResolutionCache.getPackageJsonInfoCache().deletePackageJsonInfo(key[0]);
122478
+ }
122479
+ }
122378
122480
  }
122379
122481
  }
122380
122482
  function invalidateResolutionsOfFailedLookupLocations() {
@@ -123391,7 +123493,11 @@ function createWatchProgram(host) {
123391
123493
  const oldProgram = getCurrentProgram();
123392
123494
  builderProgram = createProgram2(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
123393
123495
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
123394
- updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()), watchMissingFilePath);
123496
+ updateMissingFilePathsWatch(
123497
+ builderProgram.getProgram(),
123498
+ missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()),
123499
+ watchMissingFilePath
123500
+ );
123395
123501
  if (needsUpdateInTypeRootWatch) {
123396
123502
  resolutionCache.updateTypeRootsWatch();
123397
123503
  }
@@ -123684,8 +123790,15 @@ function createWatchProgram(host) {
123684
123790
  cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
123685
123791
  }
123686
123792
  }
123687
- function watchMissingFilePath(missingFilePath) {
123688
- return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, 500 /* Medium */, watchOptions, WatchType.MissingFile);
123793
+ function watchMissingFilePath(missingFilePath, missingFileName) {
123794
+ return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(
123795
+ missingFilePath,
123796
+ missingFileName,
123797
+ onMissingFileChange,
123798
+ 500 /* Medium */,
123799
+ watchOptions,
123800
+ WatchType.MissingFile
123801
+ );
123689
123802
  }
123690
123803
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
123691
123804
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
@@ -124160,6 +124273,7 @@ function createStateBuildOrder(state) {
124160
124273
  mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124161
124274
  mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124162
124275
  mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124276
+ mutateMapSkippingNewValues(state.lastCachedPackageJsonLookups, currentProjects, noopOnDelete);
124163
124277
  if (state.watch) {
124164
124278
  mutateMapSkippingNewValues(
124165
124279
  state.allWatchedConfigFiles,
@@ -124408,7 +124522,7 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124408
124522
  return withProgramOrUndefined(action) || emptyArray;
124409
124523
  }
124410
124524
  function createProgram2() {
124411
- var _a, _b;
124525
+ var _a, _b, _c;
124412
124526
  Debug.assert(program === void 0);
124413
124527
  if (state.options.dry) {
124414
124528
  reportStatus(state, Diagnostics.A_non_dry_build_would_build_project_0, project);
@@ -124437,12 +124551,16 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124437
124551
  config.projectReferences
124438
124552
  );
124439
124553
  if (state.watch) {
124554
+ const entries = (_c = state.moduleResolutionCache) == null ? void 0 : _c.getPackageJsonInfoCache().entries();
124440
124555
  state.lastCachedPackageJsonLookups.set(
124441
124556
  projectPath,
124442
- state.moduleResolutionCache && map(
124443
- state.moduleResolutionCache.getPackageJsonInfoCache().entries(),
124444
- ([path, data]) => [state.host.realpath && data ? toPath2(state, state.host.realpath(path)) : path, data]
124445
- )
124557
+ entries && new Map(arrayFrom(
124558
+ entries,
124559
+ ([path, data]) => {
124560
+ path = state.host.realpath && data ? state.host.realpath(path) : path;
124561
+ return [toPath2(state, path), path];
124562
+ }
124563
+ ))
124446
124564
  );
124447
124565
  state.builderPrograms.set(projectPath, program);
124448
124566
  }
@@ -125175,9 +125293,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
125175
125293
  const extendedConfigStatus = forEach(project.options.configFile.extendedSourceFiles || emptyArray, (configFile) => checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName));
125176
125294
  if (extendedConfigStatus)
125177
125295
  return extendedConfigStatus;
125178
- const dependentPackageFileStatus = forEach(
125179
- state.lastCachedPackageJsonLookups.get(resolvedPath) || emptyArray,
125180
- ([path]) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125296
+ const packageJsonLookups = state.lastCachedPackageJsonLookups.get(resolvedPath);
125297
+ const dependentPackageFileStatus = packageJsonLookups && forEachEntry(
125298
+ packageJsonLookups,
125299
+ (path) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125181
125300
  );
125182
125301
  if (dependentPackageFileStatus)
125183
125302
  return dependentPackageFileStatus;
@@ -125588,9 +125707,9 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) {
125588
125707
  getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath),
125589
125708
  new Map(state.lastCachedPackageJsonLookups.get(resolvedPath)),
125590
125709
  {
125591
- createNewValue: (path, _input) => watchFile(
125710
+ createNewValue: (_path, input) => watchFile(
125592
125711
  state,
125593
- path,
125712
+ input,
125594
125713
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
125595
125714
  2e3 /* High */,
125596
125715
  parsed == null ? void 0 : parsed.watchOptions,