@typescript-deploys/pr-build 5.4.0-pr-56552-6 → 5.4.0-pr-56515-12

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.20231127`;
21
+ var version = `${versionMajorMinor}.0-insiders.20231128`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3671,6 +3671,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
3671
3671
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
3672
3672
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
3673
3673
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
3674
+ TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
3674
3675
  TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
3675
3676
  return TypeFlags2;
3676
3677
  })(TypeFlags || {});
@@ -3717,6 +3718,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
3717
3718
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
3718
3719
  ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
3719
3720
  ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
3721
+ ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
3720
3722
  return ObjectFlags3;
3721
3723
  })(ObjectFlags || {});
3722
3724
  var SignatureFlags = /* @__PURE__ */ ((SignatureFlags4) => {
@@ -15951,19 +15953,19 @@ function clearMap(map2, onDeleteValue) {
15951
15953
  function mutateMapSkippingNewValues(map2, newMap, options) {
15952
15954
  const { onDeleteValue, onExistingValue } = options;
15953
15955
  map2.forEach((existingValue, key) => {
15954
- const valueInNewMap = newMap.get(key);
15955
- if (valueInNewMap === void 0) {
15956
+ var _a;
15957
+ if (!(newMap == null ? void 0 : newMap.has(key))) {
15956
15958
  map2.delete(key);
15957
15959
  onDeleteValue(existingValue, key);
15958
15960
  } else if (onExistingValue) {
15959
- onExistingValue(existingValue, valueInNewMap, key);
15961
+ onExistingValue(existingValue, (_a = newMap.get) == null ? void 0 : _a.call(newMap, key), key);
15960
15962
  }
15961
15963
  });
15962
15964
  }
15963
15965
  function mutateMap(map2, newMap, options) {
15964
15966
  mutateMapSkippingNewValues(map2, newMap, options);
15965
15967
  const { createNewValue } = options;
15966
- newMap.forEach((valueInNewMap, key) => {
15968
+ newMap == null ? void 0 : newMap.forEach((valueInNewMap, key) => {
15967
15969
  if (!map2.has(key)) {
15968
15970
  map2.set(key, createNewValue(key, valueInNewMap));
15969
15971
  }
@@ -31214,8 +31216,9 @@ var Parser;
31214
31216
  function nextTokenIsStringLiteral() {
31215
31217
  return nextToken() === 11 /* StringLiteral */;
31216
31218
  }
31217
- function nextTokenIsFromKeyword() {
31218
- return nextToken() === 161 /* FromKeyword */;
31219
+ function nextTokenIsFromKeywordOrEqualsToken() {
31220
+ nextToken();
31221
+ return token() === 161 /* FromKeyword */ || token() === 64 /* EqualsToken */;
31219
31222
  }
31220
31223
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
31221
31224
  nextToken();
@@ -31912,7 +31915,7 @@ var Parser;
31912
31915
  identifier = parseIdentifier();
31913
31916
  }
31914
31917
  let isTypeOnly = false;
31915
- if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31918
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeywordOrEqualsToken)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
31916
31919
  isTypeOnly = true;
31917
31920
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
31918
31921
  }
@@ -36783,34 +36786,39 @@ function specToDiagnostic(spec, disallowTrailingRecursion) {
36783
36786
  return [Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
36784
36787
  }
36785
36788
  }
36786
- function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, path, useCaseSensitiveFileNames2) {
36787
- const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude");
36789
+ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, basePath, useCaseSensitiveFileNames2) {
36790
+ const rawExcludeRegex = getRegularExpressionForWildcard(exclude, basePath, "exclude");
36788
36791
  const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames2 ? "" : "i");
36789
36792
  const wildcardDirectories = {};
36793
+ const wildCardKeyToPath = /* @__PURE__ */ new Map();
36790
36794
  if (include !== void 0) {
36791
36795
  const recursiveKeys = [];
36792
36796
  for (const file of include) {
36793
- const spec = normalizePath(combinePaths(path, file));
36797
+ const spec = normalizePath(combinePaths(basePath, file));
36794
36798
  if (excludeRegex && excludeRegex.test(spec)) {
36795
36799
  continue;
36796
36800
  }
36797
36801
  const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2);
36798
36802
  if (match) {
36799
- const { key, flags } = match;
36800
- const existingFlags = wildcardDirectories[key];
36803
+ const { key, path, flags } = match;
36804
+ const existingPath = wildCardKeyToPath.get(key);
36805
+ const existingFlags = existingPath !== void 0 ? wildcardDirectories[existingPath] : void 0;
36801
36806
  if (existingFlags === void 0 || existingFlags < flags) {
36802
- wildcardDirectories[key] = flags;
36807
+ wildcardDirectories[existingPath !== void 0 ? existingPath : path] = flags;
36808
+ if (existingPath === void 0)
36809
+ wildCardKeyToPath.set(key, path);
36803
36810
  if (flags === 1 /* Recursive */) {
36804
36811
  recursiveKeys.push(key);
36805
36812
  }
36806
36813
  }
36807
36814
  }
36808
36815
  }
36809
- for (const key in wildcardDirectories) {
36810
- if (hasProperty(wildcardDirectories, key)) {
36816
+ for (const path in wildcardDirectories) {
36817
+ if (hasProperty(wildcardDirectories, path)) {
36811
36818
  for (const recursiveKey of recursiveKeys) {
36812
- if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames2)) {
36813
- delete wildcardDirectories[key];
36819
+ const key = toCanonicalKey(path, useCaseSensitiveFileNames2);
36820
+ if (key !== recursiveKey && containsPath(recursiveKey, key, basePath, !useCaseSensitiveFileNames2)) {
36821
+ delete wildcardDirectories[path];
36814
36822
  }
36815
36823
  }
36816
36824
  }
@@ -36818,6 +36826,9 @@ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExclu
36818
36826
  }
36819
36827
  return wildcardDirectories;
36820
36828
  }
36829
+ function toCanonicalKey(path, useCaseSensitiveFileNames2) {
36830
+ return useCaseSensitiveFileNames2 ? path : toFileNameLowerCase(path);
36831
+ }
36821
36832
  function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36822
36833
  const match = wildcardDirectoryPattern.exec(spec);
36823
36834
  if (match) {
@@ -36825,13 +36836,16 @@ function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
36825
36836
  const starWildcardIndex = spec.indexOf("*");
36826
36837
  const lastDirectorySeperatorIndex = spec.lastIndexOf(directorySeparator);
36827
36838
  return {
36828
- key: useCaseSensitiveFileNames2 ? match[0] : toFileNameLowerCase(match[0]),
36839
+ key: toCanonicalKey(match[0], useCaseSensitiveFileNames2),
36840
+ path: match[0],
36829
36841
  flags: questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex || starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex ? 1 /* Recursive */ : 0 /* None */
36830
36842
  };
36831
36843
  }
36832
36844
  if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
36845
+ const path = removeTrailingDirectorySeparator(spec);
36833
36846
  return {
36834
- key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames2 ? spec : toFileNameLowerCase(spec)),
36847
+ key: toCanonicalKey(path, useCaseSensitiveFileNames2),
36848
+ path,
36835
36849
  flags: 1 /* Recursive */
36836
36850
  };
36837
36851
  }
@@ -37409,6 +37423,9 @@ function getAutomaticTypeDirectiveNames(options, host) {
37409
37423
  }
37410
37424
  return result;
37411
37425
  }
37426
+ function isPackageJsonInfo(entry) {
37427
+ return !!(entry == null ? void 0 : entry.contents);
37428
+ }
37412
37429
  function compilerOptionValueToString(value) {
37413
37430
  var _a;
37414
37431
  if (value === null || typeof value !== "object") {
@@ -37513,7 +37530,7 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
37513
37530
  }
37514
37531
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
37515
37532
  let cache;
37516
- return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, entries, getInternalMap };
37533
+ return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, getInternalMap };
37517
37534
  function getPackageJsonInfo2(packageJsonPath) {
37518
37535
  return cache == null ? void 0 : cache.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
37519
37536
  }
@@ -37523,10 +37540,6 @@ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
37523
37540
  function clear2() {
37524
37541
  cache = void 0;
37525
37542
  }
37526
- function entries() {
37527
- const iter = cache == null ? void 0 : cache.entries();
37528
- return iter ? arrayFrom(iter) : [];
37529
- }
37530
37543
  function getInternalMap() {
37531
37544
  return cache;
37532
37545
  }
@@ -38406,13 +38419,13 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
38406
38419
  }
38407
38420
  const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
38408
38421
  if (existing !== void 0) {
38409
- if (typeof existing !== "boolean") {
38422
+ if (isPackageJsonInfo(existing)) {
38410
38423
  if (traceEnabled)
38411
38424
  trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
38412
38425
  (_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
38413
38426
  return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
38414
38427
  } else {
38415
- if (existing && traceEnabled)
38428
+ if (existing.directoryExists && traceEnabled)
38416
38429
  trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
38417
38430
  (_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
38418
38431
  return void 0;
@@ -38434,7 +38447,7 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
38434
38447
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
38435
38448
  }
38436
38449
  if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
38437
- state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists);
38450
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, { packageDirectory, directoryExists });
38438
38451
  (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
38439
38452
  }
38440
38453
  }
@@ -41765,7 +41778,7 @@ function createBinder() {
41765
41778
  }
41766
41779
  function bindSpecialPropertyAssignment(node) {
41767
41780
  var _a;
41768
- const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer) || lookupSymbolForPropertyAccess(node.left.expression, container);
41781
+ const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer);
41769
41782
  if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) {
41770
41783
  return;
41771
41784
  }
@@ -41863,7 +41876,7 @@ function createBinder() {
41863
41876
  return isBinaryExpression(propertyAccess.parent) ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 312 /* SourceFile */ : propertyAccess.parent.parent.kind === 312 /* SourceFile */;
41864
41877
  }
41865
41878
  function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
41866
- let namespaceSymbol = lookupSymbolForPropertyAccess(name, blockScopeContainer) || lookupSymbolForPropertyAccess(name, container);
41879
+ let namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
41867
41880
  const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
41868
41881
  namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
41869
41882
  bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
@@ -42407,7 +42420,7 @@ function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourc
42407
42420
  }
42408
42421
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, preferences, userPreferences, options = {}) {
42409
42422
  const info = getInfo(importingSourceFileName, host);
42410
- const modulePaths = getAllModulePaths(importingSourceFileName, toFileName2, host, userPreferences, options);
42423
+ const modulePaths = getAllModulePaths(info, toFileName2, host, userPreferences, options);
42411
42424
  return firstDefined(modulePaths, (modulePath) => tryGetModuleNameAsNodeModule(
42412
42425
  modulePath,
42413
42426
  info,
@@ -42460,7 +42473,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42460
42473
  if (!moduleSourceFile)
42461
42474
  return { moduleSpecifiers: emptyArray, computedWithoutCache };
42462
42475
  computedWithoutCache = true;
42463
- modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host));
42476
+ modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host));
42464
42477
  const result = computeModuleSpecifiers(
42465
42478
  modulePaths,
42466
42479
  compilerOptions,
@@ -42474,7 +42487,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
42474
42487
  return { moduleSpecifiers: result, computedWithoutCache };
42475
42488
  }
42476
42489
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
42477
- const info = getInfo(importingSourceFile.path, host);
42490
+ const info = getInfo(importingSourceFile.fileName, host);
42478
42491
  const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
42479
42492
  const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
42480
42493
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
@@ -42538,16 +42551,22 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
42538
42551
  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
42552
  }
42540
42553
  function getInfo(importingSourceFileName, host) {
42554
+ importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
42541
42555
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
42542
42556
  const sourceDirectory = getDirectoryPath(importingSourceFileName);
42543
- return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
42557
+ return {
42558
+ getCanonicalFileName,
42559
+ importingSourceFileName,
42560
+ sourceDirectory,
42561
+ canonicalSourceDirectory: getCanonicalFileName(sourceDirectory)
42562
+ };
42544
42563
  }
42545
42564
  function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }, pathsOnly) {
42546
42565
  const { baseUrl, paths, rootDirs } = compilerOptions;
42547
42566
  if (pathsOnly && !paths) {
42548
42567
  return void 0;
42549
42568
  }
42550
- const { sourceDirectory, getCanonicalFileName } = info;
42569
+ const { sourceDirectory, canonicalSourceDirectory, getCanonicalFileName } = info;
42551
42570
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
42552
42571
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
42553
42572
  if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
@@ -42572,7 +42591,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
42572
42591
  if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
42573
42592
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
42574
42593
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
42575
- const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
42594
+ const sourceIsInternal = startsWith(canonicalSourceDirectory, projectDirectory);
42576
42595
  const targetIsInternal = startsWith(modulePath, projectDirectory);
42577
42596
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
42578
42597
  return maybeNonRelative;
@@ -42645,8 +42664,9 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
42645
42664
  });
42646
42665
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
42647
42666
  }
42648
- function getAllModulePaths(importingFilePath, importedFileName, host, preferences, options = {}) {
42667
+ function getAllModulePaths(info, importedFileName, host, preferences, options = {}) {
42649
42668
  var _a;
42669
+ const importingFilePath = toPath(info.importingSourceFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42650
42670
  const importedFilePath = toPath(importedFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
42651
42671
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
42652
42672
  if (cache) {
@@ -42654,30 +42674,29 @@ function getAllModulePaths(importingFilePath, importedFileName, host, preference
42654
42674
  if (cached == null ? void 0 : cached.modulePaths)
42655
42675
  return cached.modulePaths;
42656
42676
  }
42657
- const modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host);
42677
+ const modulePaths = getAllModulePathsWorker(info, importedFileName, host);
42658
42678
  if (cache) {
42659
42679
  cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
42660
42680
  }
42661
42681
  return modulePaths;
42662
42682
  }
42663
- function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42664
- const getCanonicalFileName = hostGetCanonicalFileName(host);
42683
+ function getAllModulePathsWorker(info, importedFileName, host) {
42665
42684
  const allFileNames = /* @__PURE__ */ new Map();
42666
42685
  let importedFileFromNodeModules = false;
42667
42686
  forEachFileNameOfModule(
42668
- importingFileName,
42687
+ info.importingSourceFileName,
42669
42688
  importedFileName,
42670
42689
  host,
42671
42690
  /*preferSymlinks*/
42672
42691
  true,
42673
42692
  (path, isRedirect) => {
42674
42693
  const isInNodeModules = pathContainsNodeModules(path);
42675
- allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect, isInNodeModules });
42694
+ allFileNames.set(path, { path: info.getCanonicalFileName(path), isRedirect, isInNodeModules });
42676
42695
  importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
42677
42696
  }
42678
42697
  );
42679
42698
  const sortedPaths = [];
42680
- for (let directory = getDirectoryPath(importingFileName); allFileNames.size !== 0; ) {
42699
+ for (let directory = info.canonicalSourceDirectory; allFileNames.size !== 0; ) {
42681
42700
  const directoryStart = ensureTrailingDirectorySeparator(directory);
42682
42701
  let pathsInDirectory;
42683
42702
  allFileNames.forEach(({ path, isRedirect, isInNodeModules }, fileName) => {
@@ -42698,7 +42717,10 @@ function getAllModulePathsWorker(importingFileName, importedFileName, host) {
42698
42717
  directory = newDirectory;
42699
42718
  }
42700
42719
  if (allFileNames.size) {
42701
- const remainingPaths = arrayFrom(allFileNames.values());
42720
+ const remainingPaths = arrayFrom(
42721
+ allFileNames.entries(),
42722
+ ([fileName, { isRedirect, isInNodeModules }]) => ({ path: fileName, isRedirect, isInNodeModules })
42723
+ );
42702
42724
  if (remainingPaths.length > 1)
42703
42725
  remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
42704
42726
  sortedPaths.push(...remainingPaths);
@@ -42858,7 +42880,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
42858
42880
  }
42859
42881
  return processEnding(shortest, allowedEndings, compilerOptions);
42860
42882
  }
42861
- function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
42883
+ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, canonicalSourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
42862
42884
  if (!host.fileExists || !host.readFile) {
42863
42885
  return void 0;
42864
42886
  }
@@ -42902,7 +42924,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42902
42924
  }
42903
42925
  const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
42904
42926
  const pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
42905
- if (!(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42927
+ if (!(startsWith(canonicalSourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
42906
42928
  return void 0;
42907
42929
  }
42908
42930
  const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
@@ -42915,7 +42937,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
42915
42937
  let moduleFileToTry = path;
42916
42938
  let maybeBlockedByTypesVersions = false;
42917
42939
  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)) {
42940
+ if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
42919
42941
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
42920
42942
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
42921
42943
  if (getResolvePackageJsonExports(options)) {
@@ -54502,9 +54524,13 @@ function createTypeChecker(host) {
54502
54524
  function getConstraintOfTypeParameter(typeParameter) {
54503
54525
  return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : void 0;
54504
54526
  }
54527
+ function isConstMappedType(type, depth) {
54528
+ const typeVariable = getHomomorphicTypeVariable(type);
54529
+ return !!typeVariable && isConstTypeVariable(typeVariable, depth);
54530
+ }
54505
54531
  function isConstTypeVariable(type, depth = 0) {
54506
54532
  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));
54533
+ 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
54534
  }
54509
54535
  function getConstraintOfIndexedAccess(type) {
54510
54536
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -56901,6 +56927,8 @@ function createTypeChecker(host) {
56901
56927
  includes |= flags & 473694207 /* IncludesMask */;
56902
56928
  if (flags & 465829888 /* Instantiable */)
56903
56929
  includes |= 33554432 /* IncludesInstantiable */;
56930
+ if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
56931
+ includes |= 268435456 /* IncludesConstrainedTypeVariable */;
56904
56932
  if (type === wildcardType)
56905
56933
  includes |= 8388608 /* IncludesWildcard */;
56906
56934
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
@@ -57005,6 +57033,41 @@ function createTypeChecker(host) {
57005
57033
  }
57006
57034
  }
57007
57035
  }
57036
+ function removeConstrainedTypeVariables(types) {
57037
+ const typeVariables = [];
57038
+ for (const type of types) {
57039
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
57040
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
57041
+ pushIfUnique(typeVariables, type.types[index]);
57042
+ }
57043
+ }
57044
+ for (const typeVariable of typeVariables) {
57045
+ const primitives = [];
57046
+ for (const type of types) {
57047
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
57048
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
57049
+ if (type.types[index] === typeVariable) {
57050
+ insertType(primitives, type.types[1 - index]);
57051
+ }
57052
+ }
57053
+ }
57054
+ const constraint = getBaseConstraintOfType(typeVariable);
57055
+ if (everyType(constraint, (t) => containsType(primitives, t))) {
57056
+ let i = types.length;
57057
+ while (i > 0) {
57058
+ i--;
57059
+ const type = types[i];
57060
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
57061
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
57062
+ if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
57063
+ orderedRemoveItemAt(types, i);
57064
+ }
57065
+ }
57066
+ }
57067
+ insertType(types, typeVariable);
57068
+ }
57069
+ }
57070
+ }
57008
57071
  function isNamedUnionType(type) {
57009
57072
  return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
57010
57073
  }
@@ -57070,6 +57133,9 @@ function createTypeChecker(host) {
57070
57133
  if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
57071
57134
  removeStringLiteralsMatchedByTemplateLiterals(typeSet);
57072
57135
  }
57136
+ if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
57137
+ removeConstrainedTypeVariables(typeSet);
57138
+ }
57073
57139
  if (unionReduction === 2 /* Subtype */) {
57074
57140
  typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
57075
57141
  if (!typeSet) {
@@ -57282,9 +57348,9 @@ function createTypeChecker(host) {
57282
57348
  types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
57283
57349
  return true;
57284
57350
  }
57285
- function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
57351
+ function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
57286
57352
  const result = createType(2097152 /* Intersection */);
57287
- result.objectFlags = getPropagatingFlagsOfTypes(
57353
+ result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
57288
57354
  types,
57289
57355
  /*excludeKinds*/
57290
57356
  98304 /* Nullable */
@@ -57298,6 +57364,7 @@ function createTypeChecker(host) {
57298
57364
  const typeMembershipMap = /* @__PURE__ */ new Map();
57299
57365
  const includes = addTypesToIntersection(typeMembershipMap, 0, types);
57300
57366
  const typeSet = arrayFrom(typeMembershipMap.values());
57367
+ let objectFlags = 0 /* None */;
57301
57368
  if (includes & 131072 /* Never */) {
57302
57369
  return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
57303
57370
  }
@@ -57326,6 +57393,25 @@ function createTypeChecker(host) {
57326
57393
  if (typeSet.length === 1) {
57327
57394
  return typeSet[0];
57328
57395
  }
57396
+ if (typeSet.length === 2) {
57397
+ const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
57398
+ const typeVariable = typeSet[typeVarIndex];
57399
+ const primitiveType = typeSet[1 - typeVarIndex];
57400
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
57401
+ const constraint = getBaseConstraintOfType(typeVariable);
57402
+ if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
57403
+ if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
57404
+ return typeVariable;
57405
+ }
57406
+ if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
57407
+ if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
57408
+ return neverType;
57409
+ }
57410
+ }
57411
+ objectFlags = 67108864 /* IsConstrainedTypeVariable */;
57412
+ }
57413
+ }
57414
+ }
57329
57415
  const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
57330
57416
  let result = intersectionTypes.get(id);
57331
57417
  if (!result) {
@@ -57348,7 +57434,7 @@ function createTypeChecker(host) {
57348
57434
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
57349
57435
  }
57350
57436
  } else {
57351
- result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
57437
+ result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
57352
57438
  }
57353
57439
  intersectionTypes.set(id, result);
57354
57440
  }
@@ -66877,14 +66963,15 @@ function createTypeChecker(host) {
66877
66963
  if (declaration) {
66878
66964
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
66879
66965
  const parent = declaration.parent.parent;
66880
- if (parent.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(declaration) & 6 /* Constant */ || parent.kind === 169 /* Parameter */) {
66966
+ const rootDeclaration = getRootDeclaration(parent);
66967
+ if (rootDeclaration.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(rootDeclaration) & 6 /* Constant */ || rootDeclaration.kind === 169 /* Parameter */) {
66881
66968
  const links = getNodeLinks(parent);
66882
66969
  if (!(links.flags & 4194304 /* InCheckIdentifier */)) {
66883
66970
  links.flags |= 4194304 /* InCheckIdentifier */;
66884
66971
  const parentType = getTypeForBindingElementParent(parent, 0 /* Normal */);
66885
66972
  const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
66886
66973
  links.flags &= ~4194304 /* InCheckIdentifier */;
66887
- if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(parent.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
66974
+ if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(rootDeclaration.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
66888
66975
  const pattern = declaration.parent;
66889
66976
  const narrowedType = getFlowTypeOfReference(
66890
66977
  pattern,
@@ -107971,8 +108058,8 @@ function transformDeclarations(context) {
107971
108058
  const specifier = getModuleSpecifier(
107972
108059
  options,
107973
108060
  currentSourceFile,
107974
- toPath(outputFilePath2, host.getCurrentDirectory(), host.getCanonicalFileName),
107975
- toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName),
108061
+ getNormalizedAbsolutePath(outputFilePath2, host.getCurrentDirectory()),
108062
+ getNormalizedAbsolutePath(declFileName, host.getCurrentDirectory()),
107976
108063
  host
107977
108064
  );
107978
108065
  if (!pathIsRelative(specifier)) {
@@ -115398,8 +115485,8 @@ function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensi
115398
115485
  }
115399
115486
  const baseName = getBaseNameOfFileName(fileOrDirectory);
115400
115487
  const fsQueryResult = {
115401
- fileExists: host.fileExists(fileOrDirectoryPath),
115402
- directoryExists: host.directoryExists(fileOrDirectoryPath)
115488
+ fileExists: host.fileExists(fileOrDirectory),
115489
+ directoryExists: host.directoryExists(fileOrDirectory)
115403
115490
  };
115404
115491
  if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
115405
115492
  clearCache();
@@ -115482,11 +115569,9 @@ function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, t
115482
115569
  });
115483
115570
  }
115484
115571
  function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
115485
- const missingFilePaths = program.getMissingFilePaths();
115486
- const newMissingFilePathMap = arrayToMap(missingFilePaths, identity, returnTrue);
115487
115572
  mutateMap(
115488
115573
  missingFileWatches,
115489
- newMissingFilePathMap,
115574
+ program.getMissingFilePaths(),
115490
115575
  {
115491
115576
  // Watch the missing files
115492
115577
  createNewValue: createMissingFileWatch,
@@ -115497,18 +115582,22 @@ function updateMissingFilePathsWatch(program, missingFileWatches, createMissingF
115497
115582
  );
115498
115583
  }
115499
115584
  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
- );
115585
+ if (wildcardDirectories) {
115586
+ mutateMap(
115587
+ existingWatchedForWildcards,
115588
+ new Map(Object.entries(wildcardDirectories)),
115589
+ {
115590
+ // Create new watch and recursive info
115591
+ createNewValue: createWildcardDirectoryWatcher,
115592
+ // Close existing watch thats not needed any more
115593
+ onDeleteValue: closeFileWatcherOf,
115594
+ // Close existing watch that doesnt match in the flags
115595
+ onExistingValue: updateWildcardDirectoryWatcher
115596
+ }
115597
+ );
115598
+ } else {
115599
+ clearMap(existingWatchedForWildcards, closeFileWatcherOf);
115600
+ }
115512
115601
  function createWildcardDirectoryWatcher(directory, flags) {
115513
115602
  return {
115514
115603
  watcher: watchDirectory(directory, flags),
@@ -116313,7 +116402,8 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
116313
116402
  return false;
116314
116403
  if (program.getSourceFiles().some(sourceFileNotUptoDate))
116315
116404
  return false;
116316
- if (program.getMissingFilePaths().some(fileExists))
116405
+ const missingPaths = program.getMissingFilePaths();
116406
+ if (missingPaths && forEachEntry(missingPaths, fileExists))
116317
116407
  return false;
116318
116408
  const currentOptions = program.getCompilerOptions();
116319
116409
  if (!compareDataObjects(currentOptions, newOptions))
@@ -116613,7 +116703,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116613
116703
  let redirectTargetsMap = createMultiMap();
116614
116704
  let usesUriStyleNodeCoreModules = false;
116615
116705
  const filesByName = /* @__PURE__ */ new Map();
116616
- let missingFilePaths;
116706
+ let missingFileNames = /* @__PURE__ */ new Map();
116617
116707
  const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? /* @__PURE__ */ new Map() : void 0;
116618
116708
  let resolvedProjectReferences;
116619
116709
  let projectReferenceRedirects;
@@ -116732,12 +116822,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116732
116822
  });
116733
116823
  }
116734
116824
  }
116735
- missingFilePaths = arrayFrom(mapDefinedIterator(filesByName.entries(), ([path, file]) => file === void 0 ? path : void 0));
116736
116825
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
116737
116826
  processingDefaultLibFiles = void 0;
116738
116827
  processingOtherFiles = void 0;
116739
116828
  }
116740
- Debug.assert(!!missingFilePaths);
116741
116829
  if (oldProgram && host.onReleaseOldSourceFile) {
116742
116830
  const oldSourceFiles = oldProgram.getSourceFiles();
116743
116831
  for (const oldSourceFile of oldSourceFiles) {
@@ -116782,8 +116870,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
116782
116870
  getSourceFile,
116783
116871
  getSourceFileByPath,
116784
116872
  getSourceFiles: () => files,
116785
- getMissingFilePaths: () => missingFilePaths,
116786
- // TODO: GH#18217
116873
+ getMissingFilePaths: () => missingFileNames,
116787
116874
  getModuleResolutionCache: () => moduleResolutionCache,
116788
116875
  getFilesByNameMap: () => filesByName,
116789
116876
  getCompilerOptions: () => options,
@@ -117210,7 +117297,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117210
117297
  const newSourceFiles = [];
117211
117298
  const modifiedSourceFiles = [];
117212
117299
  structureIsReused = 2 /* Completely */;
117213
- if (oldProgram.getMissingFilePaths().some((missingFilePath) => host.fileExists(missingFilePath))) {
117300
+ if (forEachEntry(oldProgram.getMissingFilePaths(), (missingFileName) => host.fileExists(missingFileName))) {
117214
117301
  return 0 /* Not */;
117215
117302
  }
117216
117303
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -117350,7 +117437,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117350
117437
  if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
117351
117438
  return 1 /* SafeModules */;
117352
117439
  }
117353
- missingFilePaths = oldProgram.getMissingFilePaths();
117440
+ missingFileNames = oldProgram.getMissingFilePaths();
117354
117441
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
117355
117442
  for (const newSourceFile of newSourceFiles) {
117356
117443
  filesByName.set(newSourceFile.path, newSourceFile);
@@ -117407,7 +117494,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
117407
117494
  const path = toPath3(f);
117408
117495
  if (getSourceFileByPath(path))
117409
117496
  return true;
117410
- if (contains(missingFilePaths, path))
117497
+ if (missingFileNames.has(path))
117411
117498
  return false;
117412
117499
  return host.fileExists(f);
117413
117500
  },
@@ -118219,6 +118306,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118219
118306
  addFileToFilesByName(
118220
118307
  file2,
118221
118308
  path,
118309
+ fileName,
118222
118310
  /*redirectedPath*/
118223
118311
  void 0
118224
118312
  );
@@ -118291,7 +118379,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118291
118379
  if (fileFromPackageId) {
118292
118380
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
118293
118381
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
118294
- addFileToFilesByName(dupFile, path, redirectedPath);
118382
+ addFileToFilesByName(dupFile, path, fileName, redirectedPath);
118295
118383
  addFileIncludeReason(dupFile, reason);
118296
118384
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118297
118385
  processingOtherFiles.push(dupFile);
@@ -118301,7 +118389,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118301
118389
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
118302
118390
  }
118303
118391
  }
118304
- addFileToFilesByName(file, path, redirectedPath);
118392
+ addFileToFilesByName(file, path, fileName, redirectedPath);
118305
118393
  if (file) {
118306
118394
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
118307
118395
  file.fileName = fileName;
@@ -118341,14 +118429,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118341
118429
  if (file)
118342
118430
  fileReasons.add(file.path, reason);
118343
118431
  }
118344
- function addFileToFilesByName(file, path, redirectedPath) {
118432
+ function addFileToFilesByName(file, path, fileName, redirectedPath) {
118345
118433
  if (redirectedPath) {
118346
- filesByName.set(redirectedPath, file);
118347
- filesByName.set(path, file || false);
118434
+ updateFilesByNameMap(fileName, redirectedPath, file);
118435
+ updateFilesByNameMap(fileName, path, file || false);
118348
118436
  } else {
118349
- filesByName.set(path, file);
118437
+ updateFilesByNameMap(fileName, path, file);
118350
118438
  }
118351
118439
  }
118440
+ function updateFilesByNameMap(fileName, path, file) {
118441
+ filesByName.set(path, file);
118442
+ if (file !== void 0)
118443
+ missingFileNames.delete(path);
118444
+ else
118445
+ missingFileNames.set(path, fileName);
118446
+ }
118352
118447
  function getProjectReferenceRedirect(fileName) {
118353
118448
  const referencedProject = getProjectReferenceRedirectProject(fileName);
118354
118449
  return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
@@ -118669,6 +118764,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118669
118764
  /*file*/
118670
118765
  void 0,
118671
118766
  sourceFilePath,
118767
+ refPath,
118672
118768
  /*redirectedPath*/
118673
118769
  void 0
118674
118770
  );
@@ -118680,6 +118776,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118680
118776
  addFileToFilesByName(
118681
118777
  sourceFile,
118682
118778
  sourceFilePath,
118779
+ refPath,
118683
118780
  /*redirectedPath*/
118684
118781
  void 0
118685
118782
  );
@@ -118689,6 +118786,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
118689
118786
  addFileToFilesByName(
118690
118787
  sourceFile,
118691
118788
  sourceFilePath,
118789
+ refPath,
118692
118790
  /*redirectedPath*/
118693
118791
  void 0
118694
118792
  );
@@ -122474,8 +122572,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122474
122572
  function closeTypeRootsWatch() {
122475
122573
  clearMap(typeRootsWatches, closeFileWatcher);
122476
122574
  }
122477
- function createTypeRootsWatch(typeRootPath, typeRoot) {
122478
- return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
122575
+ function createTypeRootsWatch(typeRoot) {
122576
+ return canWatchTypeRootPath(typeRoot) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
122479
122577
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
122480
122578
  if (cachedDirectoryStructureHost) {
122481
122579
  cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
@@ -122484,7 +122582,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122484
122582
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
122485
122583
  const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
122486
122584
  typeRoot,
122487
- typeRootPath,
122585
+ resolutionHost.toPath(typeRoot),
122488
122586
  rootPath,
122489
122587
  rootPathComponents,
122490
122588
  getCurrentDirectory,
@@ -122505,7 +122603,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
122505
122603
  if (typeRoots) {
122506
122604
  mutateMap(
122507
122605
  typeRootsWatches,
122508
- arrayToMap(typeRoots, (tr) => resolutionHost.toPath(tr)),
122606
+ new Set(typeRoots),
122509
122607
  {
122510
122608
  createNewValue: createTypeRootsWatch,
122511
122609
  onDeleteValue: closeFileWatcher
@@ -123434,7 +123532,11 @@ function createWatchProgram(host) {
123434
123532
  const oldProgram = getCurrentProgram();
123435
123533
  builderProgram = createProgram2(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
123436
123534
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
123437
- updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()), watchMissingFilePath);
123535
+ updateMissingFilePathsWatch(
123536
+ builderProgram.getProgram(),
123537
+ missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()),
123538
+ watchMissingFilePath
123539
+ );
123438
123540
  if (needsUpdateInTypeRootWatch) {
123439
123541
  resolutionCache.updateTypeRootsWatch();
123440
123542
  }
@@ -123727,8 +123829,15 @@ function createWatchProgram(host) {
123727
123829
  cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
123728
123830
  }
123729
123831
  }
123730
- function watchMissingFilePath(missingFilePath) {
123731
- return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, 500 /* Medium */, watchOptions, WatchType.MissingFile);
123832
+ function watchMissingFilePath(missingFilePath, missingFileName) {
123833
+ return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(
123834
+ missingFilePath,
123835
+ missingFileName,
123836
+ onMissingFileChange,
123837
+ 500 /* Medium */,
123838
+ watchOptions,
123839
+ WatchType.MissingFile
123840
+ );
123732
123841
  }
123733
123842
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
123734
123843
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
@@ -123740,15 +123849,11 @@ function createWatchProgram(host) {
123740
123849
  }
123741
123850
  }
123742
123851
  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
- }
123852
+ updateWatchingWildcardDirectories(
123853
+ watchedWildcardDirectories || (watchedWildcardDirectories = /* @__PURE__ */ new Map()),
123854
+ wildcardDirectories,
123855
+ watchWildcardDirectory
123856
+ );
123752
123857
  }
123753
123858
  function watchWildcardDirectory(directory, flags) {
123754
123859
  return watchDirectory(
@@ -123820,7 +123925,7 @@ function createWatchProgram(host) {
123820
123925
  );
123821
123926
  }
123822
123927
  function watchReferencedProject(configFileName2, configPath, commandLine) {
123823
- var _a, _b, _c, _d, _e;
123928
+ var _a, _b, _c, _d;
123824
123929
  commandLine.watcher || (commandLine.watcher = watchFile2(
123825
123930
  configFileName2,
123826
123931
  (_fileName, eventKind) => {
@@ -123835,55 +123940,50 @@ function createWatchProgram(host) {
123835
123940
  ((_a = commandLine.parsedCommandLine) == null ? void 0 : _a.watchOptions) || watchOptions,
123836
123941
  WatchType.ConfigFileOfReferencedProject
123837
123942
  ));
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
- }
123943
+ updateWatchingWildcardDirectories(
123944
+ commandLine.watchedDirectories || (commandLine.watchedDirectories = /* @__PURE__ */ new Map()),
123945
+ (_b = commandLine.parsedCommandLine) == null ? void 0 : _b.wildcardDirectories,
123946
+ (directory, flags) => {
123947
+ var _a2;
123948
+ return watchDirectory(
123949
+ directory,
123950
+ (fileOrDirectory) => {
123951
+ const fileOrDirectoryPath = toPath3(fileOrDirectory);
123952
+ if (cachedDirectoryStructureHost) {
123953
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
123954
+ }
123955
+ nextSourceFileVersion(fileOrDirectoryPath);
123956
+ const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
123957
+ if (!(config == null ? void 0 : config.parsedCommandLine))
123958
+ return;
123959
+ if (isIgnoredFileFromWildCardWatching({
123960
+ watchedDirPath: toPath3(directory),
123961
+ fileOrDirectory,
123962
+ fileOrDirectoryPath,
123963
+ configFileName: configFileName2,
123964
+ options: config.parsedCommandLine.options,
123965
+ program: config.parsedCommandLine.fileNames,
123966
+ currentDirectory,
123967
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
123968
+ writeLog,
123969
+ toPath: toPath3
123970
+ }))
123971
+ return;
123972
+ if (config.updateLevel !== 2 /* Full */) {
123973
+ config.updateLevel = 1 /* RootNamesAndUpdate */;
123974
+ scheduleProgramUpdate();
123975
+ }
123976
+ },
123977
+ flags,
123978
+ ((_a2 = commandLine.parsedCommandLine) == null ? void 0 : _a2.watchOptions) || watchOptions,
123979
+ WatchType.WildcardDirectoryOfReferencedProject
123980
+ );
123981
+ }
123982
+ );
123883
123983
  updateExtendedConfigFilesWatches(
123884
123984
  configPath,
123885
- (_d = commandLine.parsedCommandLine) == null ? void 0 : _d.options,
123886
- ((_e = commandLine.parsedCommandLine) == null ? void 0 : _e.watchOptions) || watchOptions,
123985
+ (_c = commandLine.parsedCommandLine) == null ? void 0 : _c.options,
123986
+ ((_d = commandLine.parsedCommandLine) == null ? void 0 : _d.watchOptions) || watchOptions,
123887
123987
  WatchType.ExtendedConfigOfReferencedProject
123888
123988
  );
123889
123989
  }
@@ -124189,9 +124289,9 @@ function getBuildOrder(state) {
124189
124289
  function createStateBuildOrder(state) {
124190
124290
  const buildOrder = createBuildOrder(state, state.rootNames.map((f) => resolveProjectName(state, f)));
124191
124291
  state.resolvedConfigFilePaths.clear();
124192
- const currentProjects = new Map(
124292
+ const currentProjects = new Set(
124193
124293
  getBuildOrderFromAnyBuildOrder(buildOrder).map(
124194
- (resolved) => [toResolvedConfigFilePath(state, resolved), true]
124294
+ (resolved) => toResolvedConfigFilePath(state, resolved)
124195
124295
  )
124196
124296
  );
124197
124297
  const noopOnDelete = { onDeleteValue: noop };
@@ -124203,6 +124303,7 @@ function createStateBuildOrder(state) {
124203
124303
  mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
124204
124304
  mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
124205
124305
  mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
124306
+ mutateMapSkippingNewValues(state.lastCachedPackageJsonLookups, currentProjects, noopOnDelete);
124206
124307
  if (state.watch) {
124207
124308
  mutateMapSkippingNewValues(
124208
124309
  state.allWatchedConfigFiles,
@@ -124451,7 +124552,7 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124451
124552
  return withProgramOrUndefined(action) || emptyArray;
124452
124553
  }
124453
124554
  function createProgram2() {
124454
- var _a, _b;
124555
+ var _a, _b, _c;
124455
124556
  Debug.assert(program === void 0);
124456
124557
  if (state.options.dry) {
124457
124558
  reportStatus(state, Diagnostics.A_non_dry_build_would_build_project_0, project);
@@ -124480,12 +124581,13 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
124480
124581
  config.projectReferences
124481
124582
  );
124482
124583
  if (state.watch) {
124584
+ const internalMap = (_c = state.moduleResolutionCache) == null ? void 0 : _c.getPackageJsonInfoCache().getInternalMap();
124483
124585
  state.lastCachedPackageJsonLookups.set(
124484
124586
  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
- )
124587
+ internalMap && new Set(arrayFrom(
124588
+ internalMap.values(),
124589
+ (data) => state.host.realpath && (isPackageJsonInfo(data) || data.directoryExists) ? state.host.realpath(combinePaths(data.packageDirectory, "package.json")) : combinePaths(data.packageDirectory, "package.json")
124590
+ ))
124489
124591
  );
124490
124592
  state.builderPrograms.set(projectPath, program);
124491
124593
  }
@@ -125218,9 +125320,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
125218
125320
  const extendedConfigStatus = forEach(project.options.configFile.extendedSourceFiles || emptyArray, (configFile) => checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName));
125219
125321
  if (extendedConfigStatus)
125220
125322
  return extendedConfigStatus;
125221
- const dependentPackageFileStatus = forEach(
125222
- state.lastCachedPackageJsonLookups.get(resolvedPath) || emptyArray,
125223
- ([path]) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125323
+ const packageJsonLookups = state.lastCachedPackageJsonLookups.get(resolvedPath);
125324
+ const dependentPackageFileStatus = packageJsonLookups && forEachKey(
125325
+ packageJsonLookups,
125326
+ (path) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
125224
125327
  );
125225
125328
  if (dependentPackageFileStatus)
125226
125329
  return dependentPackageFileStatus;
@@ -125577,7 +125680,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
125577
125680
  return;
125578
125681
  updateWatchingWildcardDirectories(
125579
125682
  getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath),
125580
- new Map(Object.entries(parsed.wildcardDirectories)),
125683
+ parsed.wildcardDirectories,
125581
125684
  (dir, flags) => state.watchDirectory(
125582
125685
  dir,
125583
125686
  (fileOrDirectory) => {
@@ -125609,9 +125712,9 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) {
125609
125712
  return;
125610
125713
  mutateMap(
125611
125714
  getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath),
125612
- arrayToMap(parsed.fileNames, (fileName) => toPath2(state, fileName)),
125715
+ new Set(parsed.fileNames),
125613
125716
  {
125614
- createNewValue: (_path, input) => watchFile(
125717
+ createNewValue: (input) => watchFile(
125615
125718
  state,
125616
125719
  input,
125617
125720
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
@@ -125629,11 +125732,11 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) {
125629
125732
  return;
125630
125733
  mutateMap(
125631
125734
  getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath),
125632
- new Map(state.lastCachedPackageJsonLookups.get(resolvedPath)),
125735
+ state.lastCachedPackageJsonLookups.get(resolvedPath),
125633
125736
  {
125634
- createNewValue: (path, _input) => watchFile(
125737
+ createNewValue: (input) => watchFile(
125635
125738
  state,
125636
- path,
125739
+ input,
125637
125740
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
125638
125741
  2e3 /* High */,
125639
125742
  parsed == null ? void 0 : parsed.watchOptions,