@typescript-deploys/pr-build 5.0.0-pr-51725-7 → 5.0.0-pr-51373-23

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-insiders.20221202`;
26
+ var version = `${versionMajorMinor}.0-insiders.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
  }
@@ -37837,7 +37839,7 @@ function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory,
37837
37839
  if (!shortest) {
37838
37840
  return void 0;
37839
37841
  }
37840
- return getEmitModuleResolutionKind(compilerOptions) === 2 /* NodeJs */ ? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions) : removeFileExtension(shortest);
37842
+ return getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */ ? removeFileExtension(shortest) : removeExtensionAndIndexPostFix(shortest, ending, compilerOptions);
37841
37843
  }
37842
37844
  function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileName, sourceDirectory }, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
37843
37845
  if (!host.fileExists || !host.readFile) {
@@ -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
  }
@@ -48911,7 +48919,7 @@ function createTypeChecker(host) {
48911
48919
  const links = getNodeLinks(node);
48912
48920
  if (!links.resolvedType) {
48913
48921
  const type = checkExpressionWithTypeArguments(node);
48914
- links.resolvedType = getWidenedType(type);
48922
+ links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
48915
48923
  }
48916
48924
  return links.resolvedType;
48917
48925
  }
@@ -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);
@@ -67973,7 +67981,6 @@ function createTypeChecker(host) {
67973
67981
  let firstDefaultClause;
67974
67982
  let hasDuplicateDefaultClause = false;
67975
67983
  const expressionType = checkExpression(node.expression);
67976
- const expressionIsLiteral = isLiteralType(expressionType);
67977
67984
  forEach(node.caseBlock.clauses, (clause) => {
67978
67985
  if (clause.kind === 293 /* DefaultClause */ && !hasDuplicateDefaultClause) {
67979
67986
  if (firstDefaultClause === void 0) {
@@ -67992,15 +67999,9 @@ function createTypeChecker(host) {
67992
67999
  }
67993
68000
  function createLazyCaseClauseDiagnostics(clause2) {
67994
68001
  return () => {
67995
- let caseType = checkExpression(clause2.expression);
67996
- const caseIsLiteral = isLiteralType(caseType);
67997
- let comparedExpressionType = expressionType;
67998
- if (!caseIsLiteral || !expressionIsLiteral) {
67999
- caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
68000
- comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
68001
- }
68002
- if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
68003
- checkTypeComparableTo(caseType, comparedExpressionType, clause2.expression, void 0);
68002
+ const caseType = checkExpression(clause2.expression);
68003
+ if (!isTypeEqualityComparableTo(expressionType, caseType)) {
68004
+ checkTypeComparableTo(caseType, expressionType, clause2.expression, void 0);
68004
68005
  }
68005
68006
  };
68006
68007
  }
@@ -71101,11 +71102,11 @@ function createTypeChecker(host) {
71101
71102
  let fileToDirective;
71102
71103
  if (resolvedTypeReferenceDirectives) {
71103
71104
  fileToDirective = /* @__PURE__ */ new Map();
71104
- resolvedTypeReferenceDirectives.forEach((resolvedDirective, key, mode) => {
71105
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
71105
+ resolvedTypeReferenceDirectives.forEach(({ resolvedTypeReferenceDirective }, key, mode) => {
71106
+ if (!(resolvedTypeReferenceDirective == null ? void 0 : resolvedTypeReferenceDirective.resolvedFileName)) {
71106
71107
  return;
71107
71108
  }
71108
- const file = host.getSourceFile(resolvedDirective.resolvedFileName);
71109
+ const file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
71109
71110
  if (file) {
71110
71111
  addReferencedFilesToTypeDirective(file, key, mode);
71111
71112
  }
@@ -97353,25 +97354,6 @@ function flattenDiagnosticMessageText(diag2, newLine, indent2 = 0) {
97353
97354
  }
97354
97355
  return result;
97355
97356
  }
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
97357
  function getModeForFileReference(ref, containingFileMode) {
97376
97358
  return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
97377
97359
  }
@@ -97437,22 +97419,65 @@ function getResolutionModeOverrideForClause(clause, grammarErrorOnNode) {
97437
97419
  }
97438
97420
  return elem.value.text === "import" ? 99 /* ESNext */ : 1 /* CommonJS */;
97439
97421
  }
97440
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, resolutionInfo, loader) {
97441
- if (names.length === 0) {
97442
- return [];
97443
- }
97422
+ var emptyResolution = {
97423
+ resolvedModule: void 0,
97424
+ resolvedTypeReferenceDirective: void 0
97425
+ };
97426
+ function getModuleResolutionName(literal) {
97427
+ return literal.text;
97428
+ }
97429
+ var moduleResolutionNameAndModeGetter = {
97430
+ getName: getModuleResolutionName,
97431
+ getMode: (entry, file) => getModeForUsageLocation(file, entry)
97432
+ };
97433
+ function createModuleResolutionLoader(containingFile, redirectedReference, options, host, cache) {
97434
+ return {
97435
+ nameAndMode: moduleResolutionNameAndModeGetter,
97436
+ resolve: (moduleName, resoluionMode) => resolveModuleName(
97437
+ moduleName,
97438
+ containingFile,
97439
+ options,
97440
+ host,
97441
+ cache,
97442
+ redirectedReference,
97443
+ resoluionMode
97444
+ )
97445
+ };
97446
+ }
97447
+ function getTypeReferenceResolutionName(entry) {
97448
+ return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry;
97449
+ }
97450
+ var typeReferenceResolutionNameAndModeGetter = {
97451
+ getName: getTypeReferenceResolutionName,
97452
+ getMode: (entry, file) => getModeForFileReference(entry, file == null ? void 0 : file.impliedNodeFormat)
97453
+ };
97454
+ function createTypeReferenceResolutionLoader(containingFile, redirectedReference, options, host, cache) {
97455
+ return {
97456
+ nameAndMode: typeReferenceResolutionNameAndModeGetter,
97457
+ resolve: (typeRef, resoluionMode) => resolveTypeReferenceDirective(
97458
+ typeRef,
97459
+ containingFile,
97460
+ options,
97461
+ host,
97462
+ redirectedReference,
97463
+ cache,
97464
+ resoluionMode
97465
+ )
97466
+ };
97467
+ }
97468
+ function loadWithModeAwareCache(entries, containingFile, redirectedReference, options, containingSourceFile, host, resolutionCache, createLoader) {
97469
+ if (entries.length === 0)
97470
+ return emptyArray;
97444
97471
  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));
97472
+ const cache = /* @__PURE__ */ new Map();
97473
+ const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache);
97474
+ for (const entry of entries) {
97475
+ const name = loader.nameAndMode.getName(entry);
97476
+ const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
97477
+ const key = createModeAwareCacheKey(name, mode);
97478
+ let result = cache.get(key);
97479
+ if (!result) {
97480
+ cache.set(key, result = loader.resolve(name, mode));
97456
97481
  }
97457
97482
  resolutions.push(result);
97458
97483
  }
@@ -97498,14 +97523,14 @@ function isReferenceFileLocation(location) {
97498
97523
  return location.pos !== void 0;
97499
97524
  }
97500
97525
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97501
- var _a2, _b, _c, _d;
97526
+ var _a2, _b, _c, _d, _e, _f;
97502
97527
  const file = Debug.checkDefined(getSourceFileByPath(ref.file));
97503
97528
  const { kind, index } = ref;
97504
97529
  let pos, end, packageId, resolutionMode;
97505
97530
  switch (kind) {
97506
97531
  case 3 /* Import */:
97507
97532
  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;
97533
+ 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
97534
  if (importLiteral.pos === -1)
97510
97535
  return { file, packageId, text: importLiteral.text };
97511
97536
  pos = skipTrivia(file.text, importLiteral.pos);
@@ -97516,7 +97541,7 @@ function getReferencedFileLocation(getSourceFileByPath, ref) {
97516
97541
  break;
97517
97542
  case 5 /* TypeReferenceDirective */:
97518
97543
  ({ 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;
97544
+ 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
97545
  break;
97521
97546
  case 7 /* LibReferenceDirective */:
97522
97547
  ({ pos, end } = file.libReferenceDirectives[index]);
@@ -97705,7 +97730,7 @@ function createCreateProgramOptions(rootNames, options, host, oldProgram, config
97705
97730
  };
97706
97731
  }
97707
97732
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97708
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
97733
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
97709
97734
  const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97710
97735
  const { rootNames, options, configFileParsingDiagnostics, projectReferences } = createProgramOptions;
97711
97736
  let { oldProgram } = createProgramOptions;
@@ -97722,6 +97747,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97722
97747
  const cachedDeclarationDiagnosticsForFile = {};
97723
97748
  let resolvedTypeReferenceDirectives = createModeAwareCache();
97724
97749
  let fileProcessingDiagnostics;
97750
+ let automaticTypeDirectiveNames;
97751
+ let automaticTypeDirectiveResolutions;
97725
97752
  const maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97726
97753
  let currentNodeModulesDepth = 0;
97727
97754
  const modulesWithElidedImports = /* @__PURE__ */ new Map();
@@ -97740,50 +97767,59 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97740
97767
  const hasEmitBlockingDiagnostics = /* @__PURE__ */ new Map();
97741
97768
  let _compilerOptionsObjectLiteralSyntax;
97742
97769
  let moduleResolutionCache;
97743
- let typeReferenceDirectiveResolutionCache;
97744
97770
  let actualResolveModuleNamesWorker;
97745
97771
  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
- };
97772
+ if (host.resolveModuleNameLiterals) {
97773
+ actualResolveModuleNamesWorker = host.resolveModuleNameLiterals.bind(host);
97766
97774
  moduleResolutionCache = (_b = host.getModuleResolutionCache) == null ? void 0 : _b.call(host);
97775
+ } else if (host.resolveModuleNames) {
97776
+ actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile, reusedNames) => host.resolveModuleNames(
97777
+ moduleNames.map(getModuleResolutionName),
97778
+ containingFile,
97779
+ reusedNames == null ? void 0 : reusedNames.map(getModuleResolutionName),
97780
+ redirectedReference,
97781
+ options2,
97782
+ containingSourceFile
97783
+ ).map(
97784
+ (resolved) => resolved ? resolved.extension !== void 0 ? { resolvedModule: resolved } : { resolvedModule: { ...resolved, extension: extensionFromPath(resolved.resolvedFileName) } } : emptyResolution
97785
+ );
97786
+ moduleResolutionCache = (_c = host.getModuleResolutionCache) == null ? void 0 : _c.call(host);
97767
97787
  } else {
97768
97788
  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);
97789
+ actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
97790
+ moduleNames,
97791
+ containingFile,
97792
+ redirectedReference,
97793
+ options2,
97794
+ containingSourceFile,
97795
+ host,
97796
+ moduleResolutionCache,
97797
+ createModuleResolutionLoader
97798
+ );
97771
97799
  }
97772
97800
  let actualResolveTypeReferenceDirectiveNamesWorker;
97773
- if (host.resolveTypeReferenceDirectives) {
97774
- actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo) => host.resolveTypeReferenceDirectives(Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode, resolutionInfo);
97801
+ if (host.resolveTypeReferenceDirectiveReferences) {
97802
+ actualResolveTypeReferenceDirectiveNamesWorker = host.resolveTypeReferenceDirectiveReferences.bind(host);
97803
+ } else if (host.resolveTypeReferenceDirectives) {
97804
+ actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => host.resolveTypeReferenceDirectives(
97805
+ typeDirectiveNames.map(getTypeReferenceResolutionName),
97806
+ containingFile,
97807
+ redirectedReference,
97808
+ options2,
97809
+ containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat
97810
+ ).map((resolvedTypeReferenceDirective) => ({ resolvedTypeReferenceDirective }));
97775
97811
  } else {
97776
- typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97777
- const loader = (typesRef, containingFile, redirectedReference, resolutionMode) => resolveTypeReferenceDirective(
97778
- typesRef,
97812
+ const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97813
+ actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
97814
+ typeDirectiveNames,
97779
97815
  containingFile,
97780
- options,
97781
- host,
97782
97816
  redirectedReference,
97817
+ options2,
97818
+ containingSourceFile,
97819
+ host,
97783
97820
  typeReferenceDirectiveResolutionCache,
97784
- resolutionMode
97785
- ).resolvedTypeReferenceDirective;
97786
- actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) => loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader);
97821
+ createTypeReferenceResolutionLoader
97822
+ );
97787
97823
  }
97788
97824
  const packageIdToSourceFile = /* @__PURE__ */ new Map();
97789
97825
  let sourceFileToPackageName = /* @__PURE__ */ new Map();
@@ -97796,7 +97832,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97796
97832
  let projectReferenceRedirects;
97797
97833
  let mapFromFileToProjectReferenceRedirects;
97798
97834
  let mapFromToProjectReferenceRedirectSource;
97799
- const useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _c.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
97835
+ const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
97800
97836
  const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
97801
97837
  compilerHost: host,
97802
97838
  getSymlinkCache,
@@ -97807,13 +97843,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97807
97843
  forEachResolvedProjectReference: forEachResolvedProjectReference2
97808
97844
  });
97809
97845
  const readFile = host.readFile.bind(host);
97810
- (_d = tracing) == null ? void 0 : _d.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97846
+ (_e = tracing) == null ? void 0 : _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97811
97847
  const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
97812
- (_e = tracing) == null ? void 0 : _e.pop();
97848
+ (_f = tracing) == null ? void 0 : _f.pop();
97813
97849
  let structureIsReused;
97814
- (_f = tracing) == null ? void 0 : _f.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
97850
+ (_g = tracing) == null ? void 0 : _g.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
97815
97851
  structureIsReused = tryReuseStructureFromOldProgram();
97816
- (_g = tracing) == null ? void 0 : _g.pop();
97852
+ (_h = tracing) == null ? void 0 : _h.pop();
97817
97853
  if (structureIsReused !== 2 /* Completely */) {
97818
97854
  processingDefaultLibFiles = [];
97819
97855
  processingOtherFiles = [];
@@ -97847,19 +97883,30 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97847
97883
  });
97848
97884
  }
97849
97885
  }
97850
- (_h = tracing) == null ? void 0 : _h.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
97886
+ (_i = tracing) == null ? void 0 : _i.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
97851
97887
  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 });
97888
+ (_j = tracing) == null ? void 0 : _j.pop();
97889
+ automaticTypeDirectiveNames != null ? automaticTypeDirectiveNames : automaticTypeDirectiveNames = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
97890
+ automaticTypeDirectiveResolutions = createModeAwareCache();
97891
+ if (automaticTypeDirectiveNames.length) {
97892
+ (_k = tracing) == null ? void 0 : _k.push(tracing.Phase.Program, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
97856
97893
  const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97857
97894
  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 });
97895
+ const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename);
97896
+ for (let i = 0; i < automaticTypeDirectiveNames.length; i++) {
97897
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], void 0, resolutions[i]);
97898
+ processTypeReferenceDirective(
97899
+ automaticTypeDirectiveNames[i],
97900
+ void 0,
97901
+ resolutions[i],
97902
+ {
97903
+ kind: 8 /* AutomaticTypeDirectiveFile */,
97904
+ typeReference: automaticTypeDirectiveNames[i],
97905
+ packageId: (_m = (_l = resolutions[i]) == null ? void 0 : _l.resolvedTypeReferenceDirective) == null ? void 0 : _m.packageId
97906
+ }
97907
+ );
97861
97908
  }
97862
- (_l = tracing) == null ? void 0 : _l.pop();
97909
+ (_n = tracing) == null ? void 0 : _n.pop();
97863
97910
  }
97864
97911
  if (rootNames.length && !skipDefaultLib) {
97865
97912
  const defaultLibraryFileName = getDefaultLibraryFileName();
@@ -97906,7 +97953,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97906
97953
  }
97907
97954
  );
97908
97955
  }
97909
- typeReferenceDirectiveResolutionCache = void 0;
97910
97956
  oldProgram = void 0;
97911
97957
  const program = {
97912
97958
  getRootFileNames: () => rootNames,
@@ -97939,6 +97985,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97939
97985
  getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
97940
97986
  getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
97941
97987
  getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives,
97988
+ getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
97989
+ getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
97942
97990
  isSourceFileFromExternalLibrary,
97943
97991
  isSourceFileDefaultLibrary,
97944
97992
  getSourceFileFromReference,
@@ -97948,7 +97996,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97948
97996
  usesUriStyleNodeCoreModules,
97949
97997
  isEmittedFile,
97950
97998
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
97951
- getResolvedModuleWithFailedLookupLocationsFromCache,
97952
97999
  getProjectReferences,
97953
98000
  getResolvedProjectReferences,
97954
98001
  getProjectReferenceRedirect,
@@ -97961,7 +98008,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97961
98008
  readFile,
97962
98009
  directoryExists,
97963
98010
  getSymlinkCache,
97964
- realpath: (_m = host.realpath) == null ? void 0 : _m.bind(host),
98011
+ realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
97965
98012
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
97966
98013
  getFileIncludeReasons: () => fileReasons,
97967
98014
  structureIsReused,
@@ -97975,6 +98022,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97975
98022
  case 0 /* FilePreprocessingReferencedDiagnostic */:
97976
98023
  const { file, pos, end } = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason);
97977
98024
  return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray));
98025
+ case 2 /* ResolutionDiagnostics */:
98026
+ return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
97978
98027
  default:
97979
98028
  Debug.assertNever(diagnostic);
97980
98029
  }
@@ -97982,32 +98031,30 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
97982
98031
  verifyCompilerOptions();
97983
98032
  mark("afterProgram");
97984
98033
  measure("Program", "beforeProgram", "afterProgram");
97985
- (_n = tracing) == null ? void 0 : _n.pop();
98034
+ (_p = tracing) == null ? void 0 : _p.pop();
97986
98035
  return program;
97987
- function addResolutionDiagnostics(list) {
97988
- if (!list)
98036
+ function addResolutionDiagnostics(resolution) {
98037
+ var _a3;
98038
+ if (!((_a3 = resolution.resolutionDiagnostics) == null ? void 0 : _a3.length))
97989
98039
  return;
97990
- for (const elem of list) {
97991
- programDiagnostics.add(elem);
97992
- }
98040
+ (fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
98041
+ kind: 2 /* ResolutionDiagnostics */,
98042
+ diagnostics: resolution.resolutionDiagnostics
98043
+ });
97993
98044
  }
97994
- function pullDiagnosticsFromCache(names, containingFile) {
97995
- var _a3;
97996
- if (!moduleResolutionCache)
98045
+ function addResolutionDiagnosticsFromResolutionOrCache(containingFile, name, resolution, mode) {
98046
+ if (host.resolveModuleNameLiterals || !host.resolveModuleNames)
98047
+ return addResolutionDiagnostics(resolution);
98048
+ if (!moduleResolutionCache || isExternalModuleNameRelative(name))
97997
98049
  return;
97998
98050
  const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97999
98051
  const containingDir = getDirectoryPath(containingFileName);
98000
98052
  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
- }
98053
+ const fromCache = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir);
98054
+ if (fromCache)
98055
+ addResolutionDiagnostics(fromCache);
98009
98056
  }
98010
- function resolveModuleNamesWorker(moduleNames, containingFile, resolutionInfo) {
98057
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
98011
98058
  var _a3, _b2;
98012
98059
  if (!moduleNames.length)
98013
98060
  return emptyArray;
@@ -98015,23 +98062,22 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98015
98062
  const redirectedReference = getRedirectReferenceForResolution(containingFile);
98016
98063
  (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
98017
98064
  mark("beforeResolveModule");
98018
- const result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo);
98065
+ const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames);
98019
98066
  mark("afterResolveModule");
98020
98067
  measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
98021
98068
  (_b2 = tracing) == null ? void 0 : _b2.pop();
98022
- pullDiagnosticsFromCache(moduleNames, containingFile);
98023
98069
  return result;
98024
98070
  }
98025
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, resolutionInfo) {
98071
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, reusedNames) {
98026
98072
  var _a3, _b2;
98027
98073
  if (!typeDirectiveNames.length)
98028
98074
  return [];
98075
+ const containingSourceFile = !isString(containingFile) ? containingFile : void 0;
98029
98076
  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;
98077
+ const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile);
98032
98078
  (_a3 = tracing) == null ? void 0 : _a3.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
98033
98079
  mark("beforeResolveTypeReference");
98034
- const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode, resolutionInfo);
98080
+ const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames);
98035
98081
  mark("afterResolveTypeReference");
98036
98082
  measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
98037
98083
  (_b2 = tracing) == null ? void 0 : _b2.pop();
@@ -98077,9 +98123,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98077
98123
  }
98078
98124
  return libs.length + 2;
98079
98125
  }
98080
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
98081
- return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
98082
- }
98083
98126
  function toPath3(fileName) {
98084
98127
  return toPath(fileName, currentDirectory, getCanonicalFileName);
98085
98128
  }
@@ -98108,6 +98151,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98108
98151
  return classifiableNames;
98109
98152
  }
98110
98153
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98154
+ var _a3;
98111
98155
  if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
98112
98156
  return resolveModuleNamesWorker(moduleNames, file, void 0);
98113
98157
  }
@@ -98123,24 +98167,24 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98123
98167
  let unknownModuleNames;
98124
98168
  let result;
98125
98169
  let reusedNames;
98126
- const predictedToResolveToAmbientModuleMarker = {};
98170
+ const predictedToResolveToAmbientModuleMarker = emptyResolution;
98127
98171
  for (let i = 0; i < moduleNames.length; i++) {
98128
98172
  const moduleName = moduleNames[i];
98129
98173
  if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
98130
98174
  const mode = getModeForUsageLocation(file, moduleName);
98131
- const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName.text, mode);
98132
- if (oldResolvedModule) {
98175
+ const oldResolution = (_a3 = oldSourceFile.resolvedModules) == null ? void 0 : _a3.get(moduleName.text, mode);
98176
+ if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
98133
98177
  if (isTraceEnabled(options, host)) {
98134
98178
  trace(
98135
98179
  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,
98180
+ 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
98181
  moduleName.text,
98138
98182
  getNormalizedAbsolutePath(file.originalFileName, currentDirectory),
98139
- oldResolvedModule.resolvedFileName,
98140
- oldResolvedModule.packageId && packageIdToString(oldResolvedModule.packageId)
98183
+ oldResolution.resolvedModule.resolvedFileName,
98184
+ oldResolution.resolvedModule.packageId && packageIdToString(oldResolution.resolvedModule.packageId)
98141
98185
  );
98142
98186
  }
98143
- (result != null ? result : result = new Array(moduleNames.length))[i] = oldResolvedModule;
98187
+ (result != null ? result : result = new Array(moduleNames.length))[i] = oldResolution;
98144
98188
  (reusedNames != null ? reusedNames : reusedNames = []).push(moduleName);
98145
98189
  continue;
98146
98190
  }
@@ -98160,18 +98204,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98160
98204
  (unknownModuleNames != null ? unknownModuleNames : unknownModuleNames = []).push(moduleName);
98161
98205
  }
98162
98206
  }
98163
- const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, { names: unknownModuleNames, reusedNames }) : emptyArray;
98207
+ const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray;
98164
98208
  if (!result) {
98165
98209
  Debug.assert(resolutions.length === moduleNames.length);
98166
98210
  return resolutions;
98167
98211
  }
98168
98212
  let j = 0;
98169
98213
  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 {
98214
+ if (!result[i]) {
98175
98215
  result[i] = resolutions[j];
98176
98216
  j++;
98177
98217
  }
@@ -98195,6 +98235,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98195
98235
  }
98196
98236
  }
98197
98237
  function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98238
+ var _a3;
98198
98239
  if (structureIsReused === 0 /* Not */) {
98199
98240
  return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, void 0);
98200
98241
  }
@@ -98203,7 +98244,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98203
98244
  if (oldSourceFile !== containingFile && containingFile.resolvedTypeReferenceDirectiveNames) {
98204
98245
  const result2 = [];
98205
98246
  for (const typeDirectiveName of typeDirectiveNames) {
98206
- const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getResolutionName(typeDirectiveName), typeDirectiveName.resolutionMode || containingFile.impliedNodeFormat);
98247
+ const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getTypeReferenceResolutionName(typeDirectiveName), getModeForFileReference(typeDirectiveName, containingFile.impliedNodeFormat));
98207
98248
  result2.push(resolvedTypeReferenceDirective);
98208
98249
  }
98209
98250
  return result2;
@@ -98217,21 +98258,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98217
98258
  for (let i = 0; i < typeDirectiveNames.length; i++) {
98218
98259
  const entry = typeDirectiveNames[i];
98219
98260
  if (canReuseResolutions) {
98220
- const typeDirectiveName = getResolutionName(entry);
98261
+ const typeDirectiveName = getTypeReferenceResolutionName(entry);
98221
98262
  const mode = getModeForFileReference(entry, containingSourceFile == null ? void 0 : containingSourceFile.impliedNodeFormat);
98222
- const oldResolvedTypeReferenceDirective = getResolvedTypeReferenceDirective(oldSourceFile, typeDirectiveName, mode);
98223
- if (oldResolvedTypeReferenceDirective) {
98263
+ const oldResolution = (_a3 = !isString(containingFile) ? oldSourceFile == null ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a3.get(typeDirectiveName, mode);
98264
+ if (oldResolution == null ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98224
98265
  if (isTraceEnabled(options, host)) {
98225
98266
  trace(
98226
98267
  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,
98268
+ 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
98269
  typeDirectiveName,
98229
98270
  !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile,
98230
- oldResolvedTypeReferenceDirective.resolvedFileName,
98231
- oldResolvedTypeReferenceDirective.packageId && packageIdToString(oldResolvedTypeReferenceDirective.packageId)
98271
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName,
98272
+ oldResolution.resolvedTypeReferenceDirective.packageId && packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId)
98232
98273
  );
98233
98274
  }
98234
- (result != null ? result : result = new Array(typeDirectiveNames.length))[i] = oldResolvedTypeReferenceDirective;
98275
+ (result != null ? result : result = new Array(typeDirectiveNames.length))[i] = oldResolution;
98235
98276
  (reusedNames != null ? reusedNames : reusedNames = []).push(entry);
98236
98277
  continue;
98237
98278
  }
@@ -98243,7 +98284,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98243
98284
  const resolutions = resolveTypeReferenceDirectiveNamesWorker(
98244
98285
  unknownTypeReferenceDirectiveNames,
98245
98286
  containingFile,
98246
- { names: unknownTypeReferenceDirectiveNames, reusedNames }
98287
+ reusedNames
98247
98288
  );
98248
98289
  if (!result) {
98249
98290
  Debug.assert(resolutions.length === typeDirectiveNames.length);
@@ -98279,7 +98320,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98279
98320
  );
98280
98321
  }
98281
98322
  function tryReuseStructureFromOldProgram() {
98282
- var _a3, _b2;
98323
+ var _a3;
98283
98324
  if (!oldProgram) {
98284
98325
  return 0 /* Not */;
98285
98326
  }
@@ -98389,19 +98430,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98389
98430
  for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
98390
98431
  const moduleNames = getModuleNames(newSourceFile);
98391
98432
  const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98392
- const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
98433
+ const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter);
98393
98434
  if (resolutionsChanged) {
98394
98435
  structureIsReused = 1 /* SafeModules */;
98395
- newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98436
+ newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions, moduleResolutionNameAndModeGetter);
98396
98437
  } else {
98397
98438
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98398
98439
  }
98399
98440
  const typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98400
98441
  const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98401
- const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
98442
+ const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter);
98402
98443
  if (typeReferenceResolutionsChanged) {
98403
98444
  structureIsReused = 1 /* SafeModules */;
98404
- newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98445
+ newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions, typeReferenceResolutionNameAndModeGetter);
98405
98446
  } else {
98406
98447
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98407
98448
  }
@@ -98409,9 +98450,17 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98409
98450
  if (structureIsReused !== 2 /* Completely */) {
98410
98451
  return structureIsReused;
98411
98452
  }
98412
- if (changesAffectingProgramStructure(oldOptions, options) || ((_b2 = host.hasChangedAutomaticTypeDirectiveNames) == null ? void 0 : _b2.call(host))) {
98453
+ if (changesAffectingProgramStructure(oldOptions, options)) {
98413
98454
  return 1 /* SafeModules */;
98414
98455
  }
98456
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
98457
+ if (host.hasChangedAutomaticTypeDirectiveNames())
98458
+ return 1 /* SafeModules */;
98459
+ } else {
98460
+ automaticTypeDirectiveNames = getAutomaticTypeDirectiveNames(options, host);
98461
+ if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98462
+ return 1 /* SafeModules */;
98463
+ }
98415
98464
  missingFilePaths = oldProgram.getMissingFilePaths();
98416
98465
  Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98417
98466
  for (const newSourceFile of newSourceFiles) {
@@ -98435,6 +98484,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
98435
98484
  fileReasons = oldProgram.getFileIncludeReasons();
98436
98485
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98437
98486
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98487
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98488
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98438
98489
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98439
98490
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98440
98491
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
@@ -99378,7 +99429,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99378
99429
  }
99379
99430
  function processTypeReferenceDirectives(file) {
99380
99431
  const typeDirectives = file.typeReferenceDirectives;
99381
- if (!typeDirectives) {
99432
+ if (!typeDirectives.length) {
99433
+ file.resolvedTypeReferenceDirectiveNames = void 0;
99382
99434
  return;
99383
99435
  }
99384
99436
  const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
@@ -99389,23 +99441,31 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99389
99441
  setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99390
99442
  const mode = ref.resolutionMode || file.impliedNodeFormat;
99391
99443
  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));
99444
+ (fileProcessingDiagnostics != null ? fileProcessingDiagnostics : fileProcessingDiagnostics = []).push({
99445
+ kind: 2 /* ResolutionDiagnostics */,
99446
+ diagnostics: [
99447
+ createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)
99448
+ ]
99449
+ });
99393
99450
  }
99394
99451
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: 5 /* TypeReferenceDirective */, file: file.path, index });
99395
99452
  }
99396
99453
  }
99397
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99454
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99398
99455
  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);
99456
+ (_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 });
99457
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99401
99458
  (_b2 = tracing) == null ? void 0 : _b2.pop();
99402
99459
  }
99403
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99404
- const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99460
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99461
+ var _a3;
99462
+ addResolutionDiagnostics(resolution);
99463
+ const previousResolution = (_a3 = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) == null ? void 0 : _a3.resolvedTypeReferenceDirective;
99405
99464
  if (previousResolution && previousResolution.primary) {
99406
99465
  return;
99407
99466
  }
99408
99467
  let saveResolution = true;
99468
+ const { resolvedTypeReferenceDirective } = resolution;
99409
99469
  if (resolvedTypeReferenceDirective) {
99410
99470
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99411
99471
  currentNodeModulesDepth++;
@@ -99436,7 +99496,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99436
99496
  addFilePreprocessingFileExplainingDiagnostic(void 0, reason, Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99437
99497
  }
99438
99498
  if (saveResolution) {
99439
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99499
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99440
99500
  }
99441
99501
  }
99442
99502
  function pathForLibFile(libFileName) {
@@ -99485,8 +99545,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
99485
99545
  Debug.assert(resolutions.length === moduleNames.length);
99486
99546
  const optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a3 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a3.commandLine.options : void 0) || options;
99487
99547
  for (let index = 0; index < moduleNames.length; index++) {
99488
- const resolution = resolutions[index];
99489
- setResolvedModule(file, moduleNames[index].text, resolution, getModeForUsageLocation(file, moduleNames[index]));
99548
+ const resolution = resolutions[index].resolvedModule;
99549
+ const moduleName = moduleNames[index].text;
99550
+ const mode = getModeForUsageLocation(file, moduleNames[index]);
99551
+ setResolvedModule(file, moduleName, resolutions[index], mode);
99552
+ addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
99490
99553
  if (!resolution) {
99491
99554
  continue;
99492
99555
  }
@@ -100127,8 +100190,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
100127
100190
  if (!symlinks) {
100128
100191
  symlinks = createSymlinkCache(currentDirectory, getCanonicalFileName);
100129
100192
  }
100130
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
100131
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100193
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100194
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
100132
100195
  }
100133
100196
  return symlinks;
100134
100197
  }
@@ -100462,7 +100525,7 @@ var BuilderState;
100462
100525
  }
100463
100526
  }
100464
100527
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100465
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => {
100528
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(({ resolvedTypeReferenceDirective }) => {
100466
100529
  if (!resolvedTypeReferenceDirective) {
100467
100530
  return;
100468
100531
  }
@@ -101972,9 +102035,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
101972
102035
  finishRecordingFilesWithChangedResolutions,
101973
102036
  startCachingPerDirectoryResolution,
101974
102037
  finishCachingPerDirectoryResolution,
101975
- resolveModuleNames,
101976
- getResolvedModuleWithFailedLookupLocationsFromCache,
101977
- resolveTypeReferenceDirectives,
102038
+ resolveModuleNameLiterals,
102039
+ resolveTypeReferenceDirectiveReferences,
102040
+ resolveSingleModuleNameWithoutWatching,
101978
102041
  removeResolutionsFromProjectReferenceRedirects,
101979
102042
  removeResolutionsOfFile,
101980
102043
  hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames,
@@ -101990,7 +102053,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
101990
102053
  function getResolvedModule2(resolution) {
101991
102054
  return resolution.resolvedModule;
101992
102055
  }
101993
- function getResolvedTypeReferenceDirective2(resolution) {
102056
+ function getResolvedTypeReferenceDirective(resolution) {
101994
102057
  return resolution.resolvedTypeReferenceDirective;
101995
102058
  }
101996
102059
  function isInDirectoryPath(dir, file) {
@@ -102092,14 +102155,16 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102092
102155
  });
102093
102156
  hasChangedAutomaticTypeDirectiveNames = false;
102094
102157
  }
102095
- function resolveModuleName2(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102158
+ function resolveModuleName2(moduleName, containingFile, compilerOptions, redirectedReference, mode) {
102159
+ var _a2;
102160
+ const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
102096
102161
  const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
102097
102162
  if (!resolutionHost.getGlobalCache) {
102098
102163
  return primaryResult;
102099
102164
  }
102100
102165
  const globalCache = resolutionHost.getGlobalCache();
102101
102166
  if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
102102
- const { resolvedModule, failedLookupLocations, affectingLocations } = loadModuleFromGlobalCache(
102167
+ const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
102103
102168
  Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
102104
102169
  resolutionHost.projectName,
102105
102170
  compilerOptions,
@@ -102109,49 +102174,55 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102109
102174
  );
102110
102175
  if (resolvedModule) {
102111
102176
  primaryResult.resolvedModule = resolvedModule;
102112
- primaryResult.failedLookupLocations.push(...failedLookupLocations);
102113
- primaryResult.affectingLocations.push(...affectingLocations);
102177
+ primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations);
102178
+ primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102179
+ primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
102114
102180
  return primaryResult;
102115
102181
  }
102116
102182
  }
102117
102183
  return primaryResult;
102118
102184
  }
102119
- function resolveTypeReferenceDirective2(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
102120
- return resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
102185
+ function createModuleResolutionLoader2(containingFile, redirectedReference, options) {
102186
+ return {
102187
+ nameAndMode: moduleResolutionNameAndModeGetter,
102188
+ resolve: (moduleName, resoluionMode) => resolveModuleName2(
102189
+ moduleName,
102190
+ containingFile,
102191
+ options,
102192
+ redirectedReference,
102193
+ resoluionMode
102194
+ )
102195
+ };
102121
102196
  }
102122
102197
  function resolveNamesWithLocalCache({
102123
- names,
102198
+ entries,
102124
102199
  containingFile,
102200
+ containingSourceFile,
102125
102201
  redirectedReference,
102202
+ options,
102126
102203
  perFileCache,
102204
+ reusedNames,
102127
102205
  loader,
102128
102206
  getResolutionWithResolvedFileName,
102129
102207
  shouldRetryResolution,
102130
- reusedNames,
102131
- resolutionInfo,
102132
- logChanges,
102133
- containingSourceFile,
102134
- containingSourceFileMode
102208
+ logChanges
102135
102209
  }) {
102136
- var _a2, _b, _c;
102210
+ var _a2;
102137
102211
  const path = resolutionHost.toPath(containingFile);
102138
102212
  const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
102139
102213
  const resolvedModules = [];
102140
- const compilerOptions = resolutionHost.getCompilationSettings();
102141
102214
  const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
102142
102215
  const program = resolutionHost.getCurrentProgram();
102143
102216
  const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
102144
102217
  const unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference;
102145
102218
  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++;
102219
+ for (const entry of entries) {
102220
+ const name = loader.nameAndMode.getName(entry);
102221
+ const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
102151
102222
  let resolution = resolutionsInFile.get(name, mode);
102152
102223
  if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
102153
102224
  const existingResolution = resolution;
102154
- resolution = loader(name, containingFile, compilerOptions, ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102225
+ resolution = loader.resolve(name, mode);
102155
102226
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102156
102227
  resolutionHost.onDiscoveredSymlink();
102157
102228
  }
@@ -102165,12 +102236,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102165
102236
  logChanges = false;
102166
102237
  }
102167
102238
  } else {
102168
- const host = ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost;
102169
- if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
102239
+ const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
102240
+ if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
102170
102241
  const resolved = getResolutionWithResolvedFileName(resolution);
102171
102242
  trace(
102172
102243
  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,
102244
+ 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
102245
  name,
102175
102246
  containingFile,
102176
102247
  resolved == null ? void 0 : resolved.resolvedFileName,
@@ -102180,19 +102251,16 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102180
102251
  }
102181
102252
  Debug.assert(resolution !== void 0 && !resolution.isInvalidated);
102182
102253
  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;
102254
+ resolvedModules.push(resolution);
102192
102255
  }
102256
+ reusedNames == null ? void 0 : reusedNames.forEach((entry) => seenNamesInFile.set(
102257
+ loader.nameAndMode.getName(entry),
102258
+ loader.nameAndMode.getMode(entry, containingSourceFile),
102259
+ true
102260
+ ));
102193
102261
  if (resolutionsInFile.size() !== seenNamesInFile.size()) {
102194
102262
  resolutionsInFile.forEach((resolution, name, mode) => {
102195
- if (!seenNamesInFile.has(name, mode) && !contains(reusedNames, name)) {
102263
+ if (!seenNamesInFile.has(name, mode)) {
102196
102264
  stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
102197
102265
  resolutionsInFile.delete(name, mode);
102198
102266
  }
@@ -102217,39 +102285,53 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102217
102285
  return oldResult.resolvedFileName === newResult.resolvedFileName;
102218
102286
  }
102219
102287
  }
102220
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo) {
102288
+ function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
102289
+ var _a2;
102221
102290
  return resolveNamesWithLocalCache({
102222
- names: typeDirectiveNames,
102291
+ entries: typeDirectiveReferences,
102223
102292
  containingFile,
102293
+ containingSourceFile,
102224
102294
  redirectedReference,
102295
+ options,
102296
+ reusedNames,
102225
102297
  perFileCache: resolvedTypeReferenceDirectives,
102226
- loader: resolveTypeReferenceDirective2,
102227
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
102228
- shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
102229
- containingSourceFileMode: containingFileMode,
102230
- resolutionInfo
102298
+ loader: createTypeReferenceResolutionLoader(
102299
+ containingFile,
102300
+ redirectedReference,
102301
+ options,
102302
+ ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost,
102303
+ typeReferenceDirectiveResolutionCache
102304
+ ),
102305
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
102306
+ shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0
102231
102307
  });
102232
102308
  }
102233
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile, resolutionInfo) {
102309
+ function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
102234
102310
  return resolveNamesWithLocalCache({
102235
- names: moduleNames,
102311
+ entries: moduleLiterals,
102236
102312
  containingFile,
102313
+ containingSourceFile,
102237
102314
  redirectedReference,
102315
+ options,
102316
+ reusedNames,
102238
102317
  perFileCache: resolvedModuleNames,
102239
- loader: resolveModuleName2,
102318
+ loader: createModuleResolutionLoader2(
102319
+ containingFile,
102320
+ redirectedReference,
102321
+ options
102322
+ ),
102240
102323
  getResolutionWithResolvedFileName: getResolvedModule2,
102241
102324
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
102242
- reusedNames,
102243
- resolutionInfo,
102244
- logChanges: logChangesWhenResolvingModule,
102245
- containingSourceFile
102325
+ logChanges: logChangesWhenResolvingModule
102246
102326
  });
102247
102327
  }
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);
102328
+ function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
102329
+ const path = resolutionHost.toPath(containingFile);
102330
+ const resolutionsInFile = resolvedModuleNames.get(path);
102331
+ const resolution = resolutionsInFile == null ? void 0 : resolutionsInFile.get(moduleName, void 0);
102332
+ if (resolution && !resolution.isInvalidated)
102333
+ return resolution;
102334
+ return resolveModuleName2(moduleName, containingFile, resolutionHost.getCompilationSettings());
102253
102335
  }
102254
102336
  function isNodeModulesAtTypesDirectory(dirPath) {
102255
102337
  return endsWith(dirPath, "/node_modules/@types");
@@ -102328,37 +102410,39 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102328
102410
  function watchFailedLookupLocationOfResolution(resolution) {
102329
102411
  Debug.assert(!!resolution.refCount);
102330
102412
  const { failedLookupLocations, affectingLocations } = resolution;
102331
- if (!failedLookupLocations.length && !affectingLocations.length)
102413
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length))
102332
102414
  return;
102333
- if (failedLookupLocations.length)
102415
+ if (failedLookupLocations == null ? void 0 : failedLookupLocations.length)
102334
102416
  resolutionsWithFailedLookups.push(resolution);
102335
102417
  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);
102418
+ if (failedLookupLocations) {
102419
+ for (const failedLookupLocation of failedLookupLocations) {
102420
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102421
+ const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102422
+ if (toWatch) {
102423
+ const { dir, dirPath, nonRecursive } = toWatch;
102424
+ if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
102425
+ const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
102426
+ customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
102427
+ }
102428
+ if (dirPath === rootPath) {
102429
+ Debug.assert(!nonRecursive);
102430
+ setAtRoot = true;
102431
+ } else {
102432
+ setDirectoryWatcher(dir, dirPath, nonRecursive);
102433
+ }
102350
102434
  }
102351
102435
  }
102436
+ if (setAtRoot) {
102437
+ setDirectoryWatcher(rootDir, rootPath, true);
102438
+ }
102352
102439
  }
102353
- if (setAtRoot) {
102354
- setDirectoryWatcher(rootDir, rootPath, true);
102355
- }
102356
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
102440
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length));
102357
102441
  }
102358
102442
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
102359
102443
  Debug.assert(!!resolution.refCount);
102360
102444
  const { affectingLocations } = resolution;
102361
- if (!affectingLocations.length)
102445
+ if (!(affectingLocations == null ? void 0 : affectingLocations.length))
102362
102446
  return;
102363
102447
  if (addToResolutionsWithOnlyAffectingLocations)
102364
102448
  resolutionsWithOnlyAffectingLocations.push(resolution);
@@ -102476,12 +102560,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102476
102560
  if (removeAtRoot) {
102477
102561
  removeDirectoryWatcher(rootPath);
102478
102562
  }
102479
- } else if (affectingLocations.length) {
102563
+ } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
102480
102564
  unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102481
102565
  }
102482
- for (const affectingLocation of affectingLocations) {
102483
- const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102484
- watcher.resolutions--;
102566
+ if (affectingLocations) {
102567
+ for (const affectingLocation of affectingLocations) {
102568
+ const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102569
+ watcher.resolutions--;
102570
+ }
102485
102571
  }
102486
102572
  }
102487
102573
  function removeDirectoryWatcher(dirPath) {
@@ -102517,7 +102603,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102517
102603
  }
102518
102604
  function removeResolutionsOfFile(filePath) {
102519
102605
  removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule2);
102520
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective2);
102606
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
102521
102607
  }
102522
102608
  function invalidateResolutions(resolutions, canInvalidate) {
102523
102609
  if (!resolutions)
@@ -102603,17 +102689,19 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
102603
102689
  return invalidated;
102604
102690
  }
102605
102691
  function canInvalidateFailedLookupResolution(resolution) {
102692
+ var _a2;
102606
102693
  if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution))
102607
102694
  return true;
102608
102695
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
102609
102696
  return false;
102610
- return resolution.failedLookupLocations.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
102697
+ return (_a2 = resolution.failedLookupLocations) == null ? void 0 : _a2.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)));
102611
102698
  }
102612
102699
  function isInvalidatedFailedLookup(locationPath) {
102613
102700
  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
102701
  }
102615
102702
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102616
- return !!affectingPathChecks && resolution.affectingLocations.some((location) => affectingPathChecks.has(location));
102703
+ var _a2;
102704
+ return !!affectingPathChecks && ((_a2 = resolution.affectingLocations) == null ? void 0 : _a2.some((location) => affectingPathChecks.has(location)));
102617
102705
  }
102618
102706
  function closeTypeRootsWatch() {
102619
102707
  clearMap(typeRootsWatches, closeFileWatcher);
@@ -103379,10 +103467,18 @@ function createWatchProgram(host) {
103379
103467
  configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory,
103380
103468
  false
103381
103469
  );
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;
103470
+ compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
103471
+ compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
103472
+ if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
103473
+ compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache);
103474
+ }
103475
+ compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
103476
+ compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
103477
+ if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
103478
+ compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
103479
+ }
103480
+ compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
103481
+ const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103386
103482
  const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
103387
103483
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
103388
103484
  synchronizeProgram();
@@ -104021,19 +104117,38 @@ function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, optio
104021
104117
  const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
104022
104118
  setGetSourceFileAsHashVersioned(compilerHost);
104023
104119
  compilerHost.getParsedCommandLine = (fileName) => parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName));
104120
+ compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
104121
+ compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
104024
104122
  compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
104025
104123
  compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
104026
104124
  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);
104125
+ let moduleResolutionCache, typeReferenceDirectiveResolutionCache;
104126
+ if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
104127
+ moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName);
104128
+ compilerHost.resolveModuleNameLiterals = (moduleNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
104129
+ moduleNames,
104130
+ containingFile,
104131
+ redirectedReference,
104132
+ options2,
104133
+ containingSourceFile,
104134
+ host,
104135
+ moduleResolutionCache,
104136
+ createModuleResolutionLoader
104137
+ );
104032
104138
  compilerHost.getModuleResolutionCache = () => moduleResolutionCache;
104033
104139
  }
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);
104140
+ if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
104141
+ typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, void 0, moduleResolutionCache == null ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
104142
+ compilerHost.resolveTypeReferenceDirectiveReferences = (typeDirectiveNames, containingFile, redirectedReference, options2, containingSourceFile) => loadWithModeAwareCache(
104143
+ typeDirectiveNames,
104144
+ containingFile,
104145
+ redirectedReference,
104146
+ options2,
104147
+ containingSourceFile,
104148
+ host,
104149
+ typeReferenceDirectiveResolutionCache,
104150
+ createTypeReferenceResolutionLoader
104151
+ );
104037
104152
  }
104038
104153
  compilerHost.getBuildInfo = (fileName, configFilePath) => getBuildInfo3(state, fileName, toResolvedConfigFilePath(state, configFilePath), void 0);
104039
104154
  const { watchFile: watchFile2, watchDirectory, writeLog } = createWatchFactory(hostWithWatch, options);