@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/tsserver.js CHANGED
@@ -1643,6 +1643,7 @@ __export(server_exports, {
1643
1643
  isOuterExpression: () => isOuterExpression,
1644
1644
  isOutermostOptionalChain: () => isOutermostOptionalChain,
1645
1645
  isOverrideModifier: () => isOverrideModifier,
1646
+ isPackageJsonInfo: () => isPackageJsonInfo,
1646
1647
  isPackedArrayLiteral: () => isPackedArrayLiteral,
1647
1648
  isParameter: () => isParameter,
1648
1649
  isParameterDeclaration: () => isParameterDeclaration,
@@ -2294,7 +2295,6 @@ __export(server_exports, {
2294
2295
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
2295
2296
  updateLanguageServiceSourceFile: () => updateLanguageServiceSourceFile,
2296
2297
  updateMissingFilePathsWatch: () => updateMissingFilePathsWatch,
2297
- updatePackageJsonWatch: () => updatePackageJsonWatch,
2298
2298
  updateResolutionField: () => updateResolutionField,
2299
2299
  updateSharedExtendedConfigFileWatcher: () => updateSharedExtendedConfigFileWatcher,
2300
2300
  updateSourceFile: () => updateSourceFile,
@@ -2331,7 +2331,7 @@ module.exports = __toCommonJS(server_exports);
2331
2331
 
2332
2332
  // src/compiler/corePublic.ts
2333
2333
  var versionMajorMinor = "5.4";
2334
- var version = `${versionMajorMinor}.0-insiders.20231127`;
2334
+ var version = `${versionMajorMinor}.0-insiders.20231128`;
2335
2335
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2336
2336
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2337
2337
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6685,6 +6685,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => {
6685
6685
  TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard";
6686
6686
  TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject";
6687
6687
  TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable";
6688
+ TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable";
6688
6689
  TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion";
6689
6690
  return TypeFlags2;
6690
6691
  })(TypeFlags || {});
@@ -6731,6 +6732,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
6731
6732
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
6732
6733
  ObjectFlags3[ObjectFlags3["IsNeverIntersectionComputed"] = 16777216] = "IsNeverIntersectionComputed";
6733
6734
  ObjectFlags3[ObjectFlags3["IsNeverIntersection"] = 33554432] = "IsNeverIntersection";
6735
+ ObjectFlags3[ObjectFlags3["IsConstrainedTypeVariable"] = 67108864] = "IsConstrainedTypeVariable";
6734
6736
  return ObjectFlags3;
6735
6737
  })(ObjectFlags || {});
6736
6738
  var VarianceFlags = /* @__PURE__ */ ((VarianceFlags2) => {
@@ -20031,19 +20033,19 @@ function clearMap(map2, onDeleteValue) {
20031
20033
  function mutateMapSkippingNewValues(map2, newMap, options) {
20032
20034
  const { onDeleteValue, onExistingValue } = options;
20033
20035
  map2.forEach((existingValue, key) => {
20034
- const valueInNewMap = newMap.get(key);
20035
- if (valueInNewMap === void 0) {
20036
+ var _a;
20037
+ if (!(newMap == null ? void 0 : newMap.has(key))) {
20036
20038
  map2.delete(key);
20037
20039
  onDeleteValue(existingValue, key);
20038
20040
  } else if (onExistingValue) {
20039
- onExistingValue(existingValue, valueInNewMap, key);
20041
+ onExistingValue(existingValue, (_a = newMap.get) == null ? void 0 : _a.call(newMap, key), key);
20040
20042
  }
20041
20043
  });
20042
20044
  }
20043
20045
  function mutateMap(map2, newMap, options) {
20044
20046
  mutateMapSkippingNewValues(map2, newMap, options);
20045
20047
  const { createNewValue } = options;
20046
- newMap.forEach((valueInNewMap, key) => {
20048
+ newMap == null ? void 0 : newMap.forEach((valueInNewMap, key) => {
20047
20049
  if (!map2.has(key)) {
20048
20050
  map2.set(key, createNewValue(key, valueInNewMap));
20049
20051
  }
@@ -35640,8 +35642,9 @@ var Parser;
35640
35642
  function nextTokenIsStringLiteral() {
35641
35643
  return nextToken() === 11 /* StringLiteral */;
35642
35644
  }
35643
- function nextTokenIsFromKeyword() {
35644
- return nextToken() === 161 /* FromKeyword */;
35645
+ function nextTokenIsFromKeywordOrEqualsToken() {
35646
+ nextToken();
35647
+ return token() === 161 /* FromKeyword */ || token() === 64 /* EqualsToken */;
35645
35648
  }
35646
35649
  function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
35647
35650
  nextToken();
@@ -36338,7 +36341,7 @@ var Parser;
36338
36341
  identifier = parseIdentifier();
36339
36342
  }
36340
36343
  let isTypeOnly = false;
36341
- if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeyword)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36344
+ if ((identifier == null ? void 0 : identifier.escapedText) === "type" && (token() !== 161 /* FromKeyword */ || isIdentifier2() && lookAhead(nextTokenIsFromKeywordOrEqualsToken)) && (isIdentifier2() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
36342
36345
  isTypeOnly = true;
36343
36346
  identifier = isIdentifier2() ? parseIdentifier() : void 0;
36344
36347
  }
@@ -41244,34 +41247,39 @@ function specToDiagnostic(spec, disallowTrailingRecursion) {
41244
41247
  return [Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
41245
41248
  }
41246
41249
  }
41247
- function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, path, useCaseSensitiveFileNames2) {
41248
- const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude");
41250
+ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExcludeSpecs: exclude }, basePath, useCaseSensitiveFileNames2) {
41251
+ const rawExcludeRegex = getRegularExpressionForWildcard(exclude, basePath, "exclude");
41249
41252
  const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames2 ? "" : "i");
41250
41253
  const wildcardDirectories = {};
41254
+ const wildCardKeyToPath = /* @__PURE__ */ new Map();
41251
41255
  if (include !== void 0) {
41252
41256
  const recursiveKeys = [];
41253
41257
  for (const file of include) {
41254
- const spec = normalizePath(combinePaths(path, file));
41258
+ const spec = normalizePath(combinePaths(basePath, file));
41255
41259
  if (excludeRegex && excludeRegex.test(spec)) {
41256
41260
  continue;
41257
41261
  }
41258
41262
  const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2);
41259
41263
  if (match) {
41260
- const { key, flags } = match;
41261
- const existingFlags = wildcardDirectories[key];
41264
+ const { key, path, flags } = match;
41265
+ const existingPath = wildCardKeyToPath.get(key);
41266
+ const existingFlags = existingPath !== void 0 ? wildcardDirectories[existingPath] : void 0;
41262
41267
  if (existingFlags === void 0 || existingFlags < flags) {
41263
- wildcardDirectories[key] = flags;
41268
+ wildcardDirectories[existingPath !== void 0 ? existingPath : path] = flags;
41269
+ if (existingPath === void 0)
41270
+ wildCardKeyToPath.set(key, path);
41264
41271
  if (flags === 1 /* Recursive */) {
41265
41272
  recursiveKeys.push(key);
41266
41273
  }
41267
41274
  }
41268
41275
  }
41269
41276
  }
41270
- for (const key in wildcardDirectories) {
41271
- if (hasProperty(wildcardDirectories, key)) {
41277
+ for (const path in wildcardDirectories) {
41278
+ if (hasProperty(wildcardDirectories, path)) {
41272
41279
  for (const recursiveKey of recursiveKeys) {
41273
- if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames2)) {
41274
- delete wildcardDirectories[key];
41280
+ const key = toCanonicalKey(path, useCaseSensitiveFileNames2);
41281
+ if (key !== recursiveKey && containsPath(recursiveKey, key, basePath, !useCaseSensitiveFileNames2)) {
41282
+ delete wildcardDirectories[path];
41275
41283
  }
41276
41284
  }
41277
41285
  }
@@ -41279,6 +41287,9 @@ function getWildcardDirectories({ validatedIncludeSpecs: include, validatedExclu
41279
41287
  }
41280
41288
  return wildcardDirectories;
41281
41289
  }
41290
+ function toCanonicalKey(path, useCaseSensitiveFileNames2) {
41291
+ return useCaseSensitiveFileNames2 ? path : toFileNameLowerCase(path);
41292
+ }
41282
41293
  function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
41283
41294
  const match = wildcardDirectoryPattern.exec(spec);
41284
41295
  if (match) {
@@ -41286,13 +41297,16 @@ function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames2) {
41286
41297
  const starWildcardIndex = spec.indexOf("*");
41287
41298
  const lastDirectorySeperatorIndex = spec.lastIndexOf(directorySeparator);
41288
41299
  return {
41289
- key: useCaseSensitiveFileNames2 ? match[0] : toFileNameLowerCase(match[0]),
41300
+ key: toCanonicalKey(match[0], useCaseSensitiveFileNames2),
41301
+ path: match[0],
41290
41302
  flags: questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex || starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex ? 1 /* Recursive */ : 0 /* None */
41291
41303
  };
41292
41304
  }
41293
41305
  if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
41306
+ const path = removeTrailingDirectorySeparator(spec);
41294
41307
  return {
41295
- key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames2 ? spec : toFileNameLowerCase(spec)),
41308
+ key: toCanonicalKey(path, useCaseSensitiveFileNames2),
41309
+ path,
41296
41310
  flags: 1 /* Recursive */
41297
41311
  };
41298
41312
  }
@@ -41935,6 +41949,9 @@ function getAutomaticTypeDirectiveNames(options, host) {
41935
41949
  }
41936
41950
  return result;
41937
41951
  }
41952
+ function isPackageJsonInfo(entry) {
41953
+ return !!(entry == null ? void 0 : entry.contents);
41954
+ }
41938
41955
  function compilerOptionValueToString(value) {
41939
41956
  var _a;
41940
41957
  if (value === null || typeof value !== "object") {
@@ -42039,7 +42056,7 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
42039
42056
  }
42040
42057
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
42041
42058
  let cache;
42042
- return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, entries, getInternalMap };
42059
+ return { getPackageJsonInfo: getPackageJsonInfo2, setPackageJsonInfo, clear: clear2, getInternalMap };
42043
42060
  function getPackageJsonInfo2(packageJsonPath) {
42044
42061
  return cache == null ? void 0 : cache.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
42045
42062
  }
@@ -42049,10 +42066,6 @@ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
42049
42066
  function clear2() {
42050
42067
  cache = void 0;
42051
42068
  }
42052
- function entries() {
42053
- const iter = cache == null ? void 0 : cache.entries();
42054
- return iter ? arrayFrom(iter) : [];
42055
- }
42056
42069
  function getInternalMap() {
42057
42070
  return cache;
42058
42071
  }
@@ -43069,13 +43082,13 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
43069
43082
  }
43070
43083
  const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
43071
43084
  if (existing !== void 0) {
43072
- if (typeof existing !== "boolean") {
43085
+ if (isPackageJsonInfo(existing)) {
43073
43086
  if (traceEnabled)
43074
43087
  trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
43075
43088
  (_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
43076
43089
  return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
43077
43090
  } else {
43078
- if (existing && traceEnabled)
43091
+ if (existing.directoryExists && traceEnabled)
43079
43092
  trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
43080
43093
  (_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
43081
43094
  return void 0;
@@ -43097,7 +43110,7 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
43097
43110
  trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
43098
43111
  }
43099
43112
  if (state.packageJsonInfoCache && !state.packageJsonInfoCache.isReadonly)
43100
- state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, directoryExists);
43113
+ state.packageJsonInfoCache.setPackageJsonInfo(packageJsonPath, { packageDirectory, directoryExists });
43101
43114
  (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
43102
43115
  }
43103
43116
  }
@@ -46446,7 +46459,7 @@ function createBinder() {
46446
46459
  }
46447
46460
  function bindSpecialPropertyAssignment(node) {
46448
46461
  var _a;
46449
- const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer) || lookupSymbolForPropertyAccess(node.left.expression, container);
46462
+ const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer);
46450
46463
  if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) {
46451
46464
  return;
46452
46465
  }
@@ -46544,7 +46557,7 @@ function createBinder() {
46544
46557
  return isBinaryExpression(propertyAccess.parent) ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 312 /* SourceFile */ : propertyAccess.parent.parent.kind === 312 /* SourceFile */;
46545
46558
  }
46546
46559
  function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
46547
- let namespaceSymbol = lookupSymbolForPropertyAccess(name, blockScopeContainer) || lookupSymbolForPropertyAccess(name, container);
46560
+ let namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
46548
46561
  const isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
46549
46562
  namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
46550
46563
  bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
@@ -47108,8 +47121,8 @@ function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourc
47108
47121
  return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, getPreferences({}, compilerOptions, importingSourceFile), {}, options);
47109
47122
  }
47110
47123
  function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences, options = {}) {
47111
- const info = getInfo(importingSourceFile.path, host);
47112
- const modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
47124
+ const info = getInfo(importingSourceFile.fileName, host);
47125
+ const modulePaths = getAllModulePaths(info, nodeModulesFileName, host, preferences, options);
47113
47126
  return firstDefined(modulePaths, (modulePath) => tryGetModuleNameAsNodeModule(
47114
47127
  modulePath,
47115
47128
  info,
@@ -47124,7 +47137,7 @@ function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeMod
47124
47137
  }
47125
47138
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName2, host, preferences, userPreferences, options = {}) {
47126
47139
  const info = getInfo(importingSourceFileName, host);
47127
- const modulePaths = getAllModulePaths(importingSourceFileName, toFileName2, host, userPreferences, options);
47140
+ const modulePaths = getAllModulePaths(info, toFileName2, host, userPreferences, options);
47128
47141
  return firstDefined(modulePaths, (modulePath) => tryGetModuleNameAsNodeModule(
47129
47142
  modulePath,
47130
47143
  info,
@@ -47186,7 +47199,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
47186
47199
  if (!moduleSourceFile)
47187
47200
  return { moduleSpecifiers: emptyArray, computedWithoutCache };
47188
47201
  computedWithoutCache = true;
47189
- modulePaths || (modulePaths = getAllModulePathsWorker(importingSourceFile.path, moduleSourceFile.originalFileName, host));
47202
+ modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host));
47190
47203
  const result = computeModuleSpecifiers(
47191
47204
  modulePaths,
47192
47205
  compilerOptions,
@@ -47200,7 +47213,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
47200
47213
  return { moduleSpecifiers: result, computedWithoutCache };
47201
47214
  }
47202
47215
  function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
47203
- const info = getInfo(importingSourceFile.path, host);
47216
+ const info = getInfo(importingSourceFile.fileName, host);
47204
47217
  const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
47205
47218
  const existingSpecifier = forEach(modulePaths, (modulePath) => forEach(
47206
47219
  host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)),
@@ -47264,16 +47277,22 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
47264
47277
  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);
47265
47278
  }
47266
47279
  function getInfo(importingSourceFileName, host) {
47280
+ importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
47267
47281
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
47268
47282
  const sourceDirectory = getDirectoryPath(importingSourceFileName);
47269
- return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
47283
+ return {
47284
+ getCanonicalFileName,
47285
+ importingSourceFileName,
47286
+ sourceDirectory,
47287
+ canonicalSourceDirectory: getCanonicalFileName(sourceDirectory)
47288
+ };
47270
47289
  }
47271
47290
  function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }, pathsOnly) {
47272
47291
  const { baseUrl, paths, rootDirs } = compilerOptions;
47273
47292
  if (pathsOnly && !paths) {
47274
47293
  return void 0;
47275
47294
  }
47276
- const { sourceDirectory, getCanonicalFileName } = info;
47295
+ const { sourceDirectory, canonicalSourceDirectory, getCanonicalFileName } = info;
47277
47296
  const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode);
47278
47297
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, allowedEndings, compilerOptions) || processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), allowedEndings, compilerOptions);
47279
47298
  if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
@@ -47298,7 +47317,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
47298
47317
  if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
47299
47318
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
47300
47319
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
47301
- const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
47320
+ const sourceIsInternal = startsWith(canonicalSourceDirectory, projectDirectory);
47302
47321
  const targetIsInternal = startsWith(modulePath, projectDirectory);
47303
47322
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
47304
47323
  return maybeNonRelative;
@@ -47371,8 +47390,9 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
47371
47390
  });
47372
47391
  return result || (preferSymlinks ? forEach(targets, (p) => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? void 0 : cb(p, p === referenceRedirect)) : void 0);
47373
47392
  }
47374
- function getAllModulePaths(importingFilePath, importedFileName, host, preferences, options = {}) {
47393
+ function getAllModulePaths(info, importedFileName, host, preferences, options = {}) {
47375
47394
  var _a;
47395
+ const importingFilePath = toPath(info.importingSourceFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
47376
47396
  const importedFilePath = toPath(importedFileName, host.getCurrentDirectory(), hostGetCanonicalFileName(host));
47377
47397
  const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
47378
47398
  if (cache) {
@@ -47380,30 +47400,29 @@ function getAllModulePaths(importingFilePath, importedFileName, host, preference
47380
47400
  if (cached == null ? void 0 : cached.modulePaths)
47381
47401
  return cached.modulePaths;
47382
47402
  }
47383
- const modulePaths = getAllModulePathsWorker(importingFilePath, importedFileName, host);
47403
+ const modulePaths = getAllModulePathsWorker(info, importedFileName, host);
47384
47404
  if (cache) {
47385
47405
  cache.setModulePaths(importingFilePath, importedFilePath, preferences, options, modulePaths);
47386
47406
  }
47387
47407
  return modulePaths;
47388
47408
  }
47389
- function getAllModulePathsWorker(importingFileName, importedFileName, host) {
47390
- const getCanonicalFileName = hostGetCanonicalFileName(host);
47409
+ function getAllModulePathsWorker(info, importedFileName, host) {
47391
47410
  const allFileNames = /* @__PURE__ */ new Map();
47392
47411
  let importedFileFromNodeModules = false;
47393
47412
  forEachFileNameOfModule(
47394
- importingFileName,
47413
+ info.importingSourceFileName,
47395
47414
  importedFileName,
47396
47415
  host,
47397
47416
  /*preferSymlinks*/
47398
47417
  true,
47399
47418
  (path, isRedirect) => {
47400
47419
  const isInNodeModules = pathContainsNodeModules(path);
47401
- allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect, isInNodeModules });
47420
+ allFileNames.set(path, { path: info.getCanonicalFileName(path), isRedirect, isInNodeModules });
47402
47421
  importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
47403
47422
  }
47404
47423
  );
47405
47424
  const sortedPaths = [];
47406
- for (let directory = getDirectoryPath(importingFileName); allFileNames.size !== 0; ) {
47425
+ for (let directory = info.canonicalSourceDirectory; allFileNames.size !== 0; ) {
47407
47426
  const directoryStart = ensureTrailingDirectorySeparator(directory);
47408
47427
  let pathsInDirectory;
47409
47428
  allFileNames.forEach(({ path, isRedirect, isInNodeModules }, fileName) => {
@@ -47424,7 +47443,10 @@ function getAllModulePathsWorker(importingFileName, importedFileName, host) {
47424
47443
  directory = newDirectory;
47425
47444
  }
47426
47445
  if (allFileNames.size) {
47427
- const remainingPaths = arrayFrom(allFileNames.values());
47446
+ const remainingPaths = arrayFrom(
47447
+ allFileNames.entries(),
47448
+ ([fileName, { isRedirect, isInNodeModules }]) => ({ path: fileName, isRedirect, isInNodeModules })
47449
+ );
47428
47450
  if (remainingPaths.length > 1)
47429
47451
  remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
47430
47452
  sortedPaths.push(...remainingPaths);
@@ -47584,7 +47606,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
47584
47606
  }
47585
47607
  return processEnding(shortest, allowedEndings, compilerOptions);
47586
47608
  }
47587
- function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
47609
+ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, canonicalSourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
47588
47610
  if (!host.fileExists || !host.readFile) {
47589
47611
  return void 0;
47590
47612
  }
@@ -47628,7 +47650,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
47628
47650
  }
47629
47651
  const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
47630
47652
  const pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
47631
- if (!(startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
47653
+ if (!(startsWith(canonicalSourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
47632
47654
  return void 0;
47633
47655
  }
47634
47656
  const nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
@@ -47641,7 +47663,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
47641
47663
  let moduleFileToTry = path;
47642
47664
  let maybeBlockedByTypesVersions = false;
47643
47665
  const cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host)) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
47644
- if (typeof cachedPackageJson === "object" || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
47666
+ if (isPackageJsonInfo(cachedPackageJson) || cachedPackageJson === void 0 && host.fileExists(packageJsonPath)) {
47645
47667
  const packageJsonContent = (cachedPackageJson == null ? void 0 : cachedPackageJson.contents.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
47646
47668
  const importMode = overrideMode || importingSourceFile.impliedNodeFormat;
47647
47669
  if (getResolvePackageJsonExports(options)) {
@@ -59228,9 +59250,13 @@ function createTypeChecker(host) {
59228
59250
  function getConstraintOfTypeParameter(typeParameter) {
59229
59251
  return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : void 0;
59230
59252
  }
59253
+ function isConstMappedType(type, depth) {
59254
+ const typeVariable = getHomomorphicTypeVariable(type);
59255
+ return !!typeVariable && isConstTypeVariable(typeVariable, depth);
59256
+ }
59231
59257
  function isConstTypeVariable(type, depth = 0) {
59232
59258
  var _a;
59233
- 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));
59259
+ 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));
59234
59260
  }
59235
59261
  function getConstraintOfIndexedAccess(type) {
59236
59262
  return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
@@ -61627,6 +61653,8 @@ function createTypeChecker(host) {
61627
61653
  includes |= flags & 473694207 /* IncludesMask */;
61628
61654
  if (flags & 465829888 /* Instantiable */)
61629
61655
  includes |= 33554432 /* IncludesInstantiable */;
61656
+ if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */)
61657
+ includes |= 268435456 /* IncludesConstrainedTypeVariable */;
61630
61658
  if (type === wildcardType)
61631
61659
  includes |= 8388608 /* IncludesWildcard */;
61632
61660
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
@@ -61731,6 +61759,41 @@ function createTypeChecker(host) {
61731
61759
  }
61732
61760
  }
61733
61761
  }
61762
+ function removeConstrainedTypeVariables(types) {
61763
+ const typeVariables = [];
61764
+ for (const type of types) {
61765
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
61766
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
61767
+ pushIfUnique(typeVariables, type.types[index]);
61768
+ }
61769
+ }
61770
+ for (const typeVariable of typeVariables) {
61771
+ const primitives = [];
61772
+ for (const type of types) {
61773
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
61774
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
61775
+ if (type.types[index] === typeVariable) {
61776
+ insertType(primitives, type.types[1 - index]);
61777
+ }
61778
+ }
61779
+ }
61780
+ const constraint = getBaseConstraintOfType(typeVariable);
61781
+ if (everyType(constraint, (t) => containsType(primitives, t))) {
61782
+ let i = types.length;
61783
+ while (i > 0) {
61784
+ i--;
61785
+ const type = types[i];
61786
+ if (getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) {
61787
+ const index = type.types[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
61788
+ if (type.types[index] === typeVariable && containsType(primitives, type.types[1 - index])) {
61789
+ orderedRemoveItemAt(types, i);
61790
+ }
61791
+ }
61792
+ }
61793
+ insertType(types, typeVariable);
61794
+ }
61795
+ }
61796
+ }
61734
61797
  function isNamedUnionType(type) {
61735
61798
  return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin));
61736
61799
  }
@@ -61796,6 +61859,9 @@ function createTypeChecker(host) {
61796
61859
  if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) {
61797
61860
  removeStringLiteralsMatchedByTemplateLiterals(typeSet);
61798
61861
  }
61862
+ if (includes & 268435456 /* IncludesConstrainedTypeVariable */) {
61863
+ removeConstrainedTypeVariables(typeSet);
61864
+ }
61799
61865
  if (unionReduction === 2 /* Subtype */) {
61800
61866
  typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */));
61801
61867
  if (!typeSet) {
@@ -62008,9 +62074,9 @@ function createTypeChecker(host) {
62008
62074
  types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */);
62009
62075
  return true;
62010
62076
  }
62011
- function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
62077
+ function createIntersectionType(types, objectFlags, aliasSymbol, aliasTypeArguments) {
62012
62078
  const result = createType(2097152 /* Intersection */);
62013
- result.objectFlags = getPropagatingFlagsOfTypes(
62079
+ result.objectFlags = objectFlags | getPropagatingFlagsOfTypes(
62014
62080
  types,
62015
62081
  /*excludeKinds*/
62016
62082
  98304 /* Nullable */
@@ -62024,6 +62090,7 @@ function createTypeChecker(host) {
62024
62090
  const typeMembershipMap = /* @__PURE__ */ new Map();
62025
62091
  const includes = addTypesToIntersection(typeMembershipMap, 0, types);
62026
62092
  const typeSet = arrayFrom(typeMembershipMap.values());
62093
+ let objectFlags = 0 /* None */;
62027
62094
  if (includes & 131072 /* Never */) {
62028
62095
  return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
62029
62096
  }
@@ -62052,6 +62119,25 @@ function createTypeChecker(host) {
62052
62119
  if (typeSet.length === 1) {
62053
62120
  return typeSet[0];
62054
62121
  }
62122
+ if (typeSet.length === 2) {
62123
+ const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
62124
+ const typeVariable = typeSet[typeVarIndex];
62125
+ const primitiveType = typeSet[1 - typeVarIndex];
62126
+ if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
62127
+ const constraint = getBaseConstraintOfType(typeVariable);
62128
+ if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
62129
+ if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
62130
+ return typeVariable;
62131
+ }
62132
+ if (!(constraint.flags & 1048576 /* Union */ && someType(constraint, (c) => isTypeStrictSubtypeOf(c, primitiveType)))) {
62133
+ if (!isTypeStrictSubtypeOf(primitiveType, constraint)) {
62134
+ return neverType;
62135
+ }
62136
+ }
62137
+ objectFlags = 67108864 /* IsConstrainedTypeVariable */;
62138
+ }
62139
+ }
62140
+ }
62055
62141
  const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
62056
62142
  let result = intersectionTypes.get(id);
62057
62143
  if (!result) {
@@ -62074,7 +62160,7 @@ function createTypeChecker(host) {
62074
62160
  result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
62075
62161
  }
62076
62162
  } else {
62077
- result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
62163
+ result = createIntersectionType(typeSet, objectFlags, aliasSymbol, aliasTypeArguments);
62078
62164
  }
62079
62165
  intersectionTypes.set(id, result);
62080
62166
  }
@@ -71603,14 +71689,15 @@ function createTypeChecker(host) {
71603
71689
  if (declaration) {
71604
71690
  if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
71605
71691
  const parent2 = declaration.parent.parent;
71606
- if (parent2.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(declaration) & 6 /* Constant */ || parent2.kind === 169 /* Parameter */) {
71692
+ const rootDeclaration = getRootDeclaration(parent2);
71693
+ if (rootDeclaration.kind === 260 /* VariableDeclaration */ && getCombinedNodeFlagsCached(rootDeclaration) & 6 /* Constant */ || rootDeclaration.kind === 169 /* Parameter */) {
71607
71694
  const links = getNodeLinks(parent2);
71608
71695
  if (!(links.flags & 4194304 /* InCheckIdentifier */)) {
71609
71696
  links.flags |= 4194304 /* InCheckIdentifier */;
71610
71697
  const parentType = getTypeForBindingElementParent(parent2, 0 /* Normal */);
71611
71698
  const parentTypeConstraint = parentType && mapType(parentType, getBaseConstraintOrType);
71612
71699
  links.flags &= ~4194304 /* InCheckIdentifier */;
71613
- if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(parent2.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
71700
+ if (parentTypeConstraint && parentTypeConstraint.flags & 1048576 /* Union */ && !(rootDeclaration.kind === 169 /* Parameter */ && isSymbolAssigned(symbol))) {
71614
71701
  const pattern = declaration.parent;
71615
71702
  const narrowedType = getFlowTypeOfReference(
71616
71703
  pattern,
@@ -112868,8 +112955,8 @@ function transformDeclarations(context) {
112868
112955
  const specifier = getModuleSpecifier(
112869
112956
  options,
112870
112957
  currentSourceFile,
112871
- toPath(outputFilePath2, host.getCurrentDirectory(), host.getCanonicalFileName),
112872
- toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName),
112958
+ getNormalizedAbsolutePath(outputFilePath2, host.getCurrentDirectory()),
112959
+ getNormalizedAbsolutePath(declFileName, host.getCurrentDirectory()),
112873
112960
  host
112874
112961
  );
112875
112962
  if (!pathIsRelative(specifier)) {
@@ -120306,8 +120393,8 @@ function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensi
120306
120393
  }
120307
120394
  const baseName = getBaseNameOfFileName(fileOrDirectory);
120308
120395
  const fsQueryResult = {
120309
- fileExists: host.fileExists(fileOrDirectoryPath),
120310
- directoryExists: host.directoryExists(fileOrDirectoryPath)
120396
+ fileExists: host.fileExists(fileOrDirectory),
120397
+ directoryExists: host.directoryExists(fileOrDirectory)
120311
120398
  };
120312
120399
  if (fsQueryResult.directoryExists || hasEntry(parentResult.sortedAndCanonicalizedDirectories, getCanonicalFileName(baseName))) {
120313
120400
  clearCache();
@@ -120395,23 +120482,10 @@ function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, t
120395
120482
  }
120396
120483
  });
120397
120484
  }
120398
- function updatePackageJsonWatch(lookups, packageJsonWatches, createPackageJsonWatch) {
120399
- const newMap = new Map(lookups);
120400
- mutateMap(
120401
- packageJsonWatches,
120402
- newMap,
120403
- {
120404
- createNewValue: createPackageJsonWatch,
120405
- onDeleteValue: closeFileWatcher
120406
- }
120407
- );
120408
- }
120409
120485
  function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
120410
- const missingFilePaths = program.getMissingFilePaths();
120411
- const newMissingFilePathMap = arrayToMap(missingFilePaths, identity, returnTrue);
120412
120486
  mutateMap(
120413
120487
  missingFileWatches,
120414
- newMissingFilePathMap,
120488
+ program.getMissingFilePaths(),
120415
120489
  {
120416
120490
  // Watch the missing files
120417
120491
  createNewValue: createMissingFileWatch,
@@ -120422,18 +120496,22 @@ function updateMissingFilePathsWatch(program, missingFileWatches, createMissingF
120422
120496
  );
120423
120497
  }
120424
120498
  function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
120425
- mutateMap(
120426
- existingWatchedForWildcards,
120427
- wildcardDirectories,
120428
- {
120429
- // Create new watch and recursive info
120430
- createNewValue: createWildcardDirectoryWatcher,
120431
- // Close existing watch thats not needed any more
120432
- onDeleteValue: closeFileWatcherOf,
120433
- // Close existing watch that doesnt match in the flags
120434
- onExistingValue: updateWildcardDirectoryWatcher
120435
- }
120436
- );
120499
+ if (wildcardDirectories) {
120500
+ mutateMap(
120501
+ existingWatchedForWildcards,
120502
+ new Map(Object.entries(wildcardDirectories)),
120503
+ {
120504
+ // Create new watch and recursive info
120505
+ createNewValue: createWildcardDirectoryWatcher,
120506
+ // Close existing watch thats not needed any more
120507
+ onDeleteValue: closeFileWatcherOf,
120508
+ // Close existing watch that doesnt match in the flags
120509
+ onExistingValue: updateWildcardDirectoryWatcher
120510
+ }
120511
+ );
120512
+ } else {
120513
+ clearMap(existingWatchedForWildcards, closeFileWatcherOf);
120514
+ }
120437
120515
  function createWildcardDirectoryWatcher(directory, flags) {
120438
120516
  return {
120439
120517
  watcher: watchDirectory(directory, flags),
@@ -121271,7 +121349,8 @@ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion,
121271
121349
  return false;
121272
121350
  if (program.getSourceFiles().some(sourceFileNotUptoDate))
121273
121351
  return false;
121274
- if (program.getMissingFilePaths().some(fileExists))
121352
+ const missingPaths = program.getMissingFilePaths();
121353
+ if (missingPaths && forEachEntry(missingPaths, fileExists))
121275
121354
  return false;
121276
121355
  const currentOptions = program.getCompilerOptions();
121277
121356
  if (!compareDataObjects(currentOptions, newOptions))
@@ -121575,7 +121654,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121575
121654
  let redirectTargetsMap = createMultiMap();
121576
121655
  let usesUriStyleNodeCoreModules = false;
121577
121656
  const filesByName = /* @__PURE__ */ new Map();
121578
- let missingFilePaths;
121657
+ let missingFileNames = /* @__PURE__ */ new Map();
121579
121658
  const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? /* @__PURE__ */ new Map() : void 0;
121580
121659
  let resolvedProjectReferences;
121581
121660
  let projectReferenceRedirects;
@@ -121694,12 +121773,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121694
121773
  });
121695
121774
  }
121696
121775
  }
121697
- missingFilePaths = arrayFrom(mapDefinedIterator(filesByName.entries(), ([path, file]) => file === void 0 ? path : void 0));
121698
121776
  files = stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
121699
121777
  processingDefaultLibFiles = void 0;
121700
121778
  processingOtherFiles = void 0;
121701
121779
  }
121702
- Debug.assert(!!missingFilePaths);
121703
121780
  if (oldProgram && host.onReleaseOldSourceFile) {
121704
121781
  const oldSourceFiles = oldProgram.getSourceFiles();
121705
121782
  for (const oldSourceFile of oldSourceFiles) {
@@ -121744,8 +121821,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121744
121821
  getSourceFile,
121745
121822
  getSourceFileByPath,
121746
121823
  getSourceFiles: () => files,
121747
- getMissingFilePaths: () => missingFilePaths,
121748
- // TODO: GH#18217
121824
+ getMissingFilePaths: () => missingFileNames,
121749
121825
  getModuleResolutionCache: () => moduleResolutionCache,
121750
121826
  getFilesByNameMap: () => filesByName,
121751
121827
  getCompilerOptions: () => options,
@@ -122172,7 +122248,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122172
122248
  const newSourceFiles = [];
122173
122249
  const modifiedSourceFiles = [];
122174
122250
  structureIsReused = 2 /* Completely */;
122175
- if (oldProgram.getMissingFilePaths().some((missingFilePath) => host.fileExists(missingFilePath))) {
122251
+ if (forEachEntry(oldProgram.getMissingFilePaths(), (missingFileName) => host.fileExists(missingFileName))) {
122176
122252
  return 0 /* Not */;
122177
122253
  }
122178
122254
  const oldSourceFiles = oldProgram.getSourceFiles();
@@ -122312,7 +122388,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122312
122388
  if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
122313
122389
  return 1 /* SafeModules */;
122314
122390
  }
122315
- missingFilePaths = oldProgram.getMissingFilePaths();
122391
+ missingFileNames = oldProgram.getMissingFilePaths();
122316
122392
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
122317
122393
  for (const newSourceFile of newSourceFiles) {
122318
122394
  filesByName.set(newSourceFile.path, newSourceFile);
@@ -122369,7 +122445,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122369
122445
  const path = toPath3(f);
122370
122446
  if (getSourceFileByPath(path))
122371
122447
  return true;
122372
- if (contains(missingFilePaths, path))
122448
+ if (missingFileNames.has(path))
122373
122449
  return false;
122374
122450
  return host.fileExists(f);
122375
122451
  },
@@ -123181,6 +123257,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123181
123257
  addFileToFilesByName(
123182
123258
  file2,
123183
123259
  path,
123260
+ fileName,
123184
123261
  /*redirectedPath*/
123185
123262
  void 0
123186
123263
  );
@@ -123253,7 +123330,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123253
123330
  if (fileFromPackageId) {
123254
123331
  const dupFile = createRedirectedSourceFile(fileFromPackageId, file, fileName, path, toPath3(fileName), originalFileName, sourceFileOptions);
123255
123332
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
123256
- addFileToFilesByName(dupFile, path, redirectedPath);
123333
+ addFileToFilesByName(dupFile, path, fileName, redirectedPath);
123257
123334
  addFileIncludeReason(dupFile, reason);
123258
123335
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
123259
123336
  processingOtherFiles.push(dupFile);
@@ -123263,7 +123340,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123263
123340
  sourceFileToPackageName.set(path, packageIdToPackageName(packageId));
123264
123341
  }
123265
123342
  }
123266
- addFileToFilesByName(file, path, redirectedPath);
123343
+ addFileToFilesByName(file, path, fileName, redirectedPath);
123267
123344
  if (file) {
123268
123345
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
123269
123346
  file.fileName = fileName;
@@ -123303,14 +123380,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123303
123380
  if (file)
123304
123381
  fileReasons.add(file.path, reason);
123305
123382
  }
123306
- function addFileToFilesByName(file, path, redirectedPath) {
123383
+ function addFileToFilesByName(file, path, fileName, redirectedPath) {
123307
123384
  if (redirectedPath) {
123308
- filesByName.set(redirectedPath, file);
123309
- filesByName.set(path, file || false);
123385
+ updateFilesByNameMap(fileName, redirectedPath, file);
123386
+ updateFilesByNameMap(fileName, path, file || false);
123310
123387
  } else {
123311
- filesByName.set(path, file);
123388
+ updateFilesByNameMap(fileName, path, file);
123312
123389
  }
123313
123390
  }
123391
+ function updateFilesByNameMap(fileName, path, file) {
123392
+ filesByName.set(path, file);
123393
+ if (file !== void 0)
123394
+ missingFileNames.delete(path);
123395
+ else
123396
+ missingFileNames.set(path, fileName);
123397
+ }
123314
123398
  function getProjectReferenceRedirect(fileName) {
123315
123399
  const referencedProject = getProjectReferenceRedirectProject(fileName);
123316
123400
  return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
@@ -123631,6 +123715,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123631
123715
  /*file*/
123632
123716
  void 0,
123633
123717
  sourceFilePath,
123718
+ refPath,
123634
123719
  /*redirectedPath*/
123635
123720
  void 0
123636
123721
  );
@@ -123642,6 +123727,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123642
123727
  addFileToFilesByName(
123643
123728
  sourceFile,
123644
123729
  sourceFilePath,
123730
+ refPath,
123645
123731
  /*redirectedPath*/
123646
123732
  void 0
123647
123733
  );
@@ -123651,6 +123737,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123651
123737
  addFileToFilesByName(
123652
123738
  sourceFile,
123653
123739
  sourceFilePath,
123740
+ refPath,
123654
123741
  /*redirectedPath*/
123655
123742
  void 0
123656
123743
  );
@@ -127471,8 +127558,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
127471
127558
  function closeTypeRootsWatch() {
127472
127559
  clearMap(typeRootsWatches, closeFileWatcher);
127473
127560
  }
127474
- function createTypeRootsWatch(typeRootPath, typeRoot) {
127475
- return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
127561
+ function createTypeRootsWatch(typeRoot) {
127562
+ return canWatchTypeRootPath(typeRoot) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
127476
127563
  const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
127477
127564
  if (cachedDirectoryStructureHost) {
127478
127565
  cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
@@ -127481,7 +127568,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
127481
127568
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
127482
127569
  const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
127483
127570
  typeRoot,
127484
- typeRootPath,
127571
+ resolutionHost.toPath(typeRoot),
127485
127572
  rootPath,
127486
127573
  rootPathComponents,
127487
127574
  getCurrentDirectory,
@@ -127502,7 +127589,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
127502
127589
  if (typeRoots) {
127503
127590
  mutateMap(
127504
127591
  typeRootsWatches,
127505
- arrayToMap(typeRoots, (tr) => resolutionHost.toPath(tr)),
127592
+ new Set(typeRoots),
127506
127593
  {
127507
127594
  createNewValue: createTypeRootsWatch,
127508
127595
  onDeleteValue: closeFileWatcher
@@ -128456,7 +128543,11 @@ function createWatchProgram(host) {
128456
128543
  const oldProgram = getCurrentProgram();
128457
128544
  builderProgram = createProgram2(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
128458
128545
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
128459
- updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()), watchMissingFilePath);
128546
+ updateMissingFilePathsWatch(
128547
+ builderProgram.getProgram(),
128548
+ missingFilesMap || (missingFilesMap = /* @__PURE__ */ new Map()),
128549
+ watchMissingFilePath
128550
+ );
128460
128551
  if (needsUpdateInTypeRootWatch) {
128461
128552
  resolutionCache.updateTypeRootsWatch();
128462
128553
  }
@@ -128749,8 +128840,15 @@ function createWatchProgram(host) {
128749
128840
  cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
128750
128841
  }
128751
128842
  }
128752
- function watchMissingFilePath(missingFilePath) {
128753
- return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, 500 /* Medium */, watchOptions, WatchType.MissingFile);
128843
+ function watchMissingFilePath(missingFilePath, missingFileName) {
128844
+ return (parsedConfigs == null ? void 0 : parsedConfigs.has(missingFilePath)) ? noopFileWatcher : watchFilePath(
128845
+ missingFilePath,
128846
+ missingFileName,
128847
+ onMissingFileChange,
128848
+ 500 /* Medium */,
128849
+ watchOptions,
128850
+ WatchType.MissingFile
128851
+ );
128754
128852
  }
128755
128853
  function onMissingFileChange(fileName, eventKind, missingFilePath) {
128756
128854
  updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
@@ -128762,15 +128860,11 @@ function createWatchProgram(host) {
128762
128860
  }
128763
128861
  }
128764
128862
  function watchConfigFileWildCardDirectories() {
128765
- if (wildcardDirectories) {
128766
- updateWatchingWildcardDirectories(
128767
- watchedWildcardDirectories || (watchedWildcardDirectories = /* @__PURE__ */ new Map()),
128768
- new Map(Object.entries(wildcardDirectories)),
128769
- watchWildcardDirectory
128770
- );
128771
- } else if (watchedWildcardDirectories) {
128772
- clearMap(watchedWildcardDirectories, closeFileWatcherOf);
128773
- }
128863
+ updateWatchingWildcardDirectories(
128864
+ watchedWildcardDirectories || (watchedWildcardDirectories = /* @__PURE__ */ new Map()),
128865
+ wildcardDirectories,
128866
+ watchWildcardDirectory
128867
+ );
128774
128868
  }
128775
128869
  function watchWildcardDirectory(directory, flags) {
128776
128870
  return watchDirectory(
@@ -128842,7 +128936,7 @@ function createWatchProgram(host) {
128842
128936
  );
128843
128937
  }
128844
128938
  function watchReferencedProject(configFileName2, configPath, commandLine) {
128845
- var _a, _b, _c, _d, _e;
128939
+ var _a, _b, _c, _d;
128846
128940
  commandLine.watcher || (commandLine.watcher = watchFile2(
128847
128941
  configFileName2,
128848
128942
  (_fileName, eventKind) => {
@@ -128857,55 +128951,50 @@ function createWatchProgram(host) {
128857
128951
  ((_a = commandLine.parsedCommandLine) == null ? void 0 : _a.watchOptions) || watchOptions,
128858
128952
  WatchType.ConfigFileOfReferencedProject
128859
128953
  ));
128860
- if ((_b = commandLine.parsedCommandLine) == null ? void 0 : _b.wildcardDirectories) {
128861
- updateWatchingWildcardDirectories(
128862
- commandLine.watchedDirectories || (commandLine.watchedDirectories = /* @__PURE__ */ new Map()),
128863
- new Map(Object.entries((_c = commandLine.parsedCommandLine) == null ? void 0 : _c.wildcardDirectories)),
128864
- (directory, flags) => {
128865
- var _a2;
128866
- return watchDirectory(
128867
- directory,
128868
- (fileOrDirectory) => {
128869
- const fileOrDirectoryPath = toPath3(fileOrDirectory);
128870
- if (cachedDirectoryStructureHost) {
128871
- cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
128872
- }
128873
- nextSourceFileVersion(fileOrDirectoryPath);
128874
- const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
128875
- if (!(config == null ? void 0 : config.parsedCommandLine))
128876
- return;
128877
- if (isIgnoredFileFromWildCardWatching({
128878
- watchedDirPath: toPath3(directory),
128879
- fileOrDirectory,
128880
- fileOrDirectoryPath,
128881
- configFileName: configFileName2,
128882
- options: config.parsedCommandLine.options,
128883
- program: config.parsedCommandLine.fileNames,
128884
- currentDirectory,
128885
- useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
128886
- writeLog,
128887
- toPath: toPath3
128888
- }))
128889
- return;
128890
- if (config.updateLevel !== 2 /* Full */) {
128891
- config.updateLevel = 1 /* RootNamesAndUpdate */;
128892
- scheduleProgramUpdate();
128893
- }
128894
- },
128895
- flags,
128896
- ((_a2 = commandLine.parsedCommandLine) == null ? void 0 : _a2.watchOptions) || watchOptions,
128897
- WatchType.WildcardDirectoryOfReferencedProject
128898
- );
128899
- }
128900
- );
128901
- } else if (commandLine.watchedDirectories) {
128902
- clearMap(commandLine.watchedDirectories, closeFileWatcherOf);
128903
- commandLine.watchedDirectories = void 0;
128904
- }
128954
+ updateWatchingWildcardDirectories(
128955
+ commandLine.watchedDirectories || (commandLine.watchedDirectories = /* @__PURE__ */ new Map()),
128956
+ (_b = commandLine.parsedCommandLine) == null ? void 0 : _b.wildcardDirectories,
128957
+ (directory, flags) => {
128958
+ var _a2;
128959
+ return watchDirectory(
128960
+ directory,
128961
+ (fileOrDirectory) => {
128962
+ const fileOrDirectoryPath = toPath3(fileOrDirectory);
128963
+ if (cachedDirectoryStructureHost) {
128964
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
128965
+ }
128966
+ nextSourceFileVersion(fileOrDirectoryPath);
128967
+ const config = parsedConfigs == null ? void 0 : parsedConfigs.get(configPath);
128968
+ if (!(config == null ? void 0 : config.parsedCommandLine))
128969
+ return;
128970
+ if (isIgnoredFileFromWildCardWatching({
128971
+ watchedDirPath: toPath3(directory),
128972
+ fileOrDirectory,
128973
+ fileOrDirectoryPath,
128974
+ configFileName: configFileName2,
128975
+ options: config.parsedCommandLine.options,
128976
+ program: config.parsedCommandLine.fileNames,
128977
+ currentDirectory,
128978
+ useCaseSensitiveFileNames: useCaseSensitiveFileNames2,
128979
+ writeLog,
128980
+ toPath: toPath3
128981
+ }))
128982
+ return;
128983
+ if (config.updateLevel !== 2 /* Full */) {
128984
+ config.updateLevel = 1 /* RootNamesAndUpdate */;
128985
+ scheduleProgramUpdate();
128986
+ }
128987
+ },
128988
+ flags,
128989
+ ((_a2 = commandLine.parsedCommandLine) == null ? void 0 : _a2.watchOptions) || watchOptions,
128990
+ WatchType.WildcardDirectoryOfReferencedProject
128991
+ );
128992
+ }
128993
+ );
128905
128994
  updateExtendedConfigFilesWatches(
128906
128995
  configPath,
128907
- (_d = commandLine.parsedCommandLine) == null ? void 0 : _d.options,
128908
- ((_e = commandLine.parsedCommandLine) == null ? void 0 : _e.watchOptions) || watchOptions,
128996
+ (_c = commandLine.parsedCommandLine) == null ? void 0 : _c.options,
128997
+ ((_d = commandLine.parsedCommandLine) == null ? void 0 : _d.watchOptions) || watchOptions,
128909
128998
  WatchType.ExtendedConfigOfReferencedProject
128910
128999
  );
128911
129000
  }
@@ -129232,9 +129321,9 @@ function getBuildOrder(state) {
129232
129321
  function createStateBuildOrder(state) {
129233
129322
  const buildOrder = createBuildOrder(state, state.rootNames.map((f) => resolveProjectName(state, f)));
129234
129323
  state.resolvedConfigFilePaths.clear();
129235
- const currentProjects = new Map(
129324
+ const currentProjects = new Set(
129236
129325
  getBuildOrderFromAnyBuildOrder(buildOrder).map(
129237
- (resolved) => [toResolvedConfigFilePath(state, resolved), true]
129326
+ (resolved) => toResolvedConfigFilePath(state, resolved)
129238
129327
  )
129239
129328
  );
129240
129329
  const noopOnDelete = { onDeleteValue: noop };
@@ -129246,6 +129335,7 @@ function createStateBuildOrder(state) {
129246
129335
  mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
129247
129336
  mutateMapSkippingNewValues(state.buildInfoCache, currentProjects, noopOnDelete);
129248
129337
  mutateMapSkippingNewValues(state.outputTimeStamps, currentProjects, noopOnDelete);
129338
+ mutateMapSkippingNewValues(state.lastCachedPackageJsonLookups, currentProjects, noopOnDelete);
129249
129339
  if (state.watch) {
129250
129340
  mutateMapSkippingNewValues(
129251
129341
  state.allWatchedConfigFiles,
@@ -129500,7 +129590,7 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
129500
129590
  return withProgramOrUndefined(action) || emptyArray;
129501
129591
  }
129502
129592
  function createProgram2() {
129503
- var _a, _b;
129593
+ var _a, _b, _c;
129504
129594
  Debug.assert(program === void 0);
129505
129595
  if (state.options.dry) {
129506
129596
  reportStatus(state, Diagnostics.A_non_dry_build_would_build_project_0, project);
@@ -129529,12 +129619,13 @@ function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath,
129529
129619
  config.projectReferences
129530
129620
  );
129531
129621
  if (state.watch) {
129622
+ const internalMap = (_c = state.moduleResolutionCache) == null ? void 0 : _c.getPackageJsonInfoCache().getInternalMap();
129532
129623
  state.lastCachedPackageJsonLookups.set(
129533
129624
  projectPath,
129534
- state.moduleResolutionCache && map(
129535
- state.moduleResolutionCache.getPackageJsonInfoCache().entries(),
129536
- ([path, data]) => [state.host.realpath && data ? toPath2(state, state.host.realpath(path)) : path, data]
129537
- )
129625
+ internalMap && new Set(arrayFrom(
129626
+ internalMap.values(),
129627
+ (data) => state.host.realpath && (isPackageJsonInfo(data) || data.directoryExists) ? state.host.realpath(combinePaths(data.packageDirectory, "package.json")) : combinePaths(data.packageDirectory, "package.json")
129628
+ ))
129538
129629
  );
129539
129630
  state.builderPrograms.set(projectPath, program);
129540
129631
  }
@@ -130267,9 +130358,10 @@ function getUpToDateStatusWorker(state, project, resolvedPath) {
130267
130358
  const extendedConfigStatus = forEach(project.options.configFile.extendedSourceFiles || emptyArray, (configFile) => checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName));
130268
130359
  if (extendedConfigStatus)
130269
130360
  return extendedConfigStatus;
130270
- const dependentPackageFileStatus = forEach(
130271
- state.lastCachedPackageJsonLookups.get(resolvedPath) || emptyArray,
130272
- ([path]) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
130361
+ const packageJsonLookups = state.lastCachedPackageJsonLookups.get(resolvedPath);
130362
+ const dependentPackageFileStatus = packageJsonLookups && forEachKey(
130363
+ packageJsonLookups,
130364
+ (path) => checkConfigFileUpToDateStatus(state, path, oldestOutputFileTime, oldestOutputFileName)
130273
130365
  );
130274
130366
  if (dependentPackageFileStatus)
130275
130367
  return dependentPackageFileStatus;
@@ -130626,7 +130718,7 @@ function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
130626
130718
  return;
130627
130719
  updateWatchingWildcardDirectories(
130628
130720
  getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath),
130629
- new Map(Object.entries(parsed.wildcardDirectories)),
130721
+ parsed.wildcardDirectories,
130630
130722
  (dir, flags) => state.watchDirectory(
130631
130723
  dir,
130632
130724
  (fileOrDirectory) => {
@@ -130658,9 +130750,9 @@ function watchInputFiles(state, resolved, resolvedPath, parsed) {
130658
130750
  return;
130659
130751
  mutateMap(
130660
130752
  getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath),
130661
- arrayToMap(parsed.fileNames, (fileName) => toPath2(state, fileName)),
130753
+ new Set(parsed.fileNames),
130662
130754
  {
130663
- createNewValue: (_path, input) => watchFile(
130755
+ createNewValue: (input) => watchFile(
130664
130756
  state,
130665
130757
  input,
130666
130758
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
@@ -130678,11 +130770,11 @@ function watchPackageJsonFiles(state, resolved, resolvedPath, parsed) {
130678
130770
  return;
130679
130771
  mutateMap(
130680
130772
  getOrCreateValueMapFromConfigFileMap(state.allWatchedPackageJsonFiles, resolvedPath),
130681
- new Map(state.lastCachedPackageJsonLookups.get(resolvedPath)),
130773
+ state.lastCachedPackageJsonLookups.get(resolvedPath),
130682
130774
  {
130683
- createNewValue: (path, _input) => watchFile(
130775
+ createNewValue: (input) => watchFile(
130684
130776
  state,
130685
- path,
130777
+ input,
130686
130778
  () => invalidateProjectAndScheduleBuilds(state, resolvedPath, 0 /* Update */),
130687
130779
  2e3 /* High */,
130688
130780
  parsed == null ? void 0 : parsed.watchOptions,
@@ -136465,7 +136557,7 @@ function updateImports(program, changeTracker, oldToNew, newToOld, host, getCano
136465
136557
  if ((importedModuleSymbol == null ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some((d) => isAmbientModule(d)))
136466
136558
  return void 0;
136467
136559
  const toImport = oldFromNew !== void 0 ? getSourceFileToImportFromResolved(importLiteral, resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, allFiles) : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
136468
- return toImport !== void 0 && (toImport.updated || importingSourceFileMoved && pathIsRelative(importLiteral.text)) ? ts_moduleSpecifiers_exports.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, createModuleSpecifierResolutionHost(program, host), importLiteral.text) : void 0;
136560
+ return toImport !== void 0 && (toImport.updated || importingSourceFileMoved && pathIsRelative(importLiteral.text)) ? ts_moduleSpecifiers_exports.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, newImportFromPath, toImport.newFileName, createModuleSpecifierResolutionHost(program, host), importLiteral.text) : void 0;
136469
136561
  });
136470
136562
  }
136471
136563
  }
@@ -137304,11 +137396,11 @@ function getSourceMapper(host) {
137304
137396
  const fileFromCache = sourceFileLike.get(path);
137305
137397
  if (fileFromCache !== void 0)
137306
137398
  return fileFromCache ? fileFromCache : void 0;
137307
- if (!host.readFile || host.fileExists && !host.fileExists(path)) {
137399
+ if (!host.readFile || host.fileExists && !host.fileExists(fileName)) {
137308
137400
  sourceFileLike.set(path, false);
137309
137401
  return void 0;
137310
137402
  }
137311
- const text = host.readFile(path);
137403
+ const text = host.readFile(fileName);
137312
137404
  const file = text ? createSourceFileLike(text) : false;
137313
137405
  sourceFileLike.set(path, file);
137314
137406
  return file ? file : void 0;
@@ -139861,7 +139953,7 @@ function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsT
139861
139953
  const resolved = program.getResolvedModule(oldFile, moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier));
139862
139954
  const fileName = (_a = resolved == null ? void 0 : resolved.resolvedModule) == null ? void 0 : _a.resolvedFileName;
139863
139955
  if (fileName && targetSourceFile) {
139864
- const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), targetSourceFile, targetSourceFile.path, fileName, createModuleSpecifierResolutionHost(program, host));
139956
+ const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
139865
139957
  append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
139866
139958
  } else {
139867
139959
  append(copiedOldImports, filterImport(i, factory.createStringLiteral(moduleSpecifierFromImport(i).text), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
@@ -139939,7 +140031,7 @@ function updateImportsInOtherFiles(changes, program, host, oldFile, movedSymbols
139939
140031
  };
139940
140032
  deleteUnusedImports(sourceFile, importNode, changes, shouldMove);
139941
140033
  const pathToTargetFileWithExtension = resolvePath(getDirectoryPath(oldFile.path), targetFileName);
139942
- const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToTargetFileWithExtension, createModuleSpecifierResolutionHost(program, host));
140034
+ const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.fileName, pathToTargetFileWithExtension, createModuleSpecifierResolutionHost(program, host));
139943
140035
  const newImportDeclaration = filterImport(importNode, makeStringLiteral(newModuleSpecifier, quotePreference), shouldMove);
139944
140036
  if (newImportDeclaration)
139945
140037
  changes.insertNodeAfter(sourceFile, statement, newImportDeclaration);
@@ -140074,7 +140166,7 @@ function createOldFileImportsFromTargetFile(sourceFile, targetFileNeedExport, ta
140074
140166
  }
140075
140167
  function makeImportOrRequire(sourceFile, defaultImport, imports, targetFileNameWithExtension, program, host, useEs6Imports, quotePreference) {
140076
140168
  const pathToTargetFile = resolvePath(getDirectoryPath(sourceFile.path), targetFileNameWithExtension);
140077
- const pathToTargetFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.path, pathToTargetFile, createModuleSpecifierResolutionHost(program, host));
140169
+ const pathToTargetFileWithCorrectExtension = getModuleSpecifier(program.getCompilerOptions(), sourceFile, sourceFile.fileName, pathToTargetFile, createModuleSpecifierResolutionHost(program, host));
140078
140170
  if (useEs6Imports) {
140079
140171
  const specifiers = imports.map((i) => factory.createImportSpecifier(
140080
140172
  /*isTypeOnly*/
@@ -165814,6 +165906,10 @@ function provideInlayHints(context) {
165814
165906
  parts.push({ text: tokenToString(node.operator) });
165815
165907
  visitForDisplayParts(node.operand);
165816
165908
  break;
165909
+ case 197 /* ThisType */:
165910
+ Debug.assertNode(node, isThisTypeNode);
165911
+ parts.push({ text: "this" });
165912
+ break;
165817
165913
  default:
165818
165914
  Debug.failBadSyntaxKind(node);
165819
165915
  }
@@ -174501,6 +174597,7 @@ __export(ts_exports2, {
174501
174597
  isOuterExpression: () => isOuterExpression,
174502
174598
  isOutermostOptionalChain: () => isOutermostOptionalChain,
174503
174599
  isOverrideModifier: () => isOverrideModifier,
174600
+ isPackageJsonInfo: () => isPackageJsonInfo,
174504
174601
  isPackedArrayLiteral: () => isPackedArrayLiteral,
174505
174602
  isParameter: () => isParameter,
174506
174603
  isParameterDeclaration: () => isParameterDeclaration,
@@ -175152,7 +175249,6 @@ __export(ts_exports2, {
175152
175249
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
175153
175250
  updateLanguageServiceSourceFile: () => updateLanguageServiceSourceFile,
175154
175251
  updateMissingFilePathsWatch: () => updateMissingFilePathsWatch,
175155
- updatePackageJsonWatch: () => updatePackageJsonWatch,
175156
175252
  updateResolutionField: () => updateResolutionField,
175157
175253
  updateSharedExtendedConfigFileWatcher: () => updateSharedExtendedConfigFileWatcher,
175158
175254
  updateSourceFile: () => updateSourceFile,
@@ -177498,6 +177594,7 @@ var Project3 = class _Project {
177498
177594
  return path === options.configFilePath ? options.configFile : this.getSourceFile(path);
177499
177595
  }
177500
177596
  close() {
177597
+ var _a;
177501
177598
  this.projectService.typingsCache.onProjectClosed(this);
177502
177599
  this.closeWatchingTypingLocations();
177503
177600
  this.cleanupProgram();
@@ -177514,6 +177611,12 @@ var Project3 = class _Project {
177514
177611
  this.resolutionCache.clear();
177515
177612
  this.resolutionCache = void 0;
177516
177613
  this.cachedUnresolvedImportsPerFile = void 0;
177614
+ (_a = this.packageJsonWatches) == null ? void 0 : _a.forEach((watcher) => {
177615
+ watcher.projects.delete(this);
177616
+ watcher.close();
177617
+ });
177618
+ this.packageJsonWatches = void 0;
177619
+ this.moduleSpecifierCache.clear();
177517
177620
  this.moduleSpecifierCache = void 0;
177518
177621
  this.directoryStructureHost = void 0;
177519
177622
  this.exportMapCache = void 0;
@@ -177708,13 +177811,10 @@ var Project3 = class _Project {
177708
177811
  }
177709
177812
  }
177710
177813
  /** @internal */
177711
- onPackageJsonChange(packageJsonPath) {
177712
- var _a;
177713
- if ((_a = this.packageJsonsForAutoImport) == null ? void 0 : _a.has(packageJsonPath)) {
177714
- this.moduleSpecifierCache.clear();
177715
- if (this.autoImportProviderHost) {
177716
- this.autoImportProviderHost.markAsDirty();
177717
- }
177814
+ onPackageJsonChange() {
177815
+ this.moduleSpecifierCache.clear();
177816
+ if (this.autoImportProviderHost) {
177817
+ this.autoImportProviderHost.markAsDirty();
177718
177818
  }
177719
177819
  }
177720
177820
  /** @internal */
@@ -177929,7 +178029,7 @@ var Project3 = class _Project {
177929
178029
  this.program,
177930
178030
  this.missingFilesMap || (this.missingFilesMap = /* @__PURE__ */ new Map()),
177931
178031
  // Watch the missing files
177932
- (missingFilePath) => this.addMissingFileWatcher(missingFilePath)
178032
+ (missingFilePath, missingFileName) => this.addMissingFileWatcher(missingFilePath, missingFileName)
177933
178033
  );
177934
178034
  if (this.generatedFilesMap) {
177935
178035
  const outPath = outFile(this.compilerOptions);
@@ -178043,7 +178143,7 @@ var Project3 = class _Project {
178043
178143
  }
178044
178144
  }
178045
178145
  }
178046
- addMissingFileWatcher(missingFilePath) {
178146
+ addMissingFileWatcher(missingFilePath, missingFileName) {
178047
178147
  var _a;
178048
178148
  if (isConfiguredProject(this)) {
178049
178149
  const configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(missingFilePath);
@@ -178051,7 +178151,7 @@ var Project3 = class _Project {
178051
178151
  return noopFileWatcher;
178052
178152
  }
178053
178153
  const fileWatcher = this.projectService.watchFactory.watchFile(
178054
- missingFilePath,
178154
+ getNormalizedAbsolutePath(missingFileName, this.currentDirectory),
178055
178155
  (fileName, eventKind) => {
178056
178156
  if (isConfiguredProject(this)) {
178057
178157
  this.getCachedDirectoryStructureHost().addOrDeleteFile(fileName, missingFilePath, eventKind);
@@ -178388,7 +178488,7 @@ var Project3 = class _Project {
178388
178488
  getPackageJsonsVisibleToFile(fileName, rootDir) {
178389
178489
  if (this.projectService.serverMode !== 0 /* Semantic */)
178390
178490
  return emptyArray2;
178391
- return this.projectService.getPackageJsonsVisibleToFile(fileName, rootDir);
178491
+ return this.projectService.getPackageJsonsVisibleToFile(fileName, this, rootDir);
178392
178492
  }
178393
178493
  /** @internal */
178394
178494
  getNearestAncestorDirectoryWithPackageJson(fileName) {
@@ -178396,9 +178496,7 @@ var Project3 = class _Project {
178396
178496
  }
178397
178497
  /** @internal */
178398
178498
  getPackageJsonsForAutoImport(rootDir) {
178399
- const packageJsons = this.getPackageJsonsVisibleToFile(combinePaths(this.currentDirectory, inferredTypesContainingFile), rootDir);
178400
- this.packageJsonsForAutoImport = new Set(packageJsons.map((p) => p.fileName));
178401
- return packageJsons;
178499
+ return this.getPackageJsonsVisibleToFile(combinePaths(this.currentDirectory, inferredTypesContainingFile), rootDir);
178402
178500
  }
178403
178501
  /** @internal */
178404
178502
  getPackageJsonCache() {
@@ -178484,7 +178582,7 @@ var Project3 = class _Project {
178484
178582
  }
178485
178583
  /** @internal */
178486
178584
  watchNodeModulesForPackageJsonChanges(directoryPath) {
178487
- return this.projectService.watchPackageJsonsInNodeModules(this.toPath(directoryPath), this);
178585
+ return this.projectService.watchPackageJsonsInNodeModules(directoryPath, this);
178488
178586
  }
178489
178587
  /** @internal */
178490
178588
  getIncompleteCompletionsCache() {
@@ -180060,18 +180158,20 @@ var _ProjectService = class _ProjectService {
180060
180158
  * @internal
180061
180159
  */
180062
180160
  watchWildcardDirectory(directory, flags, configFileName, config) {
180063
- return this.watchFactory.watchDirectory(
180161
+ let watcher = this.watchFactory.watchDirectory(
180064
180162
  directory,
180065
180163
  (fileOrDirectory) => {
180066
180164
  const fileOrDirectoryPath = this.toPath(fileOrDirectory);
180067
180165
  const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
180068
- if (getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectoryPath))) {
180069
- this.logger.info(`Config: ${configFileName} Detected new package.json: ${fileOrDirectory}`);
180070
- this.onAddPackageJson(fileOrDirectoryPath);
180166
+ if (getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))) {
180167
+ const file = this.getNormalizedAbsolutePath(fileOrDirectory);
180168
+ this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
180169
+ this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
180170
+ this.watchPackageJsonFile(file, fileOrDirectoryPath, result);
180071
180171
  }
180072
180172
  const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
180073
180173
  if (isIgnoredFileFromWildCardWatching({
180074
- watchedDirPath: directory,
180174
+ watchedDirPath: this.toPath(directory),
180075
180175
  fileOrDirectory,
180076
180176
  fileOrDirectoryPath,
180077
180177
  configFileName,
@@ -180116,6 +180216,22 @@ var _ProjectService = class _ProjectService {
180116
180216
  WatchType.WildcardDirectory,
180117
180217
  configFileName
180118
180218
  );
180219
+ const result = {
180220
+ packageJsonWatches: void 0,
180221
+ close() {
180222
+ var _a;
180223
+ if (watcher) {
180224
+ watcher.close();
180225
+ watcher = void 0;
180226
+ (_a = result.packageJsonWatches) == null ? void 0 : _a.forEach((watcher2) => {
180227
+ watcher2.projects.delete(result);
180228
+ watcher2.close();
180229
+ });
180230
+ result.packageJsonWatches = void 0;
180231
+ }
180232
+ }
180233
+ };
180234
+ return result;
180119
180235
  }
180120
180236
  /** @internal */
180121
180237
  delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, loadReason) {
@@ -180860,7 +180976,7 @@ var _ProjectService = class _ProjectService {
180860
180976
  config.watchedDirectoriesStale = false;
180861
180977
  updateWatchingWildcardDirectories(
180862
180978
  config.watchedDirectories || (config.watchedDirectories = /* @__PURE__ */ new Map()),
180863
- new Map(Object.entries(config.parsedCommandLine.wildcardDirectories)),
180979
+ config.parsedCommandLine.wildcardDirectories,
180864
180980
  // Create new directory watcher
180865
180981
  (directory, flags) => this.watchWildcardDirectory(directory, flags, configFileName, config)
180866
180982
  );
@@ -180942,7 +181058,7 @@ var _ProjectService = class _ProjectService {
180942
181058
  if (value.info) {
180943
181059
  project.removeFile(
180944
181060
  value.info,
180945
- project.fileExists(path),
181061
+ project.fileExists(value.info.fileName),
180946
181062
  /*detachFromProject*/
180947
181063
  true
180948
181064
  );
@@ -181174,7 +181290,7 @@ All files are: ${JSON.stringify(names)}`, "Err" /* Err */);
181174
181290
  watchClosedScriptInfo(info) {
181175
181291
  Debug.assert(!info.fileWatcher);
181176
181292
  if (!info.isDynamicOrHasMixedContent() && (!this.globalCacheLocationDirectoryPath || !startsWith(info.path, this.globalCacheLocationDirectoryPath))) {
181177
- const indexOfNodeModules = info.path.indexOf("/node_modules/");
181293
+ const indexOfNodeModules = info.fileName.indexOf("/node_modules/");
181178
181294
  if (!this.host.getModifiedTime || indexOfNodeModules === -1) {
181179
181295
  info.fileWatcher = this.watchFactory.watchFile(
181180
181296
  info.fileName,
@@ -181185,12 +181301,12 @@ All files are: ${JSON.stringify(names)}`, "Err" /* Err */);
181185
181301
  );
181186
181302
  } else {
181187
181303
  info.mTime = this.getModifiedTime(info);
181188
- info.fileWatcher = this.watchClosedScriptInfoInNodeModules(info.path.substr(0, indexOfNodeModules));
181304
+ info.fileWatcher = this.watchClosedScriptInfoInNodeModules(info.fileName.substring(0, indexOfNodeModules));
181189
181305
  }
181190
181306
  }
181191
181307
  }
181192
- createNodeModulesWatcher(dir) {
181193
- const watcher = this.watchFactory.watchDirectory(
181308
+ createNodeModulesWatcher(dir, dirPath) {
181309
+ let watcher = this.watchFactory.watchDirectory(
181194
181310
  dir,
181195
181311
  (fileOrDirectory) => {
181196
181312
  var _a;
@@ -181199,14 +181315,14 @@ All files are: ${JSON.stringify(names)}`, "Err" /* Err */);
181199
181315
  return;
181200
181316
  const basename = getBaseFileName(fileOrDirectoryPath);
181201
181317
  if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename === "package.json" || basename === "node_modules")) {
181202
- result.affectedModuleSpecifierCacheProjects.forEach((projectName) => {
181203
- var _a2, _b;
181204
- (_b = (_a2 = this.findProject(projectName)) == null ? void 0 : _a2.getModuleSpecifierCache()) == null ? void 0 : _b.clear();
181318
+ result.affectedModuleSpecifierCacheProjects.forEach((project) => {
181319
+ var _a2;
181320
+ (_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
181205
181321
  });
181206
181322
  }
181207
181323
  if (result.refreshScriptInfoRefCount) {
181208
- if (dir === fileOrDirectoryPath) {
181209
- this.refreshScriptInfosInDirectory(dir);
181324
+ if (dirPath === fileOrDirectoryPath) {
181325
+ this.refreshScriptInfosInDirectory(dirPath);
181210
181326
  } else {
181211
181327
  const info = this.getScriptInfoForPath(fileOrDirectoryPath);
181212
181328
  if (info) {
@@ -181228,30 +181344,35 @@ All files are: ${JSON.stringify(names)}`, "Err" /* Err */);
181228
181344
  affectedModuleSpecifierCacheProjects: void 0,
181229
181345
  close: () => {
181230
181346
  var _a;
181231
- if (!result.refreshScriptInfoRefCount && !((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size)) {
181347
+ if (watcher && !result.refreshScriptInfoRefCount && !((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size)) {
181232
181348
  watcher.close();
181233
- this.nodeModulesWatchers.delete(dir);
181349
+ watcher = void 0;
181350
+ this.nodeModulesWatchers.delete(dirPath);
181234
181351
  }
181235
181352
  }
181236
181353
  };
181237
- this.nodeModulesWatchers.set(dir, result);
181354
+ this.nodeModulesWatchers.set(dirPath, result);
181238
181355
  return result;
181239
181356
  }
181240
181357
  /** @internal */
181241
181358
  watchPackageJsonsInNodeModules(dir, project) {
181242
- const watcher = this.nodeModulesWatchers.get(dir) || this.createNodeModulesWatcher(dir);
181243
- (watcher.affectedModuleSpecifierCacheProjects || (watcher.affectedModuleSpecifierCacheProjects = /* @__PURE__ */ new Set())).add(project.getProjectName());
181359
+ var _a;
181360
+ const dirPath = this.toPath(dir);
181361
+ const watcher = this.nodeModulesWatchers.get(dirPath) || this.createNodeModulesWatcher(dir, dirPath);
181362
+ Debug.assert(!((_a = watcher.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.has(project)));
181363
+ (watcher.affectedModuleSpecifierCacheProjects || (watcher.affectedModuleSpecifierCacheProjects = /* @__PURE__ */ new Set())).add(project);
181244
181364
  return {
181245
181365
  close: () => {
181246
- var _a;
181247
- (_a = watcher.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.delete(project.getProjectName());
181366
+ var _a2;
181367
+ (_a2 = watcher.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a2.delete(project);
181248
181368
  watcher.close();
181249
181369
  }
181250
181370
  };
181251
181371
  }
181252
181372
  watchClosedScriptInfoInNodeModules(dir) {
181253
181373
  const watchDir = dir + "/node_modules";
181254
- const watcher = this.nodeModulesWatchers.get(watchDir) || this.createNodeModulesWatcher(watchDir);
181374
+ const watchDirPath = this.toPath(watchDir);
181375
+ const watcher = this.nodeModulesWatchers.get(watchDirPath) || this.createNodeModulesWatcher(watchDir, watchDirPath);
181255
181376
  watcher.refreshScriptInfoRefCount++;
181256
181377
  return {
181257
181378
  close: () => {
@@ -181261,7 +181382,7 @@ All files are: ${JSON.stringify(names)}`, "Err" /* Err */);
181261
181382
  };
181262
181383
  }
181263
181384
  getModifiedTime(info) {
181264
- return (this.host.getModifiedTime(info.path) || missingFileModifiedTime).getTime();
181385
+ return (this.host.getModifiedTime(info.fileName) || missingFileModifiedTime).getTime();
181265
181386
  }
181266
181387
  refreshScriptInfo(info) {
181267
181388
  const mTime = this.getModifiedTime(info);
@@ -181525,10 +181646,9 @@ Dynamic files must always be opened with service's current directory or service
181525
181646
  });
181526
181647
  }
181527
181648
  if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) {
181528
- this.invalidateProjectPackageJson(
181529
- /*packageJsonPath*/
181530
- void 0
181531
- );
181649
+ this.forEachProject((project) => {
181650
+ project.onAutoImportProviderSettingsChanged();
181651
+ });
181532
181652
  }
181533
181653
  }
181534
181654
  if (args.extraFileExtensions) {
@@ -182447,10 +182567,9 @@ Dynamic files must always be opened with service's current directory or service
182447
182567
  this.currentPluginConfigOverrides.set(args.pluginName, args.configuration);
182448
182568
  }
182449
182569
  /** @internal */
182450
- getPackageJsonsVisibleToFile(fileName, rootDir) {
182570
+ getPackageJsonsVisibleToFile(fileName, project, rootDir) {
182451
182571
  const packageJsonCache = this.packageJsonCache;
182452
182572
  const rootPath = rootDir && this.toPath(rootDir);
182453
- const filePath = this.toPath(fileName);
182454
182573
  const result = [];
182455
182574
  const processDirectory = (directory) => {
182456
182575
  switch (packageJsonCache.directoryHasPackageJson(directory)) {
@@ -182459,7 +182578,7 @@ Dynamic files must always be opened with service's current directory or service
182459
182578
  return processDirectory(directory);
182460
182579
  case -1 /* True */:
182461
182580
  const packageJsonFileName = combinePaths(directory, "package.json");
182462
- this.watchPackageJsonFile(packageJsonFileName);
182581
+ this.watchPackageJsonFile(packageJsonFileName, this.toPath(packageJsonFileName), project);
182463
182582
  const info = packageJsonCache.getInDirectory(directory);
182464
182583
  if (info)
182465
182584
  result.push(info);
@@ -182468,13 +182587,13 @@ Dynamic files must always be opened with service's current directory or service
182468
182587
  return true;
182469
182588
  }
182470
182589
  };
182471
- forEachAncestorDirectory(getDirectoryPath(filePath), processDirectory);
182590
+ forEachAncestorDirectory(getDirectoryPath(fileName), processDirectory);
182472
182591
  return result;
182473
182592
  }
182474
182593
  /** @internal */
182475
182594
  getNearestAncestorDirectoryWithPackageJson(fileName) {
182476
182595
  return forEachAncestorDirectory(fileName, (directory) => {
182477
- switch (this.packageJsonCache.directoryHasPackageJson(this.toPath(directory))) {
182596
+ switch (this.packageJsonCache.directoryHasPackageJson(directory)) {
182478
182597
  case -1 /* True */:
182479
182598
  return directory;
182480
182599
  case 0 /* False */:
@@ -182485,41 +182604,54 @@ Dynamic files must always be opened with service's current directory or service
182485
182604
  });
182486
182605
  }
182487
182606
  /** @internal */
182488
- watchPackageJsonFile(path) {
182489
- const watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = /* @__PURE__ */ new Map());
182490
- if (!watchers.has(path)) {
182491
- this.invalidateProjectPackageJson(path);
182492
- watchers.set(
182493
- path,
182494
- this.watchFactory.watchFile(
182495
- path,
182496
- (fileName, eventKind) => {
182497
- const path2 = this.toPath(fileName);
182498
- switch (eventKind) {
182499
- case 0 /* Created */:
182500
- return Debug.fail();
182501
- case 1 /* Changed */:
182502
- this.packageJsonCache.addOrUpdate(path2);
182503
- this.invalidateProjectPackageJson(path2);
182504
- break;
182505
- case 2 /* Deleted */:
182506
- this.packageJsonCache.delete(path2);
182507
- this.invalidateProjectPackageJson(path2);
182508
- watchers.get(path2).close();
182509
- watchers.delete(path2);
182510
- }
182511
- },
182512
- 250 /* Low */,
182513
- this.hostConfiguration.watchOptions,
182514
- WatchType.PackageJson
182515
- )
182607
+ watchPackageJsonFile(file, path, project) {
182608
+ Debug.assert(project !== void 0);
182609
+ let result = (this.packageJsonFilesMap ?? (this.packageJsonFilesMap = /* @__PURE__ */ new Map())).get(path);
182610
+ if (!result) {
182611
+ let watcher = this.watchFactory.watchFile(
182612
+ file,
182613
+ (fileName, eventKind) => {
182614
+ switch (eventKind) {
182615
+ case 0 /* Created */:
182616
+ return Debug.fail();
182617
+ case 1 /* Changed */:
182618
+ this.packageJsonCache.addOrUpdate(fileName, path);
182619
+ this.onPackageJsonChange(result);
182620
+ break;
182621
+ case 2 /* Deleted */:
182622
+ this.packageJsonCache.delete(path);
182623
+ this.onPackageJsonChange(result);
182624
+ result.projects.clear();
182625
+ result.close();
182626
+ }
182627
+ },
182628
+ 250 /* Low */,
182629
+ this.hostConfiguration.watchOptions,
182630
+ WatchType.PackageJson
182516
182631
  );
182632
+ result = {
182633
+ projects: /* @__PURE__ */ new Set(),
182634
+ close: () => {
182635
+ var _a;
182636
+ if (result.projects.size || !watcher)
182637
+ return;
182638
+ watcher.close();
182639
+ watcher = void 0;
182640
+ (_a = this.packageJsonFilesMap) == null ? void 0 : _a.delete(path);
182641
+ this.packageJsonCache.invalidate(path);
182642
+ }
182643
+ };
182644
+ this.packageJsonFilesMap.set(path, result);
182517
182645
  }
182646
+ result.projects.add(project);
182647
+ (project.packageJsonWatches ?? (project.packageJsonWatches = /* @__PURE__ */ new Set())).add(result);
182518
182648
  }
182519
182649
  /** @internal */
182520
- onAddPackageJson(path) {
182521
- this.packageJsonCache.addOrUpdate(path);
182522
- this.watchPackageJsonFile(path);
182650
+ onPackageJsonChange(result) {
182651
+ result.projects.forEach((project) => {
182652
+ var _a;
182653
+ return (_a = project.onPackageJsonChange) == null ? void 0 : _a.call(project);
182654
+ });
182523
182655
  }
182524
182656
  /** @internal */
182525
182657
  includePackageJsonAutoImports() {
@@ -182533,19 +182665,6 @@ Dynamic files must always be opened with service's current directory or service
182533
182665
  }
182534
182666
  }
182535
182667
  /** @internal */
182536
- invalidateProjectPackageJson(packageJsonPath) {
182537
- this.configuredProjects.forEach(invalidate);
182538
- this.inferredProjects.forEach(invalidate);
182539
- this.externalProjects.forEach(invalidate);
182540
- function invalidate(project) {
182541
- if (packageJsonPath) {
182542
- project.onPackageJsonChange(packageJsonPath);
182543
- } else {
182544
- project.onAutoImportProviderSettingsChanged();
182545
- }
182546
- }
182547
- }
182548
- /** @internal */
182549
182668
  getIncompleteCompletionsCache() {
182550
182669
  return this.incompleteCompletionsCache || (this.incompleteCompletionsCache = createIncompleteCompletionsCache());
182551
182670
  }
@@ -182603,9 +182722,10 @@ function createModuleSpecifierCache(host) {
182603
182722
  for (const p of modulePaths) {
182604
182723
  if (p.isInNodeModules) {
182605
182724
  const nodeModulesPath = p.path.substring(0, p.path.indexOf(nodeModulesPathPart) + nodeModulesPathPart.length - 1);
182606
- if (!(containedNodeModulesWatchers == null ? void 0 : containedNodeModulesWatchers.has(nodeModulesPath))) {
182725
+ const key2 = host.toPath(nodeModulesPath);
182726
+ if (!(containedNodeModulesWatchers == null ? void 0 : containedNodeModulesWatchers.has(key2))) {
182607
182727
  (containedNodeModulesWatchers || (containedNodeModulesWatchers = /* @__PURE__ */ new Map())).set(
182608
- nodeModulesPath,
182728
+ key2,
182609
182729
  host.watchNodeModulesForPackageJsonChanges(nodeModulesPath)
182610
182730
  );
182611
182731
  }
@@ -182644,7 +182764,7 @@ function createModuleSpecifierCache(host) {
182644
182764
  }
182645
182765
  },
182646
182766
  clear() {
182647
- containedNodeModulesWatchers == null ? void 0 : containedNodeModulesWatchers.forEach((watcher) => watcher.close());
182767
+ containedNodeModulesWatchers == null ? void 0 : containedNodeModulesWatchers.forEach(closeFileWatcher);
182648
182768
  cache == null ? void 0 : cache.clear();
182649
182769
  containedNodeModulesWatchers == null ? void 0 : containedNodeModulesWatchers.clear();
182650
182770
  currentKey = void 0;
@@ -182679,34 +182799,38 @@ function createPackageJsonCache(host) {
182679
182799
  const directoriesWithoutPackageJson = /* @__PURE__ */ new Map();
182680
182800
  return {
182681
182801
  addOrUpdate,
182682
- forEach: packageJsons.forEach.bind(packageJsons),
182683
- get: packageJsons.get.bind(packageJsons),
182802
+ invalidate,
182684
182803
  delete: (fileName) => {
182685
182804
  packageJsons.delete(fileName);
182686
182805
  directoriesWithoutPackageJson.set(getDirectoryPath(fileName), true);
182687
182806
  },
182688
182807
  getInDirectory: (directory) => {
182689
- return packageJsons.get(combinePaths(directory, "package.json")) || void 0;
182808
+ return packageJsons.get(host.toPath(combinePaths(directory, "package.json"))) || void 0;
182690
182809
  },
182691
- directoryHasPackageJson,
182810
+ directoryHasPackageJson: (directory) => directoryHasPackageJson(host.toPath(directory)),
182692
182811
  searchDirectoryAndAncestors: (directory) => {
182693
182812
  forEachAncestorDirectory(directory, (ancestor) => {
182694
- if (directoryHasPackageJson(ancestor) !== 3 /* Maybe */) {
182813
+ const ancestorPath = host.toPath(ancestor);
182814
+ if (directoryHasPackageJson(ancestorPath) !== 3 /* Maybe */) {
182695
182815
  return true;
182696
182816
  }
182697
- const packageJsonFileName = host.toPath(combinePaths(ancestor, "package.json"));
182817
+ const packageJsonFileName = combinePaths(ancestor, "package.json");
182698
182818
  if (tryFileExists(host, packageJsonFileName)) {
182699
- addOrUpdate(packageJsonFileName);
182819
+ addOrUpdate(packageJsonFileName, combinePaths(ancestorPath, "package.json"));
182700
182820
  } else {
182701
- directoriesWithoutPackageJson.set(ancestor, true);
182821
+ directoriesWithoutPackageJson.set(ancestorPath, true);
182702
182822
  }
182703
182823
  });
182704
182824
  }
182705
182825
  };
182706
- function addOrUpdate(fileName) {
182826
+ function addOrUpdate(fileName, path) {
182707
182827
  const packageJsonInfo = Debug.checkDefined(createPackageJsonInfo(fileName, host.host));
182708
- packageJsons.set(fileName, packageJsonInfo);
182709
- directoriesWithoutPackageJson.delete(getDirectoryPath(fileName));
182828
+ packageJsons.set(path, packageJsonInfo);
182829
+ directoriesWithoutPackageJson.delete(getDirectoryPath(path));
182830
+ }
182831
+ function invalidate(path) {
182832
+ packageJsons.delete(path);
182833
+ directoriesWithoutPackageJson.delete(getDirectoryPath(path));
182710
182834
  }
182711
182835
  function directoryHasPackageJson(directory) {
182712
182836
  return packageJsons.has(combinePaths(directory, "package.json")) ? -1 /* True */ : directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : 3 /* Maybe */;
@@ -189264,6 +189388,7 @@ start(initializeNodeSystem(), require("os").platform());
189264
189388
  isOuterExpression,
189265
189389
  isOutermostOptionalChain,
189266
189390
  isOverrideModifier,
189391
+ isPackageJsonInfo,
189267
189392
  isPackedArrayLiteral,
189268
189393
  isParameter,
189269
189394
  isParameterDeclaration,
@@ -189915,7 +190040,6 @@ start(initializeNodeSystem(), require("os").platform());
189915
190040
  updateErrorForNoInputFiles,
189916
190041
  updateLanguageServiceSourceFile,
189917
190042
  updateMissingFilePathsWatch,
189918
- updatePackageJsonWatch,
189919
190043
  updateResolutionField,
189920
190044
  updateSharedExtendedConfigFileWatcher,
189921
190045
  updateSourceFile,