typescript 5.0.0-dev.20221204 → 5.0.0-dev.20221206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.0";
26
- var version = `${versionMajorMinor}.0-dev.20221204`;
26
+ var version = `${versionMajorMinor}.0-dev.20221206`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -10702,7 +10702,8 @@ function getFullWidth(node) {
10702
10702
  return node.end - node.pos;
10703
10703
  }
10704
10704
  function getResolvedModule(sourceFile, moduleNameText, mode) {
10705
- return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
10705
+ var _a2, _b;
10706
+ return (_b = (_a2 = sourceFile == null ? void 0 : sourceFile.resolvedModules) == null ? void 0 : _a2.get(moduleNameText, mode)) == null ? void 0 : _b.resolvedModule;
10706
10707
  }
10707
10708
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
10708
10709
  if (!sourceFile.resolvedModules) {
@@ -10716,15 +10717,11 @@ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveNam
10716
10717
  }
10717
10718
  sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
10718
10719
  }
10719
- function getResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, mode) {
10720
- var _a2;
10721
- return (_a2 = sourceFile == null ? void 0 : sourceFile.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _a2.get(typeReferenceDirectiveName, mode);
10722
- }
10723
10720
  function projectReferenceIsEqualTo(oldRef, newRef) {
10724
10721
  return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
10725
10722
  }
10726
10723
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
10727
- return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && oldResolution.extension === newResolution.extension && oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.originalPath === newResolution.originalPath && packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
10724
+ return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
10728
10725
  }
10729
10726
  function packageIdIsEqual(a, b) {
10730
10727
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
@@ -10736,15 +10733,15 @@ function packageIdToString(packageId) {
10736
10733
  return `${packageIdToPackageName(packageId)}@${packageId.version}`;
10737
10734
  }
10738
10735
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
10739
- return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary && oldResolution.originalPath === newResolution.originalPath;
10736
+ return oldResolution === newResolution || oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective || !!oldResolution.resolvedTypeReferenceDirective && !!newResolution.resolvedTypeReferenceDirective && oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName && !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary && oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
10740
10737
  }
10741
- function hasChangesInResolutions(names, newSourceFile, newResolutions, oldResolutions, comparer) {
10738
+ function hasChangesInResolutions(names, newSourceFile, newResolutions, oldResolutions, comparer, nameAndModeGetter) {
10742
10739
  Debug.assert(names.length === newResolutions.length);
10743
10740
  for (let i = 0; i < names.length; i++) {
10744
10741
  const newResolution = newResolutions[i];
10745
10742
  const entry = names[i];
10746
- const name = getResolutionName(entry);
10747
- const mode = getResolutionMode(entry, newSourceFile);
10743
+ const name = nameAndModeGetter.getName(entry);
10744
+ const mode = nameAndModeGetter.getMode(entry, newSourceFile);
10748
10745
  const oldResolution = oldResolutions && oldResolutions.get(name, mode);
10749
10746
  const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution;
10750
10747
  if (changed) {
@@ -14824,13 +14821,14 @@ function createSymlinkCache(cwd, getCanonicalFileName) {
14824
14821
  }
14825
14822
  },
14826
14823
  setSymlinksFromResolutions(files, typeReferenceDirectives) {
14827
- var _a2;
14824
+ var _a2, _b;
14828
14825
  Debug.assert(!hasProcessedResolutions);
14829
14826
  hasProcessedResolutions = true;
14830
14827
  for (const file of files) {
14831
- (_a2 = file.resolvedModules) == null ? void 0 : _a2.forEach((resolution) => processResolution(this, resolution));
14828
+ (_a2 = file.resolvedModules) == null ? void 0 : _a2.forEach((resolution) => processResolution(this, resolution.resolvedModule));
14829
+ (_b = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _b.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
14832
14830
  }
14833
- typeReferenceDirectives == null ? void 0 : typeReferenceDirectives.forEach((resolution) => processResolution(this, resolution));
14831
+ typeReferenceDirectives.forEach((resolution) => processResolution(this, resolution.resolvedTypeReferenceDirective));
14834
14832
  },
14835
14833
  hasProcessedResolutions: () => hasProcessedResolutions
14836
14834
  };
@@ -32721,17 +32719,29 @@ function resolvedTypeScriptOnly(resolved) {
32721
32719
  }
32722
32720
  function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
32723
32721
  if (resultFromCache) {
32724
- resultFromCache.failedLookupLocations.push(...failedLookupLocations);
32725
- resultFromCache.affectingLocations.push(...affectingLocations);
32722
+ resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
32723
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
32724
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
32726
32725
  return resultFromCache;
32727
32726
  }
32728
32727
  return {
32729
32728
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? void 0 : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId },
32730
- failedLookupLocations,
32731
- affectingLocations,
32732
- resolutionDiagnostics: diagnostics
32729
+ failedLookupLocations: initializeResolutionField(failedLookupLocations),
32730
+ affectingLocations: initializeResolutionField(affectingLocations),
32731
+ resolutionDiagnostics: initializeResolutionField(diagnostics)
32733
32732
  };
32734
32733
  }
32734
+ function initializeResolutionField(value) {
32735
+ return value.length ? value : void 0;
32736
+ }
32737
+ function updateResolutionField(to, value) {
32738
+ if (!(value == null ? void 0 : value.length))
32739
+ return to;
32740
+ if (!(to == null ? void 0 : to.length))
32741
+ return value;
32742
+ to.push(...value);
32743
+ return to;
32744
+ }
32735
32745
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
32736
32746
  if (!hasProperty(jsonContent, fieldName)) {
32737
32747
  if (state.traceEnabled) {
@@ -32937,7 +32947,12 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
32937
32947
  isExternalLibraryImport: pathContainsNodeModules(fileName)
32938
32948
  };
32939
32949
  }
32940
- result = { resolvedTypeReferenceDirective, failedLookupLocations, affectingLocations, resolutionDiagnostics: diagnostics };
32950
+ result = {
32951
+ resolvedTypeReferenceDirective,
32952
+ failedLookupLocations: initializeResolutionField(failedLookupLocations),
32953
+ affectingLocations: initializeResolutionField(affectingLocations),
32954
+ resolutionDiagnostics: initializeResolutionField(diagnostics)
32955
+ };
32941
32956
  perFolderCache == null ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
32942
32957
  if (traceEnabled)
32943
32958
  traceResult(result);
@@ -33197,18 +33212,12 @@ function createModeAwareCache() {
33197
33212
  return result;
33198
33213
  }
33199
33214
  }
33200
- function getResolutionName(entry) {
33201
- return !isString(entry) ? isStringLiteralLike(entry) ? entry.text : toFileNameLowerCase(entry.fileName) : entry;
33202
- }
33203
- function getResolutionMode(entry, file) {
33204
- return isStringLiteralLike(entry) ? getModeForUsageLocation(file, entry) : entry.resolutionMode || file.impliedNodeFormat;
33205
- }
33206
- function zipToModeAwareCache(file, keys, values) {
33215
+ function zipToModeAwareCache(file, keys, values, nameAndModeGetter) {
33207
33216
  Debug.assert(keys.length === values.length);
33208
33217
  const map2 = createModeAwareCache();
33209
33218
  for (let i = 0; i < keys.length; ++i) {
33210
33219
  const entry = keys[i];
33211
- map2.set(getResolutionName(entry), getResolutionMode(entry, file), values[i]);
33220
+ map2.set(nameAndModeGetter.getName(entry), nameAndModeGetter.getMode(entry, file), values[i]);
33212
33221
  }
33213
33222
  return map2;
33214
33223
  }
@@ -33306,13 +33315,6 @@ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanoni
33306
33315
  perDirectoryResolutionCache.clear();
33307
33316
  }
33308
33317
  }
33309
- function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
33310
- const containingDirectory = getDirectoryPath(containingFile);
33311
- const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
33312
- if (!perFolderCache)
33313
- return void 0;
33314
- return perFolderCache.get(moduleName, mode);
33315
- }
33316
33318
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
33317
33319
  const traceEnabled = isTraceEnabled(compilerOptions, host);
33318
33320
  if (redirectedReference) {
@@ -33497,7 +33499,7 @@ function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
33497
33499
  function resolveJSModule(moduleName, initialDir, host) {
33498
33500
  const { resolvedModule, failedLookupLocations } = tryResolveJSModuleWorker(moduleName, initialDir, host);
33499
33501
  if (!resolvedModule) {
33500
- throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations.join(", ")}`);
33502
+ throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations == null ? void 0 : failedLookupLocations.join(", ")}`);
33501
33503
  }
33502
33504
  return resolvedModule.resolvedFileName;
33503
33505
  }
@@ -38169,9 +38171,9 @@ function createTypeChecker(host) {
38169
38171
  host.getSourceFiles().forEach((sf) => {
38170
38172
  if (!sf.resolvedModules)
38171
38173
  return;
38172
- sf.resolvedModules.forEach((r) => {
38173
- if (r && r.packageId)
38174
- map2.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map2.get(r.packageId.name));
38174
+ sf.resolvedModules.forEach(({ resolvedModule }) => {
38175
+ if (resolvedModule == null ? void 0 : resolvedModule.packageId)
38176
+ map2.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map2.get(resolvedModule.packageId.name));
38175
38177
  });
38176
38178
  });
38177
38179
  return map2;
@@ -38975,6 +38977,12 @@ function createTypeChecker(host) {
38975
38977
  return diagnostic;
38976
38978
  }
38977
38979
  function isDeprecatedSymbol(symbol) {
38980
+ if (length(symbol.declarations) > 1) {
38981
+ const parentSymbol = getParentOfSymbol(symbol);
38982
+ if (parentSymbol && parentSymbol.flags & 64 /* Interface */) {
38983
+ return some(symbol.declarations, (d) => !!(getCombinedNodeFlags(d) & 268435456 /* Deprecated */));
38984
+ }
38985
+ }
38978
38986
  return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
38979
38987
  }
38980
38988
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
@@ -48668,7 +48676,7 @@ function createTypeChecker(host) {
48668
48676
  const resolved = resolveAlias(aliasSymbol2);
48669
48677
  if (resolved && resolved.flags & 524288 /* TypeAlias */) {
48670
48678
  newAliasSymbol = resolved;
48671
- aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node);
48679
+ aliasTypeArguments = typeArgumentsFromTypeReferenceNode(node) || (typeParameters ? [] : void 0);
48672
48680
  }
48673
48681
  }
48674
48682
  }
@@ -57484,13 +57492,13 @@ function createTypeChecker(host) {
57484
57492
  }
57485
57493
  const target = getReferenceCandidate(typeOfExpr.expression);
57486
57494
  if (!isMatchingReference(reference, target)) {
57487
- const propertyAccess = getDiscriminantPropertyAccess(typeOfExpr.expression, type);
57495
+ if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
57496
+ type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
57497
+ }
57498
+ const propertyAccess = getDiscriminantPropertyAccess(target, type);
57488
57499
  if (propertyAccess) {
57489
57500
  return narrowTypeByDiscriminant(type, propertyAccess, (t) => narrowTypeByLiteralExpression(t, literal, assumeTrue));
57490
57501
  }
57491
- if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
57492
- return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
57493
- }
57494
57502
  return type;
57495
57503
  }
57496
57504
  return narrowTypeByLiteralExpression(type, literal, assumeTrue);
@@ -71101,11 +71109,11 @@ function createTypeChecker(host) {
71101
71109
  let fileToDirective;
71102
71110
  if (resolvedTypeReferenceDirectives) {
71103
71111
  fileToDirective = /* @__PURE__ */ new Map();
71104
- resolvedTypeReferenceDirectives.forEach((resolvedDirective, key, mode) => {
71105
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
71112
+ resolvedTypeReferenceDirectives.forEach(({ resolvedTypeReferenceDirective }, key, mode) => {
71113
+ if (!(resolvedTypeReferenceDirective == null ? void 0 : resolvedTypeReferenceDirective.resolvedFileName)) {
71106
71114
  return;
71107
71115
  }
71108
- const file = host.getSourceFile(resolvedDirective.resolvedFileName);
71116
+ const file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
71109
71117
  if (file) {
71110
71118
  addReferencedFilesToTypeDirective(file, key, mode);
71111
71119
  }
@@ -97353,25 +97361,6 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
97353
97361
  }
97354
97362
  return result;
97355
97363
  }
97356
- function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
97357
- if (names.length === 0) {
97358
- return [];
97359
- }
97360
- const resolutions = [];
97361
- const cache = createModeAwareCache();
97362
- for (const name of names) {
97363
- let result;
97364
- const mode = getModeForFileReference(name, containingFileMode);
97365
- const strName = getResolutionName(name);
97366
- if (cache.has(strName, mode)) {
97367
- result = cache.get(strName, mode);
97368
- } else {
97369
- cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode));
97370
- }
97371
- resolutions.push(result);
97372
- }
97373
- return resolutions;
97374
- }
97375
97364
  function getModeForFileReference(ref, containingFileMode) {
97376
97365
  return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
97377
97366
  }
@@ -97437,22 +97426,65 @@ function getResolutionModeOverrideForClause(clause, grammarErrorOnNode) {
97437
97426
  }
97438
97427
  return elem.value.text === "import" ? 99 /* ESNext */ : 1 /* CommonJS */;
97439
97428
  }
97440
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, resolutionInfo, loader) {
97441
- if (names.length === 0) {
97442
- return [];
97443
- }
97429
+ var emptyResolution = {
97430
+ resolvedModule: void 0,
97431
+ resolvedTypeReferenceDirective: void 0
97432
+ };
97433
+ function getModuleResolutionName(literal) {
97434
+ return literal.text;
97435
+ }
97436
+ var moduleResolutionNameAndModeGetter = {
97437
+ getName: getModuleResolutionName,
97438
+ getMode: (entry, file) => getModeForUsageLocation(file, entry)
97439
+ };
97440
+ function createModuleResolutionLoader(containingFile, redirectedReference, options, host, cache) {
97441
+ return {
97442
+ nameAndMode: moduleResolutionNameAndModeGetter,
97443
+ resolve: (moduleName, resoluionMode) => resolveModuleName(
97444
+ moduleName,
97445
+ containingFile,
97446
+ options,
97447
+ host,
97448
+ cache,
97449
+ redirectedReference,
97450
+ resoluionMode
97451
+ )
97452
+ };
97453
+ }
97454
+ function getTypeReferenceResolutionName(entry) {
97455
+ return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry;
97456
+ }
97457
+ var typeReferenceResolutionNameAndModeGetter = {
97458
+ getName: getTypeReferenceResolutionName,
97459
+ getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
97460
+ };
97461
+ function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
97462
+ return {
97463
+ nameAndMode: typeReferenceResolutionNameAndModeGetter,
97464
+ resolve: (typeRef, resoluionMode) => resolveTypeReferenceDirective(
97465
+ typeRef,
97466
+ containingFile,
97467
+ options,
97468
+ host,
97469
+ redirectedReference,
97470
+ cache,
97471
+ resoluionMode
97472
+ )
97473
+ };
97474
+ }
97475
+ function loadWithModeAwareCache(entries, containingFile, redirectedReference, options, containingSourceFile, host, resolutionCache, createLoader) {
97476
+ if (entries.length === 0)
97477
+ return emptyArray;
97444
97478
  const resolutions = [];
97445
- const cache = createModeAwareCache();
97446
- let i = 0;
97447
- for (const entry of resolutionInfo ? resolutionInfo.names : names) {
97448
- let result;
97449
- const mode = !isString(entry) ? getModeForUsageLocation(containingFile, entry) : getModeForResolutionAtIndex(containingFile, i);
97450
- i++;
97451
- const name = isString(entry) ? entry : entry.text;
97452
- if (cache.has(name, mode)) {
97453
- result = cache.get(name, mode);
97454
- } else {
97455
- cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference));
97479
+ const cache = /* @__PURE__ */ new Map();
97480
+ const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache);
97481
+ for (const entry of entries) {
97482
+ const name = loader.nameAndMode.getName(entry);
97483
+ const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
97484
+ const key = createModeAwareCacheKey(name, mode);
97485
+ let result = cache.get(key);
97486
+ if (!result) {
97487
+ cache.set(key, result = loader.resolve(name, mode));
97456
97488
  }
97457
97489
  resolutions.push(result);
97458
97490
  }
@@ -97498,14 +97530,14 @@ function isReferenceFileLocation(location) {
97498
97530
  return location.pos !== void 0;
97499
97531
  }
97500
97532
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97501
- var _a2, _b, _c, _d;
97533
+ var _a2, _b, _c, _d, _e, _f;
97502
97534
  const file = Debug.checkDefined(getSourceFileByPath(ref.file));
97503
97535
  const { kind, index } = ref;
97504
97536
  let pos, end, packageId, resolutionMode;
97505
97537
  switch (kind) {
97506
97538
  case 3 /* Import */:
97507
97539
  const importLiteral = getModuleNameStringLiteralAt(file, index);
97508
- packageId = (_b = (_a2 = file.resolvedModules) == null ? void 0 : _a2.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) == null ? void 0 : _b.packageId;
97540
+ packageId = (_c = (_b = (_a2 = file.resolvedModules) == null ? void 0 : _a2.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) == null ? void 0 : _b.resolvedModule) == null ? void 0 : _c.packageId;
97509
97541
  if (importLiteral.pos === -1)
97510
97542
  return { file, packageId, text: importLiteral.text };
97511
97543
  pos = skipTrivia(file.text, importLiteral.pos);
@@ -97516,7 +97548,7 @@ function getReferencedFileLocation(getSourceFileByPath, ref) {
97516
97548
  break;
97517
97549
  case 5 /* TypeReferenceDirective */:
97518
97550
  ({ pos, end, resolutionMode } = file.typeReferenceDirectives[index]);
97519
- packageId = (_d = (_c = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _c.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) == null ? void 0 : _d.packageId;
97551
+ packageId = (_f = (_e = (_d = file.resolvedTypeReferenceDirectiveNames) == null ? void 0 : _d.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) == null ? void 0 : _e.resolvedTypeReferenceDirective) == null ? void 0 : _f.packageId;
97520
97552
  break;
97521
97553
  case 7 /* LibReferenceDirective */:
97522
97554
  ({ pos, end } = file.libReferenceDirectives[index]);
@@ -97705,7 +97737,7 @@ function createCreateProgramOptions(rootNames, options, host, oldProgram, config
97705
97737
  };
97706
97738
  }
97707
97739
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97708
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
97740
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
97709
97741
  const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97710
97742
  const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions;
97711
97743
  let { oldProgram } = createProgramOptions;
@@ -97722,6 +97754,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97722
97754
  const cachedDeclarationDiagnosticsForFile = {};
97723
97755
  let resolvedTypeReferenceDirectives = createModeAwareCache();
97724
97756
  let fileProcessingDiagnostics;
97757
+ let automaticTypeDirectiveNames;
97758
+ let automaticTypeDirectiveResolutions;
97725
97759
  const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97726
97760
  let currentNodeModulesDepth = 0;
97727
97761
  const modulesWithElidedImports = /* @__PURE__ */ new Map();
@@ -97740,50 +97774,59 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97740
97774
  const hasEmitBlockingDiagnostics = /* @__PURE__ */ new Map();
97741
97775
  let _compilerOptionsObjectLiteralSyntax;
97742
97776
  let moduleResolutionCache;
97743
- let typeReferenceDirectiveResolutionCache;
97744
97777
  let actualResolveModuleNamesWorker;
97745
97778
  const hasInvalidatedResolutions = host.hasInvalidatedResolutions || returnFalse;
97746
- if (host.resolveModuleNames) {
97747
- actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo) => {
97748
- var _a3;
97749
- return host.resolveModuleNames(
97750
- moduleNames.map((literal) => literal.text),
97751
- containingFileName,
97752
- (_a3 = resolutionInfo == null ? void 0 : resolutionInfo.reusedNames) == null ? void 0 : _a3.map((literal) => literal.text),
97753
- redirectedReference,
97754
- options,
97755
- containingFile,
97756
- resolutionInfo
97757
- ).map((resolved) => {
97758
- if (!resolved || resolved.extension !== void 0) {
97759
- return resolved;
97760
- }
97761
- const withExtension = clone(resolved);
97762
- withExtension.extension = extensionFromPath(resolved.resolvedFileName);
97763
- return withExtension;
97764
- });
97765
- };
97779
+ if (host.resolveModuleNameLiterals) {
97780
+ actualResolveModuleNamesWorker = host.resolveModuleNameLiterals.bind(host);
97766
97781
  moduleResolutionCache = (_b = host.getModuleResolutionCache) == null ? void 0 : _b.call(host);
97782
+ } else if (host.resolveModuleNames) {
97783
+ actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile, reusedNames) => host.resolveModuleNames(
97784
+ moduleNames.map(getModuleResolutionName),
97785
+ containingFile,
97786
+ reusedNames == null ? void 0 : reusedNames.map(getModuleResolutionName),
97787
+ redirectedReference,
97788
+ options2,
97789
+ containingSourceFile
97790
+ ).map(
97791
+ (resolved) => resolved ? resolved.extension !== void 0 ? { resolvedModule: resolved } : { resolvedModule: { ...resolved, extension: extensionFromPath(resolved.resolvedFileName) } } : emptyResolution
97792
+ );
97793
+ moduleResolutionCache = (_c = host.getModuleResolutionCache) == null ? void 0 : _c.call(host);
97767
97794
  } else {
97768
97795
  moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
97769
- const loader = (moduleName, resolverMode, containingFileName, redirectedReference) => resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule;
97770
- actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo) => loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo, loader);
97796
+ actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
97797
+ moduleNames,
97798
+ containingFile,
97799
+ redirectedReference,
97800
+ options2,
97801
+ containingSourceFile,
97802
+ host,
97803
+ moduleResolutionCache,
97804
+ createModuleResolutionLoader
97805
+ );
97771
97806
  }
97772
97807
  let actualResolveTypeReferenceDirectiveNamesWorker;
97773
- if (host.resolveTypeReferenceDirectives) {
97774
- actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo) => host.resolveTypeReferenceDirectives(Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode, resolutionInfo);
97808
+ if (host.resolveTypeReferenceDirectiveReferences) {
97809
+ actualResolveTypeReferenceDirectiveNamesWorker = host.resolveTypeReferenceDirectiveReferences.bind(host);
97810
+ } else if (host.resolveTypeReferenceDirectives) {
97811
+ actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => host.resolveTypeReferenceDirectives(
97812
+ typeDirectiveNames.map(getTypeReferenceResolutionName),
97813
+ containingFile,
97814
+ redirectedReference,
97815
+ options2,
97816
+ containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat
97817
+ ).map((resolvedTypeReferenceDirective) => ({ resolvedTypeReferenceDirective }));
97775
97818
  } else {
97776
- typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97777
- const loader = (typesRef, containingFile, redirectedReference, resolutionMode) => resolveTypeReferenceDirective(
97778
- typesRef,
97819
+ const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97820
+ actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
97821
+ typeDirectiveNames,
97779
97822
  containingFile,
97780
- options,
97781
- host,
97782
97823
  redirectedReference,
97824
+ options2,
97825
+ containingSourceFile,
97826
+ host,
97783
97827
  typeReferenceDirectiveResolutionCache,
97784
- resolutionMode
97785
- ).resolvedTypeReferenceDirective;
97786
- actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) => loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader);
97828
+ createTypeReferenceResolutionLoader
97829
+ );
97787
97830
  }
97788
97831
  const packageIdToSourceFile = /* @__PURE__ */ new Map();
97789
97832
  let sourceFileToPackageName = /* @__PURE__ */ new Map();
@@ -97796,7 +97839,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97796
97839
  let projectReferenceRedirects;
97797
97840
  let mapFromFileToProjectReferenceRedirects;
97798
97841
  let mapFromToProjectReferenceRedirectSource;
97799
- const useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _c.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
97842
+ const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
97800
97843
  const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
97801
97844
  compilerHost: host,
97802
97845
  getSymlinkCache,
@@ -97807,13 +97850,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97807
97850
  forEachResolvedProjectReference: forEachResolvedProjectReference2
97808
97851
  });
97809
97852
  const readFile = host.readFile.bind(host);
97810
- (_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97853
+ (_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97811
97854
  const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
97812
- (_e = tracing) == null ? void 0 : _e.pop();
97855
+ (_f = tracing) == null ? void 0 : _f.pop();
97813
97856
  let structureIsReused;
97814
- (_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
97857
+ (_g = tracing) == null ? void 0 : _g.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
97815
97858
  structureIsReused = tryReuseStructureFromOldProgram();
97816
- (_g = tracing) == null ? void 0 : _g.pop();
97859
+ (_h = tracing) == null ? void 0 : _h.pop();
97817
97860
  if (structureIsReused !== 2 /* Completely */) {
97818
97861
  processingDefaultLibFiles = [];
97819
97862
  processingOtherFiles = [];
@@ -97847,19 +97890,30 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97847
97890
  });
97848
97891
  }
97849
97892
  }
97850
- (_h = tracing) == null ? void 0 : _h.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
97893
+ (_i = tracing) == null ? void 0 : _i.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
97851
97894
  forEach(rootNames, (name, index) => processRootFile(name, false, false, { kind: 0 /* RootFile */, index }));
97852
- (_i = tracing) == null ? void 0 : _i.pop();
97853
- const typeReferences = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
97854
- if (typeReferences.length) {
97855
- (_j = tracing) == null ? void 0 : _j.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length });
97895
+ (_j = tracing) == null ? void 0 : _j.pop();
97896
+ automaticTypeDirectiveNames != null ? automaticTypeDirectiveNames : automaticTypeDirectiveNames = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
97897
+ automaticTypeDirectiveResolutions = createModeAwareCache();
97898
+ if (automaticTypeDirectiveNames.length) {
97899
+ (_k = tracing) == null ? void 0 : _k.push(tracing.Phase.Program, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
97856
97900
  const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97857
97901
  const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
97858
- const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeReferences, containingFilename);
97859
- for (let i = 0; i < typeReferences.length; i++) {
97860
- processTypeReferenceDirective(typeReferences[i], void 0, resolutions[i], { kind: 8 /* AutomaticTypeDirectiveFile */, typeReference: typeReferences[i], packageId: (_k = resolutions[i]) == null ? void 0 : _k.packageId });
97902
+ const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename);
97903
+ for (let i = 0; i < automaticTypeDirectiveNames.length; i++) {
97904
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], void 0, resolutions[i]);
97905
+ processTypeReferenceDirective(
97906
+ automaticTypeDirectiveNames[i],
97907
+ void 0,
97908
+ resolutions[i],
97909
+ {
97910
+ kind: 8 /* AutomaticTypeDirectiveFile */,
97911
+ typeReference: automaticTypeDirectiveNames[i],
97912
+ packageId: (_m = (_l = resolutions[i]) == null ? void 0 : _l.resolvedTypeReferenceDirective) == null ? void 0 : _m.packageId
97913
+ }
97914
+ );
97861
97915
  }
97862
- (_l = tracing) == null ? void 0 : _l.pop();
97916
+ (_n = tracing) == null ? void 0 : _n.pop();
97863
97917
  }
97864
97918
  if (rootNames.length && !skipDefaultLib) {
97865
97919
  const defaultLibraryFileName = getDefaultLibraryFileName();
@@ -97906,7 +97960,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97906
97960
  }
97907
97961
  );
97908
97962
  }
97909
- typeReferenceDirectiveResolutionCache = void 0;
97910
97963
  oldProgram = void 0;
97911
97964
  const program = {
97912
97965
  getRootFileNames: () => rootNames,
@@ -97939,6 +97992,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97939
97992
  getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
97940
97993
  getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
97941
97994
  getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
97995
+ getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
97996
+ getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
97942
97997
  isSourceFileFromExternalLibrary,
97943
97998
  isSourceFileDefaultLibrary,
97944
97999
  getSourceFileFromReference,
@@ -97948,7 +98003,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97948
98003
  usesUriStyleNodeCoreModules,
97949
98004
  isEmittedFile,
97950
98005
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
97951
- getResolvedModuleWithFailedLookupLocationsFromCache,
97952
98006
  getProjectReferences,
97953
98007
  getResolvedProjectReferences,
97954
98008
  getProjectReferenceRedirect,
@@ -97961,7 +98015,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97961
98015
  readFile,
97962
98016
  directoryExists,
97963
98017
  getSymlinkCache,
97964
- realpath: (_m = host.realpath) == null ? void 0 : _m.bind(host),
98018
+ realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
97965
98019
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
97966
98020
  getFileIncludeReasons: () => fileReasons,
97967
98021
  structureIsReused,
@@ -97975,6 +98029,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97975
98029
  case 0 /* FilePreprocessingReferencedDiagnostic */:
97976
98030
  const { file, pos, end } = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason);
97977
98031
  return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
98032
+ case 2 /* ResolutionDiagnostics */:
98033
+ return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
97978
98034
  default:
97979
98035
  Debug.assertNever(diagnostic);
97980
98036
  }
@@ -97982,32 +98038,30 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97982
98038
  verifyCompilerOptions();
97983
98039
  mark("afterProgram");
97984
98040
  measure("Program", "beforeProgram", "afterProgram");
97985
- (_n = tracing) == null ? void 0 : _n.pop();
98041
+ (_p = tracing) == null ? void 0 : _p.pop();
97986
98042
  return program;
97987
- function addResolutionDiagnostics(list) {
97988
- if (!list)
98043
+ function addResolutionDiagnostics(resolution) {
98044
+ var _a3;
98045
+ if (!((_a3 = resolution.resolutionDiagnostics) == null ? void 0 : _a3.length))
97989
98046
  return;
97990
- for (const elem of list) {
97991
- programDiagnostics.add(elem);
97992
- }
98047
+ (fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
98048
+ kind: 2 /* ResolutionDiagnostics */,
98049
+ diagnostics: resolution.resolutionDiagnostics
98050
+ });
97993
98051
  }
97994
- function pullDiagnosticsFromCache(names, containingFile) {
97995
- var _a3;
97996
- if (!moduleResolutionCache)
98052
+ function addResolutionDiagnosticsFromResolutionOrCache(containingFile, name, resolution, mode) {
98053
+ if (host.resolveModuleNameLiterals || !host.resolveModuleNames)
98054
+ return addResolutionDiagnostics(resolution);
98055
+ if (!moduleResolutionCache || isExternalModuleNameRelative(name))
97997
98056
  return;
97998
98057
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97999
98058
  const containingDir = getDirectoryPath(containingFileName);
98000
98059
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
98001
- for (const n of names) {
98002
- const mode = getResolutionMode(n, containingFile);
98003
- const name = getResolutionName(n);
98004
- if (isExternalModuleNameRelative(name))
98005
- continue;
98006
- const diags = (_a3 = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) == null ? void 0 : _a3.resolutionDiagnostics;
98007
- addResolutionDiagnostics(diags);
98008
- }
98060
+ const fromCache = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir);
98061
+ if (fromCache)
98062
+ addResolutionDiagnostics(fromCache);
98009
98063
  }
98010
- function resolveModuleNamesWorker(moduleNames, containingFile, resolutionInfo) {
98064
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
98011
98065
  var _a3, _b2;
98012
98066
  if (!moduleNames.length)
98013
98067
  return emptyArray;
@@ -98015,23 +98069,22 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98015
98069
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
98016
98070
  (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
98017
98071
  mark("beforeResolveModule");
98018
- const result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo);
98072
+ const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames);
98019
98073
  mark("afterResolveModule");
98020
98074
  measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
98021
98075
  (_b2 = tracing) == null ? void 0 : _b2.pop();
98022
- pullDiagnosticsFromCache(moduleNames, containingFile);
98023
98076
  return result;
98024
98077
  }
98025
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, resolutionInfo) {
98078
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, reusedNames) {
98026
98079
  var _a3, _b2;
98027
98080
  if (!typeDirectiveNames.length)
98028
98081
  return [];
98082
+ const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
98029
98083
  const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
98030
- const redirectedReference = !isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : void 0;
98031
- const containingFileMode = !isString(containingFile) ? containingFile.impliedNodeFormat : void 0;
98084
+ const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile);
98032
98085
  (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
98033
98086
  mark("beforeResolveTypeReference");
98034
- const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode, resolutionInfo);
98087
+ const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames);
98035
98088
  mark("afterResolveTypeReference");
98036
98089
  measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
98037
98090
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -98077,9 +98130,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98077
98130
  }
98078
98131
  return libs.length + 2;
98079
98132
  }
98080
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
98081
- return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
98082
- }
98083
98133
  function toPath3(fileName) {
98084
98134
  return toPath(fileName, currentDirectory, getCanonicalFileName);
98085
98135
  }
@@ -98108,6 +98158,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98108
98158
  return classifiableNames;
98109
98159
  }
98110
98160
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98161
+ var _a3;
98111
98162
  if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
98112
98163
  return resolveModuleNamesWorker(moduleNames, file, void 0);
98113
98164
  }
@@ -98123,24 +98174,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98123
98174
  let unknownModuleNames;
98124
98175
  let result;
98125
98176
  let reusedNames;
98126
- const predictedToResolveToAmbientModuleMarker = {};
98177
+ const predictedToResolveToAmbientModuleMarker = emptyResolution;
98127
98178
  for (let i = 0; i < moduleNames.length; i++) {
98128
98179
  const moduleName = moduleNames[i];
98129
98180
  if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
98130
98181
  const mode = getModeForUsageLocation(file, moduleName);
98131
- const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName.text, mode);
98132
- if (oldResolvedModule) {
98182
+ const oldResolution = (_a3 = oldSourceFile.resolvedModules) == null ? void 0 : _a3.get(moduleName.text, mode);
98183
+ if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
98133
98184
  if (isTraceEnabled(options, host)) {
98134
98185
  trace(
98135
98186
  host,
98136
- oldResolvedModule.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
98187
+ oldResolution.resolvedModule.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
98137
98188
  moduleName.text,
98138
98189
  getNormalizedAbsolutePath(file.originalFileName, currentDirectory),
98139
- oldResolvedModule.resolvedFileName,
98140
- oldResolvedModule.packageId && packageIdToString(oldResolvedModule.packageId)
98190
+ oldResolution.resolvedModule.resolvedFileName,
98191
+ oldResolution.resolvedModule.packageId && packageIdToString(oldResolution.resolvedModule.packageId)
98141
98192
  );
98142
98193
  }
98143
- (result != null ? result : result = new Array(moduleNames.length))[i] = oldResolvedModule;
98194
+ (result != null ? result : result = new Array(moduleNames.length))[i] = oldResolution;
98144
98195
  (reusedNames != null ? reusedNames : reusedNames = []).push(moduleName);
98145
98196
  continue;
98146
98197
  }
@@ -98160,18 +98211,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98160
98211
  (unknownModuleNames != null ? unknownModuleNames : unknownModuleNames = []).push(moduleName);
98161
98212
  }
98162
98213
  }
98163
- const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, { names: unknownModuleNames, reusedNames }) : emptyArray;
98214
+ const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray;
98164
98215
  if (!result) {
98165
98216
  Debug.assert(resolutions.length === moduleNames.length);
98166
98217
  return resolutions;
98167
98218
  }
98168
98219
  let j = 0;
98169
98220
  for (let i = 0; i < result.length; i++) {
98170
- if (result[i]) {
98171
- if (result[i] === predictedToResolveToAmbientModuleMarker) {
98172
- result[i] = void 0;
98173
- }
98174
- } else {
98221
+ if (!result[i]) {
98175
98222
  result[i] = resolutions[j];
98176
98223
  j++;
98177
98224
  }
@@ -98195,6 +98242,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98195
98242
  }
98196
98243
  }
98197
98244
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98245
+ var _a3;
98198
98246
  if (structureIsReused === 0 /* Not */) {
98199
98247
  return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, void 0);
98200
98248
  }
@@ -98203,7 +98251,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98203
98251
  if (oldSourceFile !== containingFile && containingFile.resolvedTypeReferenceDirectiveNames) {
98204
98252
  const result2 = [];
98205
98253
  for (const typeDirectiveName of typeDirectiveNames) {
98206
- const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getResolutionName(typeDirectiveName), typeDirectiveName.resolutionMode || containingFile.impliedNodeFormat);
98254
+ const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getTypeReferenceResolutionName(typeDirectiveName), getModeForFileReference(typeDirectiveName, containingFile.impliedNodeFormat));
98207
98255
  result2.push(resolvedTypeReferenceDirective);
98208
98256
  }
98209
98257
  return result2;
@@ -98217,21 +98265,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98217
98265
  for (let i = 0; i < typeDirectiveNames.length; i++) {
98218
98266
  const entry = typeDirectiveNames[i];
98219
98267
  if (canReuseResolutions) {
98220
- const typeDirectiveName = getResolutionName(entry);
98268
+ const typeDirectiveName = getTypeReferenceResolutionName(entry);
98221
98269
  const mode = getModeForFileReference(entry, containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat);
98222
- const oldResolvedTypeReferenceDirective = getResolvedTypeReferenceDirective(oldSourceFile, typeDirectiveName, mode);
98223
- if (oldResolvedTypeReferenceDirective) {
98270
+ const oldResolution = (_a3 = !isString(containingFile) ? oldSourceFile == null ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a3.get(typeDirectiveName, mode);
98271
+ if (oldResolution == null ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98224
98272
  if (isTraceEnabled(options, host)) {
98225
98273
  trace(
98226
98274
  host,
98227
- oldResolvedTypeReferenceDirective.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
98275
+ oldResolution.resolvedTypeReferenceDirective.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2,
98228
98276
  typeDirectiveName,
98229
98277
  !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile,
98230
- oldResolvedTypeReferenceDirective.resolvedFileName,
98231
- oldResolvedTypeReferenceDirective.packageId && packageIdToString(oldResolvedTypeReferenceDirective.packageId)
98278
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName,
98279
+ oldResolution.resolvedTypeReferenceDirective.packageId && packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId)
98232
98280
  );
98233
98281
  }
98234
- (result != null ? result : result = new Array(typeDirectiveNames.length))[i] = oldResolvedTypeReferenceDirective;
98282
+ (result != null ? result : result = new Array(typeDirectiveNames.length))[i] = oldResolution;
98235
98283
  (reusedNames != null ? reusedNames : reusedNames = []).push(entry);
98236
98284
  continue;
98237
98285
  }
@@ -98243,7 +98291,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98243
98291
  const resolutions = resolveTypeReferenceDirectiveNamesWorker(
98244
98292
  unknownTypeReferenceDirectiveNames,
98245
98293
  containingFile,
98246
- { names: unknownTypeReferenceDirectiveNames, reusedNames }
98294
+ reusedNames
98247
98295
  );
98248
98296
  if (!result) {
98249
98297
  Debug.assert(resolutions.length === typeDirectiveNames.length);
@@ -98279,7 +98327,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98279
98327
  );
98280
98328
  }
98281
98329
  function tryReuseStructureFromOldProgram() {
98282
- var _a3, _b2;
98330
+ var _a3;
98283
98331
  if (!oldProgram) {
98284
98332
  return 0 /* Not */;
98285
98333
  }
@@ -98389,19 +98437,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98389
98437
  for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
98390
98438
  const moduleNames = getModuleNames(newSourceFile);
98391
98439
  const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98392
- const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
98440
+ const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter);
98393
98441
  if (resolutionsChanged) {
98394
98442
  structureIsReused = 1 /* SafeModules */;
98395
- newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98443
+ newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions, moduleResolutionNameAndModeGetter);
98396
98444
  } else {
98397
98445
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98398
98446
  }
98399
98447
  const typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98400
98448
  const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98401
- const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
98449
+ const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter);
98402
98450
  if (typeReferenceResolutionsChanged) {
98403
98451
  structureIsReused = 1 /* SafeModules */;
98404
- newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98452
+ newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions, typeReferenceResolutionNameAndModeGetter);
98405
98453
  } else {
98406
98454
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98407
98455
  }
@@ -98409,9 +98457,17 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98409
98457
  if (structureIsReused !== 2 /* Completely */) {
98410
98458
  return structureIsReused;
98411
98459
  }
98412
- if (changesAffectingProgramStructure(oldOptions, options) || ((_b2 = host.hasChangedAutomaticTypeDirectiveNames) == null ? void 0 : _b2.call(host))) {
98460
+ if (changesAffectingProgramStructure(oldOptions, options)) {
98413
98461
  return 1 /* SafeModules */;
98414
98462
  }
98463
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
98464
+ if (host.hasChangedAutomaticTypeDirectiveNames())
98465
+ return 1 /* SafeModules */;
98466
+ } else {
98467
+ automaticTypeDirectiveNames = getAutomaticTypeDirectiveNames(options, host);
98468
+ if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98469
+ return 1 /* SafeModules */;
98470
+ }
98415
98471
  missingFilePaths = oldProgram.getMissingFilePaths();
98416
98472
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98417
98473
  for (const newSourceFile of newSourceFiles) {
@@ -98435,6 +98491,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98435
98491
  fileReasons = oldProgram.getFileIncludeReasons();
98436
98492
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98437
98493
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98494
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98495
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98438
98496
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98439
98497
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98440
98498
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
@@ -99378,7 +99436,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99378
99436
  }
99379
99437
  function processTypeReferenceDirectives(file) {
99380
99438
  const typeDirectives = file.typeReferenceDirectives;
99381
- if (!typeDirectives) {
99439
+ if (!typeDirectives.length) {
99440
+ file.resolvedTypeReferenceDirectiveNames = void 0;
99382
99441
  return;
99383
99442
  }
99384
99443
  const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
@@ -99389,23 +99448,31 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99389
99448
  setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99390
99449
  const mode = ref.resolutionMode || file.impliedNodeFormat;
99391
99450
  if (mode && getEmitModuleResolutionKind(options) !== 3 /* Node16 */ && getEmitModuleResolutionKind(options) !== 99 /* NodeNext */) {
99392
- programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99451
+ (fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
99452
+ kind: 2 /* ResolutionDiagnostics */,
99453
+ diagnostics: [
99454
+ createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)
99455
+ ]
99456
+ });
99393
99457
  }
99394
99458
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
99395
99459
  }
99396
99460
  }
99397
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99461
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99398
99462
  var _a3, _b2;
99399
- (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
99400
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99463
+ (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : void 0 });
99464
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99401
99465
  (_b2 = tracing) == null ? void 0 : _b2.pop();
99402
99466
  }
99403
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99404
- const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99467
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99468
+ var _a3;
99469
+ addResolutionDiagnostics(resolution);
99470
+ const previousResolution = (_a3 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a3.resolvedTypeReferenceDirective;
99405
99471
  if (previousResolution && previousResolution.primary) {
99406
99472
  return;
99407
99473
  }
99408
99474
  let saveResolution = true;
99475
+ const { resolvedTypeReferenceDirective } = resolution;
99409
99476
  if (resolvedTypeReferenceDirective) {
99410
99477
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99411
99478
  currentNodeModulesDepth++;
@@ -99436,7 +99503,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99436
99503
  addFilePreprocessingFileExplainingDiagnostic(void 0, reason, Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99437
99504
  }
99438
99505
  if (saveResolution) {
99439
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99506
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99440
99507
  }
99441
99508
  }
99442
99509
  function pathForLibFile(libFileName) {
@@ -99485,8 +99552,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99485
99552
  Debug.assert(resolutions.length === moduleNames.length);
99486
99553
  const optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a3 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a3.commandLine.options : void 0) || options;
99487
99554
  for (let index = 0; index < moduleNames.length; index++) {
99488
- const resolution = resolutions[index];
99489
- setResolvedModule(file, moduleNames[index].text, resolution, getModeForUsageLocation(file, moduleNames[index]));
99555
+ const resolution = resolutions[index].resolvedModule;
99556
+ const moduleName = moduleNames[index].text;
99557
+ const mode = getModeForUsageLocation(file, moduleNames[index]);
99558
+ setResolvedModule(file, moduleName, resolutions[index], mode);
99559
+ addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
99490
99560
  if (!resolution) {
99491
99561
  continue;
99492
99562
  }
@@ -100127,8 +100197,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
100127
100197
  if (!symlinks) {
100128
100198
  symlinks = createSymlinkCache(currentDirectory, getCanonicalFileName);
100129
100199
  }
100130
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
100131
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100200
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100201
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
100132
100202
  }
100133
100203
  return symlinks;
100134
100204
  }
@@ -100462,7 +100532,7 @@ var BuilderState;
100462
100532
  }
100463
100533
  }
100464
100534
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100465
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => {
100535
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(({ resolvedTypeReferenceDirective }) => {
100466
100536
  if (!resolvedTypeReferenceDirective) {
100467
100537
  return;
100468
100538
  }
@@ -101972,9 +102042,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
101972
102042
  finishRecordingFilesWithChangedResolutions,
101973
102043
  startCachingPerDirectoryResolution,
101974
102044
  finishCachingPerDirectoryResolution,
101975
- resolveModuleNames,
101976
- getResolvedModuleWithFailedLookupLocationsFromCache,
101977
- resolveTypeReferenceDirectives,
102045
+ resolveModuleNameLiterals,
102046
+ resolveTypeReferenceDirectiveReferences,
102047
+ resolveSingleModuleNameWithoutWatching,
101978
102048
  removeResolutionsFromProjectReferenceRedirects,
101979
102049
  removeResolutionsOfFile,
101980
102050
  hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames,
@@ -101990,7 +102060,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
101990
102060
  function getResolvedModule2(resolution) {
101991
102061
  return resolution.resolvedModule;
101992
102062
  }
101993
- function getResolvedTypeReferenceDirective2(resolution) {
102063
+ function getResolvedTypeReferenceDirective(resolution) {
101994
102064
  return resolution.resolvedTypeReferenceDirective;
101995
102065
  }
101996
102066
  function isInDirectoryPath(dir, file) {
@@ -102092,14 +102162,16 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102092
102162
  });
102093
102163
  hasChangedAutomaticTypeDirectiveNames = false;
102094
102164
  }
102095
- function resolveModuleName2(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102165
+ function resolveModuleName2(moduleName, containingFile, compilerOptions, redirectedReference, mode) {
102166
+ var _a2;
102167
+ const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
102096
102168
  const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
102097
102169
  if (!resolutionHost.getGlobalCache) {
102098
102170
  return primaryResult;
102099
102171
  }
102100
102172
  const globalCache = resolutionHost.getGlobalCache();
102101
102173
  if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
102102
- const { resolvedModule, failedLookupLocations, affectingLocations } = loadModuleFromGlobalCache(
102174
+ const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
102103
102175
  Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
102104
102176
  resolutionHost.projectName,
102105
102177
  compilerOptions,
@@ -102109,49 +102181,55 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102109
102181
  );
102110
102182
  if (resolvedModule) {
102111
102183
  primaryResult.resolvedModule = resolvedModule;
102112
- primaryResult.failedLookupLocations.push(...failedLookupLocations);
102113
- primaryResult.affectingLocations.push(...affectingLocations);
102184
+ primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations);
102185
+ primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102186
+ primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
102114
102187
  return primaryResult;
102115
102188
  }
102116
102189
  }
102117
102190
  return primaryResult;
102118
102191
  }
102119
- function resolveTypeReferenceDirective2(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
102120
- return resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
102192
+ function createModuleResolutionLoader2(containingFile, redirectedReference, options) {
102193
+ return {
102194
+ nameAndMode: moduleResolutionNameAndModeGetter,
102195
+ resolve: (moduleName, resoluionMode) => resolveModuleName2(
102196
+ moduleName,
102197
+ containingFile,
102198
+ options,
102199
+ redirectedReference,
102200
+ resoluionMode
102201
+ )
102202
+ };
102121
102203
  }
102122
102204
  function resolveNamesWithLocalCache({
102123
- names,
102205
+ entries,
102124
102206
  containingFile,
102207
+ containingSourceFile,
102125
102208
  redirectedReference,
102209
+ options,
102126
102210
  perFileCache,
102211
+ reusedNames,
102127
102212
  loader,
102128
102213
  getResolutionWithResolvedFileName,
102129
102214
  shouldRetryResolution,
102130
- reusedNames,
102131
- resolutionInfo,
102132
- logChanges,
102133
- containingSourceFile,
102134
- containingSourceFileMode
102215
+ logChanges
102135
102216
  }) {
102136
- var _a2, _b, _c;
102217
+ var _a2;
102137
102218
  const path = resolutionHost.toPath(containingFile);
102138
102219
  const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
102139
102220
  const resolvedModules = [];
102140
- const compilerOptions = resolutionHost.getCompilationSettings();
102141
102221
  const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
102142
102222
  const program = resolutionHost.getCurrentProgram();
102143
102223
  const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
102144
102224
  const unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference;
102145
102225
  const seenNamesInFile = createModeAwareCache();
102146
- let i = 0;
102147
- for (const entry of containingSourceFile && resolutionInfo ? resolutionInfo.names : names) {
102148
- const name = getResolutionName(entry);
102149
- const mode = !isString(entry) ? isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode) : containingSourceFile ? getModeForResolutionAtIndex(containingSourceFile, i) : void 0;
102150
- i++;
102226
+ for (const entry of entries) {
102227
+ const name = loader.nameAndMode.getName(entry);
102228
+ const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
102151
102229
  let resolution = resolutionsInFile.get(name, mode);
102152
102230
  if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
102153
102231
  const existingResolution = resolution;
102154
- resolution = loader(name, containingFile, compilerOptions, ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102232
+ resolution = loader.resolve(name, mode);
102155
102233
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102156
102234
  resolutionHost.onDiscoveredSymlink();
102157
102235
  }
@@ -102165,12 +102243,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102165
102243
  logChanges = false;
102166
102244
  }
102167
102245
  } else {
102168
- const host = ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost;
102169
- if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
102246
+ const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
102247
+ if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
102170
102248
  const resolved = getResolutionWithResolvedFileName(resolution);
102171
102249
  trace(
102172
102250
  host,
102173
- loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved,
102251
+ perFileCache === resolvedModuleNames ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved,
102174
102252
  name,
102175
102253
  containingFile,
102176
102254
  resolved == null ? void 0 : resolved.resolvedFileName,
@@ -102180,19 +102258,16 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102180
102258
  }
102181
102259
  Debug.assert(resolution !== void 0 && !resolution.isInvalidated);
102182
102260
  seenNamesInFile.set(name, mode, true);
102183
- resolvedModules.push(getResolutionWithResolvedFileName(resolution));
102184
- }
102185
- if (resolutionInfo && (loader === resolveTypeReferenceDirective2 || containingSourceFile)) {
102186
- (_c = resolutionInfo.reusedNames) == null ? void 0 : _c.forEach((entry) => seenNamesInFile.set(
102187
- getResolutionName(entry),
102188
- !isString(entry) && isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode),
102189
- true
102190
- ));
102191
- reusedNames = void 0;
102261
+ resolvedModules.push(resolution);
102192
102262
  }
102263
+ reusedNames == null ? void 0 : reusedNames.forEach((entry) => seenNamesInFile.set(
102264
+ loader.nameAndMode.getName(entry),
102265
+ loader.nameAndMode.getMode(entry, containingSourceFile),
102266
+ true
102267
+ ));
102193
102268
  if (resolutionsInFile.size() !== seenNamesInFile.size()) {
102194
102269
  resolutionsInFile.forEach((resolution, name, mode) => {
102195
- if (!seenNamesInFile.has(name, mode) && !contains(reusedNames, name)) {
102270
+ if (!seenNamesInFile.has(name, mode)) {
102196
102271
  stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
102197
102272
  resolutionsInFile.delete(name, mode);
102198
102273
  }
@@ -102217,39 +102292,53 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102217
102292
  return oldResult.resolvedFileName === newResult.resolvedFileName;
102218
102293
  }
102219
102294
  }
102220
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo) {
102295
+ function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
102296
+ var _a2;
102221
102297
  return resolveNamesWithLocalCache({
102222
- names: typeDirectiveNames,
102298
+ entries: typeDirectiveReferences,
102223
102299
  containingFile,
102300
+ containingSourceFile,
102224
102301
  redirectedReference,
102302
+ options,
102303
+ reusedNames,
102225
102304
  perFileCache: resolvedTypeReferenceDirectives,
102226
- loader: resolveTypeReferenceDirective2,
102227
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
102228
- shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
102229
- containingSourceFileMode: containingFileMode,
102230
- resolutionInfo
102305
+ loader: createTypeReferenceResolutionLoader(
102306
+ containingFile,
102307
+ redirectedReference,
102308
+ options,
102309
+ ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost,
102310
+ typeReferenceDirectiveResolutionCache
102311
+ ),
102312
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
102313
+ shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0
102231
102314
  });
102232
102315
  }
102233
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile, resolutionInfo) {
102316
+ function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
102234
102317
  return resolveNamesWithLocalCache({
102235
- names: moduleNames,
102318
+ entries: moduleLiterals,
102236
102319
  containingFile,
102320
+ containingSourceFile,
102237
102321
  redirectedReference,
102322
+ options,
102323
+ reusedNames,
102238
102324
  perFileCache: resolvedModuleNames,
102239
- loader: resolveModuleName2,
102325
+ loader: createModuleResolutionLoader2(
102326
+ containingFile,
102327
+ redirectedReference,
102328
+ options
102329
+ ),
102240
102330
  getResolutionWithResolvedFileName: getResolvedModule2,
102241
102331
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
102242
- reusedNames,
102243
- resolutionInfo,
102244
- logChanges: logChangesWhenResolvingModule,
102245
- containingSourceFile
102332
+ logChanges: logChangesWhenResolvingModule
102246
102333
  });
102247
102334
  }
102248
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
102249
- const cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
102250
- if (!cache)
102251
- return void 0;
102252
- return cache.get(moduleName, resolutionMode);
102335
+ function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
102336
+ const path = resolutionHost.toPath(containingFile);
102337
+ const resolutionsInFile = resolvedModuleNames.get(path);
102338
+ const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get(moduleName, void 0);
102339
+ if (resolution && !resolution.isInvalidated)
102340
+ return resolution;
102341
+ return resolveModuleName2(moduleName, containingFile, resolutionHost.getCompilationSettings());
102253
102342
  }
102254
102343
  function isNodeModulesAtTypesDirectory(dirPath) {
102255
102344
  return endsWith(dirPath, "/node_modules/@types");
@@ -102328,37 +102417,39 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102328
102417
  function watchFailedLookupLocationOfResolution(resolution) {
102329
102418
  Debug.assert(!!resolution.refCount);
102330
102419
  const { failedLookupLocations, affectingLocations } = resolution;
102331
- if (!failedLookupLocations.length && !affectingLocations.length)
102420
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
102332
102421
  return;
102333
- if (failedLookupLocations.length)
102422
+ if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
102334
102423
  resolutionsWithFailedLookups.push(resolution);
102335
102424
  let setAtRoot = false;
102336
- for (const failedLookupLocation of failedLookupLocations) {
102337
- const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102338
- const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102339
- if (toWatch) {
102340
- const { dir, dirPath, nonRecursive } = toWatch;
102341
- if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
102342
- const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
102343
- customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
102344
- }
102345
- if (dirPath === rootPath) {
102346
- Debug.assert(!nonRecursive);
102347
- setAtRoot = true;
102348
- } else {
102349
- setDirectoryWatcher(dir, dirPath, nonRecursive);
102425
+ if (failedLookupLocations) {
102426
+ for (const failedLookupLocation of failedLookupLocations) {
102427
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102428
+ const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102429
+ if (toWatch) {
102430
+ const { dir, dirPath, nonRecursive } = toWatch;
102431
+ if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
102432
+ const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
102433
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
102434
+ }
102435
+ if (dirPath === rootPath) {
102436
+ Debug.assert(!nonRecursive);
102437
+ setAtRoot = true;
102438
+ } else {
102439
+ setDirectoryWatcher(dir, dirPath, nonRecursive);
102440
+ }
102350
102441
  }
102351
102442
  }
102443
+ if (setAtRoot) {
102444
+ setDirectoryWatcher(rootDir, rootPath, true);
102445
+ }
102352
102446
  }
102353
- if (setAtRoot) {
102354
- setDirectoryWatcher(rootDir, rootPath, true);
102355
- }
102356
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
102447
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length));
102357
102448
  }
102358
102449
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
102359
102450
  Debug.assert(!!resolution.refCount);
102360
102451
  const { affectingLocations } = resolution;
102361
- if (!affectingLocations.length)
102452
+ if (!(affectingLocations == null ? void 0 : affectingLocations.length))
102362
102453
  return;
102363
102454
  if (addToResolutionsWithOnlyAffectingLocations)
102364
102455
  resolutionsWithOnlyAffectingLocations.push(resolution);
@@ -102476,12 +102567,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102476
102567
  if (removeAtRoot) {
102477
102568
  removeDirectoryWatcher(rootPath);
102478
102569
  }
102479
- } else if (affectingLocations.length) {
102570
+ } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
102480
102571
  unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102481
102572
  }
102482
- for (const affectingLocation of affectingLocations) {
102483
- const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102484
- watcher.resolutions--;
102573
+ if (affectingLocations) {
102574
+ for (const affectingLocation of affectingLocations) {
102575
+ const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102576
+ watcher.resolutions--;
102577
+ }
102485
102578
  }
102486
102579
  }
102487
102580
  function removeDirectoryWatcher(dirPath) {
@@ -102517,7 +102610,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102517
102610
  }
102518
102611
  function removeResolutionsOfFile(filePath) {
102519
102612
  removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule2);
102520
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective2);
102613
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
102521
102614
  }
102522
102615
  function invalidateResolutions(resolutions, canInvalidate) {
102523
102616
  if (!resolutions)
@@ -102603,17 +102696,19 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102603
102696
  return invalidated;
102604
102697
  }
102605
102698
  function canInvalidateFailedLookupResolution(resolution) {
102699
+ var _a2;
102606
102700
  if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
102607
102701
  return true;
102608
102702
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
102609
102703
  return false;
102610
- return resolution.failedLookupLocations.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
102704
+ return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
102611
102705
  }
102612
102706
  function isInvalidatedFailedLookup(locationPath) {
102613
102707
  return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || emptyIterator, (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || emptyIterator, (fileOrDirectoryPath) => isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : void 0);
102614
102708
  }
102615
102709
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102616
- return !!affectingPathChecks && resolution.affectingLocations.some((location) => affectingPathChecks.has(location));
102710
+ var _a2;
102711
+ return !!affectingPathChecks && ((_a2 = resolution.affectingLocations) == null ? void 0 : _a2.some((location) => affectingPathChecks.has(location)));
102617
102712
  }
102618
102713
  function closeTypeRootsWatch() {
102619
102714
  clearMap(typeRootsWatches, closeFileWatcher);
@@ -103379,10 +103474,18 @@ function createWatchProgram(host) {
103379
103474
  configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory,
103380
103475
  false
103381
103476
  );
103382
- compilerHost.resolveModuleNames = host.resolveModuleNames ? (...args) => host.resolveModuleNames(...args) : (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile, resolutionInfo) => resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile, resolutionInfo);
103383
- compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? (...args) => host.resolveTypeReferenceDirectives(...args) : (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, resolutionInfo) => resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo);
103384
- compilerHost.getModuleResolutionCache = host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
103385
- const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103477
+ compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
103478
+ compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
103479
+ if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
103480
+ compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache);
103481
+ }
103482
+ compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
103483
+ compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
103484
+ if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
103485
+ compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
103486
+ }
103487
+ compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
103488
+ const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103386
103489
  const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
103387
103490
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
103388
103491
  synchronizeProgram();
@@ -104021,19 +104124,38 @@ function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, optio
104021
104124
  const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
104022
104125
  setGetSourceFileAsHashVersioned(compilerHost);
104023
104126
  compilerHost.getParsedCommandLine = (fileName) => parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName));
104127
+ compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
104128
+ compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
104024
104129
  compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
104025
104130
  compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
104026
104131
  compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache);
104027
- const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : void 0;
104028
- const typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : void 0;
104029
- if (!compilerHost.resolveModuleNames) {
104030
- const loader = (moduleName, resolverMode, containingFile, redirectedReference) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule;
104031
- compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, resolutionInfo) => loadWithModeAwareCache(Debug.checkEachDefined(moduleNames), Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, resolutionInfo, loader);
104132
+ let moduleResolutionCache, typeReferenceDirectiveResolutionCache;
104133
+ if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
104134
+ moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName);
104135
+ compilerHost.resolveModuleNameLiterals = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
104136
+ moduleNames,
104137
+ containingFile,
104138
+ redirectedReference,
104139
+ options2,
104140
+ containingSourceFile,
104141
+ host,
104142
+ moduleResolutionCache,
104143
+ createModuleResolutionLoader
104144
+ );
104032
104145
  compilerHost.getModuleResolutionCache = () => moduleResolutionCache;
104033
104146
  }
104034
- if (!compilerHost.resolveTypeReferenceDirectives) {
104035
- const loader = (moduleName, containingFile, redirectedReference, containingFileMode) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective;
104036
- compilerHost.resolveTypeReferenceDirectives = (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) => loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader);
104147
+ if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
104148
+ typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
104149
+ compilerHost.resolveTypeReferenceDirectiveReferences = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
104150
+ typeDirectiveNames,
104151
+ containingFile,
104152
+ redirectedReference,
104153
+ options2,
104154
+ containingSourceFile,
104155
+ host,
104156
+ typeReferenceDirectiveResolutionCache,
104157
+ createTypeReferenceResolutionLoader
104158
+ );
104037
104159
  }
104038
104160
  compilerHost.getBuildInfo = (fileName, configFilePath) => getBuildInfo3(state, fileName, toResolvedConfigFilePath(state, configFilePath), void 0);
104039
104161
  const { watchFile: watchFile2, watchDirectory, writeLog } = createWatchFactory(hostWithWatch, options);