@typescript-deploys/pr-build 4.8.0-pr-50007-2 → 4.8.0-pr-50085-2

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.
@@ -4915,15 +4915,13 @@ var ts;
4915
4915
  (function (FilePreprocessingDiagnosticsKind) {
4916
4916
  FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingReferencedDiagnostic"] = 0] = "FilePreprocessingReferencedDiagnostic";
4917
4917
  FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingFileExplainingDiagnostic"] = 1] = "FilePreprocessingFileExplainingDiagnostic";
4918
- FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["ResolutionDiagnostics"] = 2] = "ResolutionDiagnostics";
4919
4918
  })(FilePreprocessingDiagnosticsKind = ts.FilePreprocessingDiagnosticsKind || (ts.FilePreprocessingDiagnosticsKind = {}));
4920
4919
  /* @internal */
4921
4920
  var StructureIsReused;
4922
4921
  (function (StructureIsReused) {
4923
4922
  StructureIsReused[StructureIsReused["Not"] = 0] = "Not";
4924
- StructureIsReused[StructureIsReused["SafeModuleCache"] = 1] = "SafeModuleCache";
4925
- StructureIsReused[StructureIsReused["SafeModules"] = 2] = "SafeModules";
4926
- StructureIsReused[StructureIsReused["Completely"] = 3] = "Completely";
4923
+ StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules";
4924
+ StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely";
4927
4925
  })(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {}));
4928
4926
  /** Return code used by getEmitOutput function to indicate status of the function */
4929
4927
  var ExitStatus;
@@ -9858,7 +9856,6 @@ var ts;
9858
9856
  Specify_how_the_TypeScript_watch_mode_works: diag(6715, ts.DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."),
9859
9857
  Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
9860
9858
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
9861
- Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation: diag(6719, ts.DiagnosticCategory.Message, "Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation_6719", "Save resolutions into .tsbuildinfo file and use them for incremental compilation."),
9862
9859
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
9863
9860
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
9864
9861
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -14600,8 +14597,7 @@ var ts;
14600
14597
  }
14601
14598
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
14602
14599
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
14603
- return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
14604
- optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
14600
+ return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
14605
14601
  }
14606
14602
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
14607
14603
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -14679,20 +14675,21 @@ var ts;
14679
14675
  }
14680
14676
  ts.getFullWidth = getFullWidth;
14681
14677
  function getResolvedModule(sourceFile, moduleNameText, mode) {
14682
- var _a, _b;
14683
- return (_b = (_a = sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleNameText, mode)) === null || _b === void 0 ? void 0 : _b.resolvedModule;
14678
+ return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
14684
14679
  }
14685
14680
  ts.getResolvedModule = getResolvedModule;
14686
14681
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
14687
- var _a;
14688
- (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
14682
+ if (!sourceFile.resolvedModules) {
14683
+ sourceFile.resolvedModules = ts.createModeAwareCache();
14684
+ }
14689
14685
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
14690
14686
  }
14691
14687
  ts.setResolvedModule = setResolvedModule;
14692
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
14693
- var _a;
14694
- (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
14695
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
14688
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
14689
+ if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
14690
+ sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
14691
+ }
14692
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
14696
14693
  }
14697
14694
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
14698
14695
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -14702,15 +14699,11 @@ var ts;
14702
14699
  }
14703
14700
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
14704
14701
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
14705
- return oldResolution === newResolution ||
14706
- oldResolution.resolvedModule === newResolution.resolvedModule ||
14707
- !!oldResolution.resolvedModule &&
14708
- !!newResolution.resolvedModule &&
14709
- oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
14710
- oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
14711
- oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
14712
- oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
14713
- packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
14702
+ return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
14703
+ oldResolution.extension === newResolution.extension &&
14704
+ oldResolution.resolvedFileName === newResolution.resolvedFileName &&
14705
+ oldResolution.originalPath === newResolution.originalPath &&
14706
+ packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
14714
14707
  }
14715
14708
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
14716
14709
  function packageIdIsEqual(a, b) {
@@ -14726,13 +14719,9 @@ var ts;
14726
14719
  }
14727
14720
  ts.packageIdToString = packageIdToString;
14728
14721
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
14729
- return oldResolution === newResolution ||
14730
- oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
14731
- !!oldResolution.resolvedTypeReferenceDirective &&
14732
- !!newResolution.resolvedTypeReferenceDirective &&
14733
- oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
14734
- !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
14735
- oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
14722
+ return oldResolution.resolvedFileName === newResolution.resolvedFileName
14723
+ && oldResolution.primary === newResolution.primary
14724
+ && oldResolution.originalPath === newResolution.originalPath;
14736
14725
  }
14737
14726
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
14738
14727
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -19589,20 +19578,23 @@ var ts;
19589
19578
  return getStringFromExpandedCharCodes(expandedCharCodes);
19590
19579
  }
19591
19580
  ts.base64decode = base64decode;
19592
- function readJsonIgnoringErrors(path, host) {
19593
- return readJsonIgnoringErrorsFromText(path, host.readFile(path));
19594
- }
19595
- ts.readJsonIgnoringErrors = readJsonIgnoringErrors;
19596
- function readJsonIgnoringErrorsFromText(path, jsonText) {
19597
- if (!jsonText)
19598
- return {};
19599
- var result = ts.parseConfigFileTextToJson(path, jsonText);
19600
- if (result.error) {
19581
+ function readJson(path, host) {
19582
+ try {
19583
+ var jsonText = host.readFile(path);
19584
+ if (!jsonText)
19585
+ return {};
19586
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
19587
+ if (result.error) {
19588
+ return {};
19589
+ }
19590
+ return result.config;
19591
+ }
19592
+ catch (e) {
19593
+ // gracefully handle if readFile fails or returns not JSON
19601
19594
  return {};
19602
19595
  }
19603
- return result.config;
19604
19596
  }
19605
- ts.readJsonIgnoringErrorsFromText = readJsonIgnoringErrorsFromText;
19597
+ ts.readJson = readJson;
19606
19598
  function directoryProbablyExists(directoryName, host) {
19607
19599
  // if host does not support 'directoryExists' assume that directory will exist
19608
19600
  return !host.directoryExists || host.directoryExists(directoryName);
@@ -20684,15 +20676,14 @@ var ts;
20684
20676
  },
20685
20677
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
20686
20678
  var _this = this;
20687
- var _a, _b;
20679
+ var _a;
20688
20680
  ts.Debug.assert(!hasProcessedResolutions);
20689
20681
  hasProcessedResolutions = true;
20690
20682
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
20691
20683
  var file = files_1[_i];
20692
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedModule); });
20693
- (_b = file.resolvedTypeReferenceDirectiveNames) === null || _b === void 0 ? void 0 : _b.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedTypeReferenceDirective); });
20684
+ (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
20694
20685
  }
20695
- typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
20686
+ typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
20696
20687
  },
20697
20688
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
20698
20689
  };
@@ -39952,17 +39943,6 @@ var ts;
39952
39943
  transpileOptionValue: undefined,
39953
39944
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
39954
39945
  },
39955
- {
39956
- name: "cacheResolutions",
39957
- type: "boolean",
39958
- category: ts.Diagnostics.Projects,
39959
- description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
39960
- affectsModuleResolution: true,
39961
- affectsMultiFileEmitBuildInfo: true,
39962
- affectsBundleEmitBuildInfo: true,
39963
- transpileOptionValue: undefined,
39964
- defaultValueDescription: false,
39965
- },
39966
39946
  {
39967
39947
  name: "assumeChangesOnlyAffectDirectDependencies",
39968
39948
  type: "boolean",
@@ -42060,9 +42040,6 @@ var ts;
42060
42040
  if (result.configFilePath) {
42061
42041
  result.configFilePath = toAbsolutePath(result.configFilePath);
42062
42042
  }
42063
- if (result.pathsBasePath) {
42064
- result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
42065
- }
42066
42043
  return result;
42067
42044
  }
42068
42045
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -43048,36 +43025,20 @@ var ts;
43048
43025
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
43049
43026
  return { fileName: resolved.path, packageId: resolved.packageId };
43050
43027
  }
43051
- function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
43052
- var _a;
43053
- var _b;
43028
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
43029
+ var _a, _b;
43054
43030
  if (resultFromCache) {
43055
- if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
43056
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
43057
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
43058
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
43031
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
43032
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
43059
43033
  return resultFromCache;
43060
43034
  }
43061
43035
  return {
43062
43036
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
43063
- failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
43064
- affectingLocations: initializeResolutionField(affectingLocations),
43065
- resolutionDiagnostics: initializeResolutionField(diagnostics),
43037
+ failedLookupLocations: failedLookupLocations,
43038
+ affectingLocations: affectingLocations,
43039
+ resolutionDiagnostics: diagnostics,
43066
43040
  };
43067
43041
  }
43068
- function initializeResolutionField(value) {
43069
- return value.length ? value : undefined;
43070
- }
43071
- /*@internal*/
43072
- function updateResolutionField(to, value) {
43073
- if (!(value === null || value === void 0 ? void 0 : value.length))
43074
- return to;
43075
- if (!(to === null || to === void 0 ? void 0 : to.length))
43076
- return value;
43077
- to.push.apply(to, value);
43078
- return to;
43079
- }
43080
- ts.updateResolutionField = updateResolutionField;
43081
43042
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
43082
43043
  if (!ts.hasProperty(jsonContent, fieldName)) {
43083
43044
  if (state.traceEnabled) {
@@ -43229,7 +43190,8 @@ var ts;
43229
43190
  options = redirectedReference.commandLine.options;
43230
43191
  }
43231
43192
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
43232
- var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, /*mode*/ resolutionMode, redirectedReference) : undefined;
43193
+ var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
43194
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
43233
43195
  if (result) {
43234
43196
  if (traceEnabled) {
43235
43197
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -43287,7 +43249,7 @@ var ts;
43287
43249
  features: features,
43288
43250
  conditions: conditions,
43289
43251
  requestContainingDirectory: containingDirectory,
43290
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
43252
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43291
43253
  };
43292
43254
  var resolved = primaryLookup();
43293
43255
  var primary = true;
@@ -43307,15 +43269,8 @@ var ts;
43307
43269
  isExternalLibraryImport: pathContainsNodeModules(fileName),
43308
43270
  };
43309
43271
  }
43310
- result = {
43311
- resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
43312
- failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
43313
- affectingLocations: initializeResolutionField(affectingLocations),
43314
- resolutionDiagnostics: initializeResolutionField(diagnostics),
43315
- };
43316
- if (containingDirectory && cache) {
43317
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
43318
- }
43272
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
43273
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
43319
43274
  if (traceEnabled)
43320
43275
  traceResult(result);
43321
43276
  return result;
@@ -43325,10 +43280,10 @@ var ts;
43325
43280
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
43326
43281
  }
43327
43282
  else if (result.resolvedTypeReferenceDirective.packageId) {
43328
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), !!result.resolvedTypeReferenceDirective.primary);
43283
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary);
43329
43284
  }
43330
43285
  else {
43331
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
43286
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
43332
43287
  }
43333
43288
  }
43334
43289
  function primaryLookup() {
@@ -43427,7 +43382,7 @@ var ts;
43427
43382
  // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types.
43428
43383
  // See `createNotNeededPackageJSON` in the types-publisher` repo.
43429
43384
  // eslint-disable-next-line no-null/no-null
43430
- var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJsonIgnoringErrors(packageJsonPath, host).typings === null;
43385
+ var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
43431
43386
  if (!isNotNeededPackage) {
43432
43387
  var baseFileName = ts.getBaseFileName(normalized);
43433
43388
  // At this stage, skip results with leading dot.
@@ -43444,143 +43399,49 @@ var ts;
43444
43399
  return result;
43445
43400
  }
43446
43401
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
43447
- function compilerOptionValueToString(value) {
43448
- var _a;
43449
- if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null
43450
- return "" + value;
43451
- }
43452
- if (ts.isArray(value)) {
43453
- return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
43454
- }
43455
- var str = "{";
43456
- for (var key in value) {
43457
- if (ts.hasProperty(value, key)) {
43458
- str += key + ": " + compilerOptionValueToString(value[key]);
43459
- }
43460
- }
43461
- return str + "}";
43462
- }
43463
- /*@internal*/
43464
- function getKeyForCompilationSettings(settings, options) {
43465
- return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
43466
- }
43467
- ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
43468
- /*@internal*/
43469
- function getRedirectsCacheKey(options) {
43470
- return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
43471
- }
43472
- ts.getRedirectsCacheKey = getRedirectsCacheKey;
43473
43402
  /*@internal*/
43474
- function createCacheWithRedirects(ownOptions) {
43475
- var ownMap;
43476
- var ownKey;
43477
- var redirectsKeyToCache = new ts.Map();
43403
+ function createCacheWithRedirects(options) {
43404
+ var ownMap = new ts.Map();
43478
43405
  var redirectsMap = new ts.Map();
43479
43406
  return {
43480
43407
  getOwnMap: getOwnMap,
43481
- redirectsKeyToCache: redirectsKeyToCache,
43482
- createMapForCompilerOptions: createMapForCompilerOptions,
43483
- getMapOfCacheRedirects: getMapOfCacheRedirects,
43408
+ redirectsMap: redirectsMap,
43484
43409
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
43485
43410
  clear: clear,
43486
- update: update,
43487
- clearRedirectsMap: function () { return redirectsMap.clear(); },
43411
+ setOwnOptions: setOwnOptions,
43412
+ setOwnMap: setOwnMap
43488
43413
  };
43489
- function ensureOwnKeyCached() {
43490
- ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
43491
- if (ownKey && !redirectsKeyToCache.has(ownKey))
43492
- redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
43493
- }
43494
- function createMapForCompilerOptions(options, optionsKey) {
43495
- if (options === ownOptions)
43496
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
43497
- return getOrCreateRedirectMapAndKey(options, /*path*/ undefined, optionsKey);
43414
+ function getOwnMap() {
43415
+ return ownMap;
43498
43416
  }
43499
- function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
43500
- var _a;
43501
- if (path || options.configFile) {
43502
- var redirects = redirectsMap.get(path || options.configFile.path);
43503
- if (redirects)
43504
- return redirects;
43505
- }
43506
- var key = optionsKey || getRedirectsCacheKey(options);
43507
- var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
43508
- if (!map) {
43509
- ensureOwnKeyCached();
43510
- if (ownKey === key) {
43511
- map = ownMap;
43512
- }
43513
- else {
43514
- redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
43515
- }
43516
- }
43517
- if (path || options.configFile)
43518
- redirectsMap.set(path || options.configFile.path, map);
43519
- return map;
43417
+ function setOwnOptions(newOptions) {
43418
+ options = newOptions;
43520
43419
  }
43521
- function getOwnMap() {
43522
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
43523
- }
43524
- function update(newOwnOptions) {
43525
- // Store existing options:
43526
- if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
43527
- ensureOwnKeyCached();
43528
- if (!redirectsMap.has(ownOptions.configFile.path)) {
43529
- redirectsMap.set(ownOptions.configFile.path, ownMap);
43530
- }
43531
- }
43532
- // If this is already present use it
43533
- if (newOwnOptions.configFile) {
43534
- var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
43535
- if (existing_1) {
43536
- ownMap = existing_1;
43537
- ownOptions = newOwnOptions;
43538
- return;
43539
- }
43540
- }
43541
- var key = getRedirectsCacheKey(newOwnOptions);
43542
- var existing = redirectsKeyToCache.get(key);
43543
- ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
43544
- ownKey = key;
43545
- ownOptions = newOwnOptions;
43546
- if (newOwnOptions.configFile)
43547
- redirectsMap.set(newOwnOptions.configFile.path, ownMap);
43420
+ function setOwnMap(newOwnMap) {
43421
+ ownMap = newOwnMap;
43548
43422
  }
43549
- function getMapOfCacheRedirects(redirectedReference) {
43550
- if (!redirectedReference)
43551
- return ownMap;
43552
- var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
43553
- if (directResult)
43554
- return directResult;
43555
- var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
43556
- var fromKey = redirectsKeyToCache.get(key);
43557
- if (fromKey) {
43558
- redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
43559
- return fromKey.map;
43560
- }
43561
- if (ownMap)
43562
- ensureOwnKeyCached();
43563
- if (ownKey === key) {
43564
- redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
43423
+ function getOrCreateMapOfCacheRedirects(redirectedReference) {
43424
+ if (!redirectedReference) {
43565
43425
  return ownMap;
43566
43426
  }
43567
- return undefined;
43568
- }
43569
- function getOrCreateMapOfCacheRedirects(redirectedReference) {
43570
- return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
43571
- getOwnMap() :
43572
- getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, /*optionsKey*/ undefined);
43427
+ var path = redirectedReference.sourceFile.path;
43428
+ var redirects = redirectsMap.get(path);
43429
+ if (!redirects) {
43430
+ // Reuse map if redirected reference map uses same resolution
43431
+ redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
43432
+ redirectsMap.set(path, redirects);
43433
+ }
43434
+ return redirects;
43573
43435
  }
43574
43436
  function clear() {
43575
- ownKey = undefined;
43576
- ownMap = undefined;
43437
+ ownMap.clear();
43577
43438
  redirectsMap.clear();
43578
- redirectsKeyToCache.clear();
43579
43439
  }
43580
43440
  }
43581
43441
  ts.createCacheWithRedirects = createCacheWithRedirects;
43582
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
43583
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, clone: clone };
43442
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
43443
+ var cache;
43444
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
43584
43445
  function getPackageJsonInfo(packageJsonPath) {
43585
43446
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
43586
43447
  }
@@ -43594,9 +43455,6 @@ var ts;
43594
43455
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
43595
43456
  return iter ? ts.arrayFrom(iter) : [];
43596
43457
  }
43597
- function clone() {
43598
- return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
43599
- }
43600
43458
  }
43601
43459
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
43602
43460
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -43607,43 +43465,47 @@ var ts;
43607
43465
  }
43608
43466
  return result;
43609
43467
  }
43468
+ function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43469
+ if (!options.configFile)
43470
+ return;
43471
+ if (directoryToModuleNameMap.redirectsMap.size === 0) {
43472
+ // The own map will be for projectCompilerOptions
43473
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
43474
+ ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
43475
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
43476
+ directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
43477
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
43478
+ }
43479
+ else {
43480
+ // Set correct own map
43481
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
43482
+ var ref = {
43483
+ sourceFile: options.configFile,
43484
+ commandLine: { options: options }
43485
+ };
43486
+ directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
43487
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
43488
+ }
43489
+ directoryToModuleNameMap.setOwnOptions(options);
43490
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
43491
+ }
43610
43492
  function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
43611
- var oldResolutionCache;
43612
43493
  return {
43613
- getFromCache: getFromCache,
43614
43494
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
43615
43495
  clear: clear,
43616
43496
  update: update,
43617
- setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
43618
43497
  };
43619
43498
  function clear() {
43620
- oldResolutionCache = undefined;
43621
43499
  directoryToModuleNameMap.clear();
43622
43500
  }
43623
43501
  function update(options) {
43624
- directoryToModuleNameMap.update(options);
43502
+ updateRedirectsMap(options, directoryToModuleNameMap);
43625
43503
  }
43626
43504
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
43627
43505
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
43628
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
43629
- }
43630
- function getFromCache(directoryName, name, mode, redirectedReference) {
43631
- var _a, _b;
43632
- var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
43633
- var result = (_b = (_a = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(path)) === null || _b === void 0 ? void 0 : _b.get(name, mode);
43634
- if (result)
43635
- return result;
43636
- var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
43637
- if (resultFromOld)
43638
- getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
43639
- return resultFromOld;
43506
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
43640
43507
  }
43641
43508
  }
43642
- /*@internal*/
43643
- function getModeAwareCacheKey(specifier, mode) {
43644
- return (mode === undefined ? specifier : mode + "|" + specifier);
43645
- }
43646
- ts.getModeAwareCacheKey = getModeAwareCacheKey;
43647
43509
  /* @internal */
43648
43510
  function createModeAwareCache() {
43649
43511
  var underlying = new ts.Map();
@@ -43669,22 +43531,13 @@ var ts;
43669
43531
  return cb(elem, specifier, mode);
43670
43532
  });
43671
43533
  },
43672
- entries: function () {
43673
- var keys = underlying.entries();
43674
- return {
43675
- next: function () {
43676
- var next = keys.next();
43677
- return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
43678
- },
43679
- };
43680
- },
43681
43534
  size: function () {
43682
43535
  return underlying.size;
43683
- },
43536
+ }
43684
43537
  };
43685
43538
  return cache;
43686
43539
  function getUnderlyingCacheKey(specifier, mode) {
43687
- var result = getModeAwareCacheKey(specifier, mode);
43540
+ var result = mode === undefined ? specifier : mode + "|" + specifier;
43688
43541
  memoizedReverseKeys.set(result, [specifier, mode]);
43689
43542
  return result;
43690
43543
  }
@@ -43697,121 +43550,35 @@ var ts;
43697
43550
  for (var i = 0; i < keys.length; ++i) {
43698
43551
  var entry = keys[i];
43699
43552
  // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
43700
- var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
43553
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
43701
43554
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
43702
43555
  map.set(name, mode, values[i]);
43703
43556
  }
43704
43557
  return map;
43705
43558
  }
43706
43559
  ts.zipToModeAwareCache = zipToModeAwareCache;
43707
- function getCommonPrefix(directory, resolution, toPath) {
43708
- var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
43709
- // find first position where directory and resolution differs
43710
- var i = 0;
43711
- var limit = Math.min(directory.length, resolutionDirectory.length);
43712
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
43713
- i++;
43714
- }
43715
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
43716
- return directory;
43717
- }
43718
- var rootLength = ts.getRootLength(directory);
43719
- if (i < rootLength) {
43720
- return undefined;
43721
- }
43722
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
43723
- if (sep === -1) {
43724
- return undefined;
43725
- }
43726
- return directory.substr(0, Math.max(sep, rootLength));
43727
- }
43728
- /*@internal*/
43729
- function getResolvedFileNameForModuleNameToDirectorySet(result) {
43730
- return result.resolvedModule &&
43731
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
43732
- }
43733
- ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
43734
- /**
43735
- * At first this function add entry directory -> module resolution result to the table.
43736
- * Then it computes the set of parent folders for 'directory' that should have the same module resolution result
43737
- * and for every parent folder in set it adds entry: parent -> module resolution. .
43738
- * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts.
43739
- * Set of parent folders that should have the same result will be:
43740
- * [
43741
- * /a/b/c/d, /a/b/c, /a/b
43742
- * ]
43743
- * this means that request for module resolution from file in any of these folder will be immediately found in cache.
43744
- */
43745
- /*@internal*/
43746
- function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
43747
- // if entry is already in cache do nothing
43748
- if (directoryPathMap.has(directory))
43749
- return;
43750
- directoryPathMap.set(directory, result);
43751
- var resolvedFileName = getResolvedFileName(result);
43752
- // find common prefix between directory and resolved file name
43753
- // this common prefix should be the shortest path that has the same resolution
43754
- // directory: /a/b/c/d/e
43755
- // resolvedFileName: /a/b/foo.d.ts
43756
- // commonPrefix: /a/b
43757
- // for failed lookups cache the result for every directory up to root
43758
- var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
43759
- var current = directory;
43760
- while (current !== commonPrefix) {
43761
- var parent = ts.getDirectoryPath(current);
43762
- if (parent === current)
43763
- break;
43764
- if (directoryPathMap.has(parent)) {
43765
- ancestoryWorker(parent);
43766
- break;
43767
- }
43768
- directoryPathMap.set(parent, result);
43769
- ancestoryWorker(parent);
43770
- current = parent;
43771
- }
43772
- }
43773
- ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
43774
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
43775
- var directoryToModuleNameMap = createCacheWithRedirects(options);
43776
- var moduleNameToDirectoryMap = createCacheWithRedirects(options);
43777
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
43560
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43561
+ var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43562
+ moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
43778
43563
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
43779
- var oldResolutionCache;
43780
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
43564
+ return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
43781
43565
  function clear() {
43782
- oldResolutionCache = undefined;
43783
- perDirectoryResolutionCache.clear();
43566
+ preDirectoryResolutionCache.clear();
43784
43567
  moduleNameToDirectoryMap.clear();
43785
43568
  packageJsonInfoCache.clear();
43786
43569
  }
43787
43570
  function update(options) {
43788
- directoryToModuleNameMap.update(options);
43789
- moduleNameToDirectoryMap.update(options);
43790
- }
43791
- function setOldResolutionCache(cache) {
43792
- oldResolutionCache = cache;
43793
- perDirectoryResolutionCache.setOldResolutionCache(cache);
43794
- }
43795
- function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
43796
- var _a, _b;
43797
- ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
43798
- var result = (_b = (_a = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(getModeAwareCacheKey(nonRelativeModuleName, mode))) === null || _b === void 0 ? void 0 : _b.get(directoryName);
43799
- if (result)
43800
- return result;
43801
- var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
43802
- if (fromOld)
43803
- getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
43804
- return fromOld;
43571
+ updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
43805
43572
  }
43806
43573
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
43807
43574
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
43808
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
43575
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
43809
43576
  }
43810
43577
  function createPerModuleNameCache() {
43811
43578
  var directoryPathMap = new ts.Map();
43812
43579
  return { get: get, set: set };
43813
43580
  function get(directory) {
43814
- return directoryPathMap.get(toPath(directory));
43581
+ return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
43815
43582
  }
43816
43583
  /**
43817
43584
  * At first this function add entry directory -> module resolution result to the table.
@@ -43825,17 +43592,57 @@ var ts;
43825
43592
  * this means that request for module resolution from file in any of these folder will be immediately found in cache.
43826
43593
  */
43827
43594
  function set(directory, result) {
43828
- return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
43595
+ var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
43596
+ // if entry is already in cache do nothing
43597
+ if (directoryPathMap.has(path)) {
43598
+ return;
43599
+ }
43600
+ directoryPathMap.set(path, result);
43601
+ var resolvedFileName = result.resolvedModule &&
43602
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
43603
+ // find common prefix between directory and resolved file name
43604
+ // this common prefix should be the shortest path that has the same resolution
43605
+ // directory: /a/b/c/d/e
43606
+ // resolvedFileName: /a/b/foo.d.ts
43607
+ // commonPrefix: /a/b
43608
+ // for failed lookups cache the result for every directory up to root
43609
+ var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
43610
+ var current = path;
43611
+ while (current !== commonPrefix) {
43612
+ var parent = ts.getDirectoryPath(current);
43613
+ if (parent === current || directoryPathMap.has(parent)) {
43614
+ break;
43615
+ }
43616
+ directoryPathMap.set(parent, result);
43617
+ current = parent;
43618
+ }
43619
+ }
43620
+ function getCommonPrefix(directory, resolution) {
43621
+ var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
43622
+ // find first position where directory and resolution differs
43623
+ var i = 0;
43624
+ var limit = Math.min(directory.length, resolutionDirectory.length);
43625
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
43626
+ i++;
43627
+ }
43628
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
43629
+ return directory;
43630
+ }
43631
+ var rootLength = ts.getRootLength(directory);
43632
+ if (i < rootLength) {
43633
+ return undefined;
43634
+ }
43635
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
43636
+ if (sep === -1) {
43637
+ return undefined;
43638
+ }
43639
+ return directory.substr(0, Math.max(sep, rootLength));
43829
43640
  }
43830
- }
43831
- function toPath(fileName) {
43832
- return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
43833
43641
  }
43834
43642
  }
43835
43643
  ts.createModuleResolutionCache = createModuleResolutionCache;
43836
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
43837
- var directoryToModuleNameMap = createCacheWithRedirects(options);
43838
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
43644
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43645
+ var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43839
43646
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43840
43647
  return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
43841
43648
  function clear() {
@@ -43846,7 +43653,10 @@ var ts;
43846
43653
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
43847
43654
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
43848
43655
  var containingDirectory = ts.getDirectoryPath(containingFile);
43849
- return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
43656
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
43657
+ if (!perFolderCache)
43658
+ return undefined;
43659
+ return perFolderCache.get(moduleName, mode);
43850
43660
  }
43851
43661
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
43852
43662
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -43861,7 +43671,8 @@ var ts;
43861
43671
  }
43862
43672
  }
43863
43673
  var containingDirectory = ts.getDirectoryPath(containingFile);
43864
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
43674
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
43675
+ var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
43865
43676
  if (result) {
43866
43677
  if (traceEnabled) {
43867
43678
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -43913,8 +43724,8 @@ var ts;
43913
43724
  if (result && result.resolvedModule)
43914
43725
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
43915
43726
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
43916
- if (cache) {
43917
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
43727
+ if (perFolderCache) {
43728
+ perFolderCache.set(moduleName, resolutionMode, result);
43918
43729
  if (!ts.isExternalModuleNameRelative(moduleName)) {
43919
43730
  // put result in per-module name cache
43920
43731
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
@@ -44200,10 +44011,10 @@ var ts;
44200
44011
  features: features,
44201
44012
  conditions: conditions,
44202
44013
  requestContainingDirectory: containingDirectory,
44203
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
44014
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44204
44015
  };
44205
44016
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
44206
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44017
+ return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44207
44018
  function tryResolve(extensions) {
44208
44019
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
44209
44020
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -44580,7 +44391,7 @@ var ts;
44580
44391
  features: NodeResolutionFeatures.None,
44581
44392
  conditions: ts.emptyArray,
44582
44393
  requestContainingDirectory: undefined,
44583
- reportResolutionDiagnostic: ts.noop
44394
+ reportDiagnostic: ts.noop
44584
44395
  };
44585
44396
  }
44586
44397
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
@@ -44627,13 +44438,12 @@ var ts;
44627
44438
  }
44628
44439
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
44629
44440
  if (directoryExists && host.fileExists(packageJsonPath)) {
44630
- var packageJsonText = host.readFile(packageJsonPath);
44631
- var packageJsonContent = ts.readJsonIgnoringErrorsFromText(packageJsonPath, packageJsonText);
44441
+ var packageJsonContent = ts.readJson(packageJsonPath, host);
44632
44442
  if (traceEnabled) {
44633
44443
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
44634
44444
  }
44635
44445
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
44636
- var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
44446
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
44637
44447
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
44638
44448
  state.affectingLocations.push(packageJsonPath);
44639
44449
  return result;
@@ -45058,8 +44868,12 @@ var ts;
45058
44868
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
45059
44869
  }
45060
44870
  }
45061
- if (commonSourceDirGuesses.length > 1)
45062
- state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
44871
+ if (commonSourceDirGuesses.length > 1) {
44872
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
44873
+ ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
44874
+ : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
44875
+ packagePath));
44876
+ }
45063
44877
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
45064
44878
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
45065
44879
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -45129,10 +44943,10 @@ var ts;
45129
44943
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
45130
44944
  }
45131
44945
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
45132
- var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
44946
+ var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
45133
44947
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
45134
44948
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
45135
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
44949
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
45136
44950
  if (resolutionFromCache) {
45137
44951
  return resolutionFromCache;
45138
44952
  }
@@ -45284,8 +45098,8 @@ var ts;
45284
45098
  typesPackageName;
45285
45099
  }
45286
45100
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
45287
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
45288
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
45101
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
45102
+ var result = cache && cache.get(containingDirectory);
45289
45103
  if (result) {
45290
45104
  if (state.traceEnabled) {
45291
45105
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -45310,11 +45124,11 @@ var ts;
45310
45124
  features: NodeResolutionFeatures.None,
45311
45125
  conditions: [],
45312
45126
  requestContainingDirectory: containingDirectory,
45313
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
45127
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
45314
45128
  };
45315
45129
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
45316
45130
  // No originalPath because classic resolution doesn't resolve realPath
45317
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value,
45131
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
45318
45132
  /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
45319
45133
  function tryResolve(extensions) {
45320
45134
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
@@ -45322,9 +45136,10 @@ var ts;
45322
45136
  return { value: resolvedUsingSettings };
45323
45137
  }
45324
45138
  if (!ts.isExternalModuleNameRelative(moduleName)) {
45139
+ var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
45325
45140
  // Climb up parent directories looking for a module.
45326
45141
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
45327
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, /*mode*/ undefined, directory, redirectedReference, state);
45142
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
45328
45143
  if (resolutionFromCache) {
45329
45144
  return resolutionFromCache;
45330
45145
  }
@@ -45369,10 +45184,10 @@ var ts;
45369
45184
  features: NodeResolutionFeatures.None,
45370
45185
  conditions: [],
45371
45186
  requestContainingDirectory: undefined,
45372
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
45187
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
45373
45188
  };
45374
45189
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
45375
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved,
45190
+ return createResolvedModuleWithFailedLookupLocations(resolved,
45376
45191
  /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
45377
45192
  }
45378
45193
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
@@ -49058,10 +48873,9 @@ var ts;
49058
48873
  host.getSourceFiles().forEach(function (sf) {
49059
48874
  if (!sf.resolvedModules)
49060
48875
  return;
49061
- sf.resolvedModules.forEach(function (_a) {
49062
- var resolvedModule = _a.resolvedModule;
49063
- if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
49064
- map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map.get(resolvedModule.packageId.name));
48876
+ sf.resolvedModules.forEach(function (r) {
48877
+ if (r && r.packageId)
48878
+ map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
49065
48879
  });
49066
48880
  });
49067
48881
  return map;
@@ -88516,12 +88330,11 @@ var ts;
88516
88330
  if (resolvedTypeReferenceDirectives) {
88517
88331
  // populate reverse mapping: file path -> type reference directive that was resolved to this file
88518
88332
  fileToDirective = new ts.Map();
88519
- resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
88520
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
88521
- if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
88333
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
88334
+ if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
88522
88335
  return;
88523
88336
  }
88524
- var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
88337
+ var file = host.getSourceFile(resolvedDirective.resolvedFileName);
88525
88338
  if (file) {
88526
88339
  // Add the transitive closure of path references loaded by this file (as long as they are not)
88527
88340
  // part of an existing type reference.
@@ -111993,7 +111806,7 @@ var ts;
111993
111806
  var sourceMap = sourceMapGenerator.toString();
111994
111807
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111995
111808
  if (printer.bundleFileInfo)
111996
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
111809
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111997
111810
  }
111998
111811
  }
111999
111812
  else {
@@ -112005,7 +111818,7 @@ var ts;
112005
111818
  // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
112006
111819
  // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
112007
111820
  if (printer.bundleFileInfo)
112008
- printer.bundleFileInfo.hash = ts.computeSignature(text, host);
111821
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
112009
111822
  // Reset state
112010
111823
  writer.clear();
112011
111824
  }
@@ -112148,6 +111961,7 @@ var ts;
112148
111961
  }
112149
111962
  /*@internal*/
112150
111963
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
111964
+ var createHash = ts.maybeBind(host, host.createHash);
112151
111965
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
112152
111966
  var buildInfo;
112153
111967
  if (host.getBuildInfo) {
@@ -112169,25 +111983,25 @@ var ts;
112169
111983
  if (!jsFileText)
112170
111984
  return jsFilePath;
112171
111985
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
112172
- if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
111986
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
112173
111987
  return jsFilePath;
112174
111988
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
112175
111989
  // error if no source map or for now if inline sourcemap
112176
111990
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
112177
111991
  return sourceMapFilePath || "inline sourcemap decoding";
112178
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
111992
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
112179
111993
  return sourceMapFilePath;
112180
111994
  // read declaration text
112181
111995
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
112182
111996
  if (declarationFilePath && !declarationText)
112183
111997
  return declarationFilePath;
112184
- if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
111998
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
112185
111999
  return declarationFilePath;
112186
112000
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
112187
112001
  // error if no source map or for now if inline sourcemap
112188
112002
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
112189
112003
  return declarationMapPath || "inline sourcemap decoding";
112190
- if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
112004
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
112191
112005
  return declarationMapPath;
112192
112006
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
112193
112007
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -112227,7 +112041,7 @@ var ts;
112227
112041
  newBuildInfo.program = buildInfo.program;
112228
112042
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
112229
112043
  // Update the output signature
112230
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
112044
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
112231
112045
  }
112232
112046
  // Update sourceFileInfo
112233
112047
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
@@ -112261,7 +112075,7 @@ var ts;
112261
112075
  getSourceFileFromReference: ts.returnUndefined,
112262
112076
  redirectTargetsMap: ts.createMultiMap(),
112263
112077
  getFileIncludeReasons: ts.notImplemented,
112264
- createHash: ts.maybeBind(host, host.createHash),
112078
+ createHash: createHash,
112265
112079
  };
112266
112080
  emitFiles(ts.notImplementedResolver, emitHost,
112267
112081
  /*targetSourceFile*/ undefined, ts.getTransformers(config.options, customTransformers));
@@ -117738,7 +117552,7 @@ var ts;
117738
117552
  var result = void 0;
117739
117553
  var mode = getModeForFileReference(name, containingFileMode);
117740
117554
  // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
117741
- var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
117555
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
117742
117556
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
117743
117557
  if (cache.has(cacheKey)) {
117744
117558
  result = cache.get(cacheKey);
@@ -117842,22 +117656,8 @@ var ts;
117842
117656
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117843
117657
  }
117844
117658
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
117845
- var emptyResolution = {
117846
- resolvedModule: undefined,
117847
- resolvedTypeReferenceDirective: undefined,
117848
- failedLookupLocations: [],
117849
- affectingLocations: [],
117850
- resolutionDiagnostics: [],
117851
- };
117852
- function isResolvedModuleWithFailedLookupLocation(resolved) {
117853
- return !!resolved && !!resolved.failedLookupLocations;
117854
- }
117855
- function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
117856
- return !!resolved && !!resolved.failedLookupLocations;
117857
- }
117858
117659
  /* @internal */
117859
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
117860
- var _a;
117660
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
117861
117661
  if (names.length === 0) {
117862
117662
  return [];
117863
117663
  }
@@ -117867,7 +117667,7 @@ var ts;
117867
117667
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
117868
117668
  var name = names_3[_i];
117869
117669
  var result = void 0;
117870
- var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
117670
+ var mode = getModeForResolutionAtIndex(containingFile, i);
117871
117671
  i++;
117872
117672
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
117873
117673
  if (cache.has(cacheKey)) {
@@ -117932,14 +117732,14 @@ var ts;
117932
117732
  /*@internal*/
117933
117733
  function getReferencedFileLocation(getSourceFileByPath, ref) {
117934
117734
  var _a, _b, _c;
117935
- var _d, _e, _f, _g, _h, _j;
117735
+ var _d, _e, _f, _g;
117936
117736
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
117937
117737
  var kind = ref.kind, index = ref.index;
117938
117738
  var pos, end, packageId, resolutionMode;
117939
117739
  switch (kind) {
117940
117740
  case ts.FileIncludeKind.Import:
117941
117741
  var importLiteral = getModuleNameStringLiteralAt(file, index);
117942
- packageId = (_f = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.resolvedModule) === null || _f === void 0 ? void 0 : _f.packageId;
117742
+ packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.packageId;
117943
117743
  if (importLiteral.pos === -1)
117944
117744
  return { file: file, packageId: packageId, text: importLiteral.text };
117945
117745
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -117950,7 +117750,7 @@ var ts;
117950
117750
  break;
117951
117751
  case ts.FileIncludeKind.TypeReferenceDirective:
117952
117752
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
117953
- packageId = (_j = (_h = (_g = file.resolvedTypeReferenceDirectiveNames) === null || _g === void 0 ? void 0 : _g.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _h === void 0 ? void 0 : _h.resolvedTypeReferenceDirective) === null || _j === void 0 ? void 0 : _j.packageId;
117753
+ packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
117954
117754
  break;
117955
117755
  case ts.FileIncludeKind.LibReferenceDirective:
117956
117756
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -118180,10 +117980,10 @@ var ts;
118180
117980
  };
118181
117981
  }
118182
117982
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
118183
- var _a, _b, _c, _d, _e;
117983
+ var _a, _b, _c, _d;
118184
117984
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
118185
117985
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
118186
- var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
117986
+ var oldProgram = createProgramOptions.oldProgram;
118187
117987
  var processingDefaultLibFiles;
118188
117988
  var processingOtherFiles;
118189
117989
  var files;
@@ -118197,8 +117997,6 @@ var ts;
118197
117997
  var cachedDeclarationDiagnosticsForFile = {};
118198
117998
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
118199
117999
  var fileProcessingDiagnostics;
118200
- var automaticTypeDirectiveNames;
118201
- var automaticTypeDirectiveResolutions;
118202
118000
  // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
118203
118001
  // This works as imported modules are discovered recursively in a depth first manner, specifically:
118204
118002
  // - For each root file, findSourceFile is called.
@@ -118220,11 +118018,6 @@ var ts;
118220
118018
  var skipDefaultLib = options.noLib;
118221
118019
  var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
118222
118020
  var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
118223
- /**
118224
- * Diagnostics for the program
118225
- * Only add diagnostics directly if it always would be done irrespective of program structure reuse.
118226
- * Otherwise fileProcessingDiagnostics is correct locations so that the diagnostics can be reported in all structure use scenarios
118227
- */
118228
118021
  var programDiagnostics = ts.createDiagnosticCollection();
118229
118022
  var currentDirectory = host.getCurrentDirectory();
118230
118023
  var supportedExtensions = ts.getSupportedExtensions(options);
@@ -118237,71 +118030,30 @@ var ts;
118237
118030
  var actualResolveModuleNamesWorker;
118238
118031
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
118239
118032
  if (host.resolveModuleNames) {
118240
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
118241
- var _a;
118242
- var result = host.resolveModuleNames(moduleNames, containingFileName, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
118243
- var name = _a.name;
118244
- return name;
118245
- }), redirectedReference, options, containingFile, partialResolutionInfo);
118246
- return result.some(isResolvedModuleWithFailedLookupLocation) ?
118247
- result :
118248
- result.map(function (resolved) { return resolved ?
118249
- resolved.extension !== undefined ?
118250
- // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
118251
- { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
118252
- { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
118253
- emptyResolution; });
118254
- };
118033
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
118034
+ // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
118035
+ if (!resolved || resolved.extension !== undefined) {
118036
+ return resolved;
118037
+ }
118038
+ var withExtension = ts.clone(resolved);
118039
+ withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
118040
+ return withExtension;
118041
+ }); };
118255
118042
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
118256
118043
  }
118257
118044
  else {
118258
118045
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
118259
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
118260
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
118261
- return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
118262
- };
118046
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
118047
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
118263
118048
  }
118264
118049
  var actualResolveTypeReferenceDirectiveNamesWorker;
118265
118050
  if (host.resolveTypeReferenceDirectives) {
118266
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
118267
- var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
118268
- return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
118269
- result :
118270
- result.map(function (resolved) { return resolved ?
118271
- { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
118272
- emptyResolution; });
118273
- };
118274
- typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
118051
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
118275
118052
  }
118276
118053
  else {
118277
118054
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
118278
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
118279
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
118280
- return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
118281
- };
118282
- }
118283
- var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
118284
- var oldBuildInfoProgram;
118285
- if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
118286
- var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
118287
- oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
118288
- fileExists: function (fileName) { return host.fileExists(fileName); },
118289
- createHash: ts.maybeBind(host, host.createHash),
118290
- getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), /*onlyRecordFailures*/ false, state_11); },
118291
- });
118292
- if (oldBuildInfoProgram) {
118293
- // Ensure redirected references are verified before using existing cache
118294
- moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
118295
- getResolved: function (dirPath, name, mode, redirectedReference) {
118296
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
118297
- }
118298
- });
118299
- typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
118300
- getResolved: function (dirPath, name, mode, redirectedReference) {
118301
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
118302
- }
118303
- });
118304
- }
118055
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
118056
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
118305
118057
  }
118306
118058
  // Map from a stringified PackageId to the source file with that id.
118307
118059
  // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
@@ -118328,9 +118080,9 @@ var ts;
118328
118080
  var projectReferenceRedirects;
118329
118081
  var mapFromFileToProjectReferenceRedirects;
118330
118082
  var mapFromToProjectReferenceRedirectSource;
118331
- var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
118083
+ var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
118332
118084
  !options.disableSourceOfProjectReferenceRedirect;
118333
- var _f = updateHostForUseSourceOfProjectReferenceRedirect({
118085
+ var _e = updateHostForUseSourceOfProjectReferenceRedirect({
118334
118086
  compilerHost: host,
118335
118087
  getSymlinkCache: getSymlinkCache,
118336
118088
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -118338,7 +118090,7 @@ var ts;
118338
118090
  getResolvedProjectReferences: getResolvedProjectReferences,
118339
118091
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
118340
118092
  forEachResolvedProjectReference: forEachResolvedProjectReference
118341
- }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
118093
+ }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
118342
118094
  var readFile = host.readFile.bind(host);
118343
118095
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
118344
118096
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -118349,7 +118101,7 @@ var ts;
118349
118101
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
118350
118102
  structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
118351
118103
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118352
- if (structureIsReused !== 3 /* Completely */) {
118104
+ if (structureIsReused !== 2 /* Completely */) {
118353
118105
  processingDefaultLibFiles = [];
118354
118106
  processingOtherFiles = [];
118355
118107
  if (projectReferences) {
@@ -118390,15 +118142,16 @@ var ts;
118390
118142
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
118391
118143
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118392
118144
  // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
118393
- automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
118394
- automaticTypeDirectiveResolutions = ts.createModeAwareCache();
118395
- if (automaticTypeDirectiveNames.length) {
118396
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
118397
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
118398
- for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
118145
+ var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
118146
+ if (typeReferences.length) {
118147
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
118148
+ // This containingFilename needs to match with the one used in managed-side
118149
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
118150
+ var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
118151
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
118152
+ for (var i = 0; i < typeReferences.length; i++) {
118399
118153
  // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
118400
- automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i]);
118401
- processTypeReferenceDirective(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: automaticTypeDirectiveNames[i], packageId: (_d = resolutions[i].resolvedTypeReferenceDirective) === null || _d === void 0 ? void 0 : _d.packageId });
118154
+ processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
118402
118155
  }
118403
118156
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118404
118157
  }
@@ -118438,13 +118191,13 @@ var ts;
118438
118191
  if (shouldCreateNewSourceFile || !newFile ||
118439
118192
  // old file wasn't redirect but new file is
118440
118193
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
118441
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
118194
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
118442
118195
  }
118443
118196
  }
118444
118197
  if (!host.getParsedCommandLine) {
118445
118198
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
118446
118199
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
118447
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
118200
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false);
118448
118201
  }
118449
118202
  });
118450
118203
  }
@@ -118462,8 +118215,6 @@ var ts;
118462
118215
  typeReferenceDirectiveResolutionCache = undefined;
118463
118216
  // unconditionally set oldProgram to undefined to prevent it from being captured in closure
118464
118217
  oldProgram = undefined;
118465
- oldBuildInfoProgram = undefined;
118466
- oldProgramOrOldBuildInfoProgramConstructor = undefined;
118467
118218
  var program = {
118468
118219
  getRootFileNames: function () { return rootNames; },
118469
118220
  getSourceFile: getSourceFile,
@@ -118471,7 +118222,6 @@ var ts;
118471
118222
  getSourceFiles: function () { return files; },
118472
118223
  getMissingFilePaths: function () { return missingFilePaths; },
118473
118224
  getModuleResolutionCache: function () { return moduleResolutionCache; },
118474
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
118475
118225
  getFilesByNameMap: function () { return filesByName; },
118476
118226
  getCompilerOptions: function () { return options; },
118477
118227
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -118496,9 +118246,6 @@ var ts;
118496
118246
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
118497
118247
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
118498
118248
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
118499
- getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
118500
- getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
118501
- getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
118502
118249
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
118503
118250
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
118504
118251
  getSourceFileFromReference: getSourceFileFromReference,
@@ -118508,12 +118255,12 @@ var ts;
118508
118255
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
118509
118256
  isEmittedFile: isEmittedFile,
118510
118257
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
118258
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
118511
118259
  getProjectReferences: getProjectReferences,
118512
118260
  getResolvedProjectReferences: getResolvedProjectReferences,
118513
118261
  getProjectReferenceRedirect: getProjectReferenceRedirect,
118514
118262
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
118515
118263
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
118516
- getRedirectReferenceForResolution: getRedirectReferenceForResolution,
118517
118264
  forEachResolvedProjectReference: forEachResolvedProjectReference,
118518
118265
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
118519
118266
  emitBuildInfo: emitBuildInfo,
@@ -118521,7 +118268,7 @@ var ts;
118521
118268
  readFile: readFile,
118522
118269
  directoryExists: directoryExists,
118523
118270
  getSymlinkCache: getSymlinkCache,
118524
- realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
118271
+ realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
118525
118272
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
118526
118273
  getFileIncludeReasons: function () { return fileReasons; },
118527
118274
  structureIsReused: structureIsReused,
@@ -118536,8 +118283,6 @@ var ts;
118536
118283
  case 0 /* FilePreprocessingReferencedDiagnostic */:
118537
118284
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
118538
118285
  return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false)));
118539
- case 2 /* ResolutionDiagnostics */:
118540
- return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
118541
118286
  default:
118542
118287
  ts.Debug.assertNever(diagnostic);
118543
118288
  }
@@ -118547,46 +118292,63 @@ var ts;
118547
118292
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
118548
118293
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118549
118294
  return program;
118550
- function getAutomaticTypeDirectiveContainingFile() {
118551
- // This containingFilename needs to match with the one used in managed-side
118552
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
118553
- return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
118295
+ function addResolutionDiagnostics(list) {
118296
+ if (!list)
118297
+ return;
118298
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
118299
+ var elem = list_3[_i];
118300
+ programDiagnostics.add(elem);
118301
+ }
118554
118302
  }
118555
- function addResolutionDiagnostics(resolution) {
118556
- if (!resolution.resolutionDiagnostics)
118303
+ function pullDiagnosticsFromCache(names, containingFile) {
118304
+ var _a;
118305
+ if (!moduleResolutionCache)
118557
118306
  return;
118558
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
118559
- kind: 2 /* ResolutionDiagnostics */,
118560
- diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
118561
- ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
118562
- : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, d.entry === "" ? "." : d.entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
118563
- d.packagePath); })
118564
- });
118307
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
118308
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
118309
+ var containingDir = ts.getDirectoryPath(containingFileName);
118310
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
118311
+ var i = 0;
118312
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
118313
+ var n = names_4[_i];
118314
+ // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
118315
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
118316
+ var name = typeof n === "string" ? n : n.fileName;
118317
+ i++;
118318
+ // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
118319
+ // (Since diagnostics are only issued via import or export map lookup)
118320
+ // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
118321
+ // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
118322
+ // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
118323
+ if (ts.isExternalModuleNameRelative(name))
118324
+ continue;
118325
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
118326
+ addResolutionDiagnostics(diags);
118327
+ }
118565
118328
  }
118566
- function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
118329
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
118567
118330
  if (!moduleNames.length)
118568
118331
  return ts.emptyArray;
118569
118332
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
118570
- if (redirectedReference === undefined)
118571
- redirectedReference = getRedirectReferenceForResolution(containingFile);
118333
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
118572
118334
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
118573
118335
  ts.performance.mark("beforeResolveModule");
118574
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
118336
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
118575
118337
  ts.performance.mark("afterResolveModule");
118576
118338
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
118577
118339
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118340
+ pullDiagnosticsFromCache(moduleNames, containingFile);
118578
118341
  return result;
118579
118342
  }
118580
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
118343
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
118581
118344
  if (!typeDirectiveNames.length)
118582
118345
  return [];
118583
118346
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
118584
- if (redirectedReference === undefined && !ts.isString(containingFile))
118585
- redirectedReference = getRedirectReferenceForResolution(containingFile);
118347
+ var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
118586
118348
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
118587
118349
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
118588
118350
  ts.performance.mark("beforeResolveTypeReference");
118589
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
118351
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
118590
118352
  ts.performance.mark("afterResolveTypeReference");
118591
118353
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
118592
118354
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -118639,6 +118401,9 @@ var ts;
118639
118401
  }
118640
118402
  return ts.libs.length + 2;
118641
118403
  }
118404
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
118405
+ return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
118406
+ }
118642
118407
  function toPath(fileName) {
118643
118408
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
118644
118409
  }
@@ -118663,11 +118428,10 @@ var ts;
118663
118428
  return classifiableNames;
118664
118429
  }
118665
118430
  function resolveModuleNamesReusingOldState(moduleNames, file) {
118666
- var _a;
118667
118431
  if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
118668
118432
  // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
118669
118433
  // the best we can do is fallback to the default logic.
118670
- return resolveModuleNamesWorker(moduleNames, file, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
118434
+ return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined);
118671
118435
  }
118672
118436
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
118673
118437
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -118695,8 +118459,6 @@ var ts;
118695
118459
  // With this information, we can infer some module resolutions without performing resolution.
118696
118460
  /** An ordered list of module names for which we cannot recover the resolution. */
118697
118461
  var unknownModuleNames;
118698
- var unknownModuleNamesIndex;
118699
- var reusedNames;
118700
118462
  /**
118701
118463
  * The indexing of elements in this list matches that of `moduleNames`.
118702
118464
  *
@@ -118707,33 +118469,22 @@ var ts;
118707
118469
  * * ResolvedModuleFull instance: can be reused.
118708
118470
  */
118709
118471
  var result;
118472
+ var reusedNames;
118710
118473
  /** A transient placeholder used to mark predicted resolution in the result list. */
118711
- var predictedToResolveToAmbientModuleMarker = true;
118712
- var redirectedReference;
118474
+ var predictedToResolveToAmbientModuleMarker = {};
118713
118475
  for (var i = 0; i < moduleNames.length; i++) {
118714
118476
  var moduleName = moduleNames[i];
118715
118477
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
118716
- if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
118717
- var mode = getModeForResolutionAtIndex(file, i);
118718
- var oldResolution = !oldBuildInfoProgram ?
118719
- (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
118720
- oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
118721
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
118478
+ if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
118479
+ var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
118480
+ if (oldResolvedModule) {
118722
118481
  if (ts.isTraceEnabled(options, host)) {
118723
- var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
118724
- if (!oldBuildInfoProgram) {
118725
- ts.trace(host, oldResolution.resolvedModule.packageId ?
118726
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118727
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, fileLocation, oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
118728
- }
118729
- else {
118730
- ts.trace(host, oldResolution.resolvedModule.packageId ?
118731
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
118732
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, moduleName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
118733
- }
118482
+ ts.trace(host, oldResolvedModule.packageId ?
118483
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118484
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId));
118734
118485
  }
118735
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
118736
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
118486
+ (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
118487
+ (reusedNames || (reusedNames = [])).push(moduleName);
118737
118488
  continue;
118738
118489
  }
118739
118490
  }
@@ -118752,16 +118503,15 @@ var ts;
118752
118503
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
118753
118504
  }
118754
118505
  if (resolvesToAmbientModuleInNonModifiedFile) {
118755
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
118506
+ (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
118756
118507
  }
118757
118508
  else {
118758
118509
  // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
118759
- (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
118760
- (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
118510
+ (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
118761
118511
  }
118762
118512
  }
118763
118513
  var resolutions = unknownModuleNames && unknownModuleNames.length
118764
- ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
118514
+ ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
118765
118515
  : ts.emptyArray;
118766
118516
  // Combine results of resolutions and predicted results
118767
118517
  if (!result) {
@@ -118775,7 +118525,7 @@ var ts;
118775
118525
  // `result[i]` is either a `ResolvedModuleFull` or a marker.
118776
118526
  // If it is the former, we can leave it as is.
118777
118527
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
118778
- result[i] = emptyResolution;
118528
+ result[i] = undefined;
118779
118529
  }
118780
118530
  }
118781
118531
  else {
@@ -118810,96 +118560,6 @@ var ts;
118810
118560
  return true;
118811
118561
  }
118812
118562
  }
118813
- function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
118814
- var _a;
118815
- if (structureIsReused === 0 /* Not */) {
118816
- return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
118817
- }
118818
- var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
118819
- var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
118820
- var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
118821
- if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
118822
- // `file` was created for the new program.
118823
- //
118824
- // We only set `file.resolvedTypeReferenceDirectiveNames` via work from the current function,
118825
- // so it is defined iff we already called the current function on `file`.
118826
- // That call happened no later than the creation of the `file` object,
118827
- // which per above occurred during the current program creation.
118828
- // Since we assume the filesystem does not change during program creation,
118829
- // it is safe to reuse resolutions from the earlier call.
118830
- var result_15 = [];
118831
- for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
118832
- var typeDirectiveName = _b[_i];
118833
- // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
118834
- var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
118835
- result_15.push(resolvedTypeReferenceDirective);
118836
- }
118837
- return result_15;
118838
- }
118839
- /** An ordered list of module names for which we cannot recover the resolution. */
118840
- var unknownTypeReferenceDirectiveNames;
118841
- var unknownTypeReferenceDirectiveNamesIndex;
118842
- /**
118843
- * The indexing of elements in this list matches that of `moduleNames`.
118844
- *
118845
- * Before combining results, result[i] is in one of the following states:
118846
- * * undefined: needs to be recomputed,
118847
- */
118848
- var result;
118849
- var reusedNames;
118850
- var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
118851
- containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
118852
- !hasInvalidatedResolution(toPath(inferredTypeFile)));
118853
- var redirectedReference;
118854
- for (var i = 0; i < typeDirectiveNames.length; i++) {
118855
- var entry = typeDirectiveNames[i];
118856
- // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
118857
- if (canReuseResolutions) {
118858
- var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
118859
- var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
118860
- var oldResolution = !oldBuildInfoProgram ?
118861
- (_a = (containingSourceFile ? oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions())) === null || _a === void 0 ? void 0 : _a.get(typeDirectiveName, mode) :
118862
- oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
118863
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
118864
- if (ts.isTraceEnabled(options, host)) {
118865
- var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
118866
- if (!oldBuildInfoProgram) {
118867
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
118868
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118869
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2, typeDirectiveName, fileLocation, oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
118870
- }
118871
- else {
118872
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
118873
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
118874
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, typeDirectiveName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
118875
- }
118876
- }
118877
- (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
118878
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
118879
- continue;
118880
- }
118881
- }
118882
- // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
118883
- (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
118884
- (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
118885
- }
118886
- if (!unknownTypeReferenceDirectiveNames)
118887
- return result || ts.emptyArray;
118888
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
118889
- if (!result) {
118890
- ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
118891
- return resolutions;
118892
- }
118893
- var j = 0;
118894
- for (var i = 0; i < result.length; i++) {
118895
- if (!result[i]) {
118896
- result[i] = resolutions[j];
118897
- j++;
118898
- }
118899
- }
118900
- ts.Debug.assert(j === resolutions.length);
118901
- return result;
118902
- }
118903
118563
  function canReuseProjectReferences() {
118904
118564
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
118905
118565
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -118921,19 +118581,14 @@ var ts;
118921
118581
  });
118922
118582
  }
118923
118583
  function tryReuseStructureFromOldProgram() {
118924
- // check properties that can affect structure of the program or module resolution strategy
118925
- // if any of these properties has changed - structure cannot be reused
118926
- var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
118927
- if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
118584
+ var _a;
118585
+ if (!oldProgram) {
118928
118586
  return 0 /* Not */;
118929
118587
  }
118930
- var result = tryReuseStructureFromOldProgramWorker();
118931
- return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 /* Not */ ?
118932
- 1 /* SafeModuleCache */ :
118933
- result;
118934
- }
118935
- function tryReuseStructureFromOldProgramWorker() {
118936
- if (!oldProgram) {
118588
+ // check properties that can affect structure of the program or module resolution strategy
118589
+ // if any of these properties has changed - structure cannot be reused
118590
+ var oldOptions = oldProgram.getCompilerOptions();
118591
+ if (ts.changesAffectModuleResolution(oldOptions, options)) {
118937
118592
  return 0 /* Not */;
118938
118593
  }
118939
118594
  // there is an old program, check if we can reuse its structure
@@ -118951,7 +118606,7 @@ var ts;
118951
118606
  // check if program source files has changed in the way that can affect structure of the program
118952
118607
  var newSourceFiles = [];
118953
118608
  var modifiedSourceFiles = [];
118954
- structureIsReused = 3 /* Completely */;
118609
+ structureIsReused = 2 /* Completely */;
118955
118610
  // If the missing file paths are now present, it can change the progam structure,
118956
118611
  // and hence cant reuse the structure.
118957
118612
  // This is same as how we dont reuse the structure if one of the file from old program is now missing
@@ -119015,107 +118670,98 @@ var ts;
119015
118670
  // The `newSourceFile` object was created for the new program.
119016
118671
  if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
119017
118672
  // 'lib' references has changed. Matches behavior in changesAffectModuleResolution
119018
- structureIsReused = 2 /* SafeModules */;
118673
+ structureIsReused = 1 /* SafeModules */;
119019
118674
  }
119020
118675
  if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
119021
118676
  // value of no-default-lib has changed
119022
118677
  // this will affect if default library is injected into the list of files
119023
- structureIsReused = 2 /* SafeModules */;
118678
+ structureIsReused = 1 /* SafeModules */;
119024
118679
  }
119025
118680
  // check tripleslash references
119026
118681
  if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
119027
118682
  // tripleslash references has changed
119028
- structureIsReused = 2 /* SafeModules */;
118683
+ structureIsReused = 1 /* SafeModules */;
119029
118684
  }
119030
118685
  // check imports and module augmentations
119031
118686
  collectExternalModuleReferences(newSourceFile);
119032
118687
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
119033
118688
  // imports has changed
119034
- structureIsReused = 2 /* SafeModules */;
118689
+ structureIsReused = 1 /* SafeModules */;
119035
118690
  }
119036
118691
  if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
119037
118692
  // moduleAugmentations has changed
119038
- structureIsReused = 2 /* SafeModules */;
118693
+ structureIsReused = 1 /* SafeModules */;
119039
118694
  }
119040
118695
  if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
119041
118696
  // dynamicImport has changed
119042
- structureIsReused = 2 /* SafeModules */;
118697
+ structureIsReused = 1 /* SafeModules */;
119043
118698
  }
119044
118699
  if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
119045
118700
  // 'types' references has changed
119046
- structureIsReused = 2 /* SafeModules */;
118701
+ structureIsReused = 1 /* SafeModules */;
119047
118702
  }
119048
118703
  // tentatively approve the file
119049
118704
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119050
118705
  }
119051
118706
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
119052
118707
  // 'module/types' references could have changed
119053
- structureIsReused = 2 /* SafeModules */;
118708
+ structureIsReused = 1 /* SafeModules */;
119054
118709
  // add file to the modified list so that we will resolve it later
119055
118710
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119056
118711
  }
119057
118712
  // if file has passed all checks it should be safe to reuse it
119058
118713
  newSourceFiles.push(newSourceFile);
119059
118714
  }
119060
- if (structureIsReused !== 3 /* Completely */) {
118715
+ if (structureIsReused !== 2 /* Completely */) {
119061
118716
  return structureIsReused;
119062
118717
  }
119063
118718
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
119064
- for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
119065
- var oldFile = oldSourceFiles_3[_a];
118719
+ for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
118720
+ var oldFile = oldSourceFiles_3[_b];
119066
118721
  if (!ts.contains(modifiedFiles, oldFile)) {
119067
- for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
119068
- var moduleName = _c[_b];
118722
+ for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
118723
+ var moduleName = _d[_c];
119069
118724
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
119070
118725
  }
119071
118726
  }
119072
118727
  }
119073
118728
  // try to verify results of module resolution
119074
- for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
119075
- var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
118729
+ for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
118730
+ var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
119076
118731
  var moduleNames = getModuleNames(newSourceFile);
119077
118732
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
119078
118733
  // ensure that module resolution results are still correct
119079
118734
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
119080
118735
  if (resolutionsChanged) {
119081
- structureIsReused = 2 /* SafeModules */;
118736
+ structureIsReused = 1 /* SafeModules */;
119082
118737
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
119083
118738
  }
119084
118739
  else {
119085
118740
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
119086
118741
  }
119087
118742
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
119088
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
118743
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
119089
118744
  // ensure that types resolutions are still correct
119090
118745
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
119091
118746
  if (typeReferenceResolutionsChanged) {
119092
- structureIsReused = 2 /* SafeModules */;
118747
+ structureIsReused = 1 /* SafeModules */;
119093
118748
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
119094
118749
  }
119095
118750
  else {
119096
118751
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
119097
118752
  }
119098
118753
  }
119099
- if (structureIsReused !== 3 /* Completely */) {
118754
+ if (structureIsReused !== 2 /* Completely */) {
119100
118755
  return structureIsReused;
119101
118756
  }
119102
- if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
119103
- return 2 /* SafeModules */;
119104
- }
119105
- if (host.hasChangedAutomaticTypeDirectiveNames) {
119106
- if (host.hasChangedAutomaticTypeDirectiveNames())
119107
- return 2 /* SafeModules */;
119108
- }
119109
- else {
119110
- automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
119111
- if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
119112
- return 2 /* SafeModules */;
118757
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
118758
+ return 1 /* SafeModules */;
119113
118759
  }
119114
118760
  missingFilePaths = oldProgram.getMissingFilePaths();
119115
118761
  // update fileName -> file mapping
119116
118762
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
119117
- for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
119118
- var newSourceFile = newSourceFiles_1[_f];
118763
+ for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
118764
+ var newSourceFile = newSourceFiles_1[_g];
119119
118765
  filesByName.set(newSourceFile.path, newSourceFile);
119120
118766
  }
119121
118767
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -119137,12 +118783,10 @@ var ts;
119137
118783
  fileReasons = oldProgram.getFileIncludeReasons();
119138
118784
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
119139
118785
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
119140
- automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
119141
- automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
119142
118786
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
119143
118787
  redirectTargetsMap = oldProgram.redirectTargetsMap;
119144
118788
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
119145
- return 3 /* Completely */;
118789
+ return 2 /* Completely */;
119146
118790
  }
119147
118791
  function getEmitHost(writeFileCallback) {
119148
118792
  return {
@@ -120184,42 +119828,35 @@ var ts;
120184
119828
  }
120185
119829
  function processTypeReferenceDirectives(file) {
120186
119830
  var typeDirectives = file.typeReferenceDirectives;
120187
- if (!typeDirectives.length) {
120188
- file.resolvedTypeReferenceDirectiveNames = undefined;
119831
+ if (!typeDirectives) {
120189
119832
  return;
120190
119833
  }
120191
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
119834
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
120192
119835
  for (var index = 0; index < typeDirectives.length; index++) {
120193
119836
  var ref = file.typeReferenceDirectives[index];
120194
119837
  var resolvedTypeReferenceDirective = resolutions[index];
120195
119838
  // store resolved type directive on the file
120196
119839
  var fileName = ts.toFileNameLowerCase(ref.fileName);
120197
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
119840
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
120198
119841
  var mode = ref.resolutionMode || file.impliedNodeFormat;
120199
119842
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
120200
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
120201
- kind: 2 /* ResolutionDiagnostics */,
120202
- diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
120203
- });
119843
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
120204
119844
  }
120205
119845
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
120206
119846
  }
120207
119847
  }
120208
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
120209
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
120210
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
119848
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119849
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
119850
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
120211
119851
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
120212
119852
  }
120213
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
120214
- var _a;
120215
- addResolutionDiagnostics(resolution);
119853
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
120216
119854
  // If we already found this library as a primary reference - nothing to do
120217
- var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
119855
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
120218
119856
  if (previousResolution && previousResolution.primary) {
120219
119857
  return;
120220
119858
  }
120221
119859
  var saveResolution = true;
120222
- var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
120223
119860
  if (resolvedTypeReferenceDirective) {
120224
119861
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
120225
119862
  currentNodeModulesDepth++;
@@ -120254,7 +119891,7 @@ var ts;
120254
119891
  addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
120255
119892
  }
120256
119893
  if (saveResolution) {
120257
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
119894
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
120258
119895
  }
120259
119896
  }
120260
119897
  function pathForLibFile(libFileName) {
@@ -120287,7 +119924,7 @@ var ts;
120287
119924
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
120288
119925
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
120289
119926
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
120290
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
119927
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
120291
119928
  kind: 0 /* FilePreprocessingReferencedDiagnostic */,
120292
119929
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
120293
119930
  diagnostic: diagnostic,
@@ -120311,14 +119948,13 @@ var ts;
120311
119948
  for (var index = 0; index < moduleNames.length; index++) {
120312
119949
  var resolution = resolutions[index];
120313
119950
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
120314
- addResolutionDiagnostics(resolution);
120315
- if (!resolution.resolvedModule) {
119951
+ if (!resolution) {
120316
119952
  continue;
120317
119953
  }
120318
- var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
120319
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
119954
+ var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
119955
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
120320
119956
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
120321
- var resolvedFileName = resolution.resolvedModule.resolvedFileName;
119957
+ var resolvedFileName = resolution.resolvedFileName;
120322
119958
  if (isFromNodeModulesSearch) {
120323
119959
  currentNodeModulesDepth++;
120324
119960
  }
@@ -120331,7 +119967,7 @@ var ts;
120331
119967
  // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs')
120332
119968
  // This may still end up being an untyped module -- the file won't be included but imports will be allowed.
120333
119969
  var shouldAddFile = resolvedFileName
120334
- && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
119970
+ && !getResolutionDiagnostic(optionsForFile, resolution)
120335
119971
  && !optionsForFile.noResolve
120336
119972
  && index < file.imports.length
120337
119973
  && !elideImport
@@ -120343,7 +119979,7 @@ var ts;
120343
119979
  else if (shouldAddFile) {
120344
119980
  findSourceFile(resolvedFileName,
120345
119981
  /*isDefaultLib*/ false,
120346
- /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
119982
+ /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
120347
119983
  }
120348
119984
  if (isFromNodeModulesSearch) {
120349
119985
  currentNodeModulesDepth--;
@@ -120447,9 +120083,6 @@ var ts;
120447
120083
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
120448
120084
  }
120449
120085
  }
120450
- if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
120451
- createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
120452
- }
120453
120086
  var outputFile = ts.outFile(options);
120454
120087
  if (options.tsBuildInfoFile) {
120455
120088
  if (!ts.isIncrementalCompilation(options)) {
@@ -120718,7 +120351,7 @@ var ts;
120718
120351
  }
120719
120352
  }
120720
120353
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
120721
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
120354
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
120722
120355
  kind: 1 /* FilePreprocessingFileExplainingDiagnostic */,
120723
120356
  file: file && file.path,
120724
120357
  fileProcessingReason: fileProcessingReason,
@@ -120986,8 +120619,8 @@ var ts;
120986
120619
  if (!symlinks) {
120987
120620
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
120988
120621
  }
120989
- if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
120990
- symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
120622
+ if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
120623
+ symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
120991
120624
  }
120992
120625
  return symlinks;
120993
120626
  }
@@ -121400,8 +121033,7 @@ var ts;
121400
121033
  }
121401
121034
  // Handle type reference directives
121402
121035
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
121403
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
121404
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
121036
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
121405
121037
  if (!resolvedTypeReferenceDirective) {
121406
121038
  return;
121407
121039
  }
@@ -121460,13 +121092,12 @@ var ts;
121460
121092
  /**
121461
121093
  * Creates the state of file references and signature for the new program from oldState if it is safe
121462
121094
  */
121463
- function create(newProgram, oldState, disableUseFileVersionAsSignature) {
121095
+ function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
121464
121096
  var _a, _b, _c;
121465
121097
  var fileInfos = new ts.Map();
121466
121098
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
121467
121099
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
121468
121100
  var useOldState = canReuseOldState(referencedMap, oldState);
121469
- var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
121470
121101
  // Ensure source files have parent pointers set
121471
121102
  newProgram.getTypeChecker();
121472
121103
  // Create the reference map, and set the file infos
@@ -121519,23 +121150,23 @@ var ts;
121519
121150
  /**
121520
121151
  * Gets the files affected by the path from the program
121521
121152
  */
121522
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
121153
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
121523
121154
  var _a, _b;
121524
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
121155
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
121525
121156
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
121526
121157
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121527
121158
  return result;
121528
121159
  }
121529
121160
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
121530
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
121161
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
121531
121162
  var sourceFile = programOfThisState.getSourceFileByPath(path);
121532
121163
  if (!sourceFile) {
121533
121164
  return ts.emptyArray;
121534
121165
  }
121535
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
121166
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121536
121167
  return [sourceFile];
121537
121168
  }
121538
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
121169
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
121539
121170
  }
121540
121171
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
121541
121172
  function updateSignatureOfFile(state, signature, path) {
@@ -121546,7 +121177,7 @@ var ts;
121546
121177
  /**
121547
121178
  * Returns if the shape of the signature has changed since last emit
121548
121179
  */
121549
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
121180
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
121550
121181
  var _a;
121551
121182
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
121552
121183
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -121558,7 +121189,7 @@ var ts;
121558
121189
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
121559
121190
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
121560
121191
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
121561
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
121192
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
121562
121193
  if (latestSignature !== prevSignature) {
121563
121194
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
121564
121195
  }
@@ -121737,7 +121368,7 @@ var ts;
121737
121368
  /**
121738
121369
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
121739
121370
  */
121740
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
121371
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
121741
121372
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
121742
121373
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
121743
121374
  }
@@ -121757,7 +121388,7 @@ var ts;
121757
121388
  if (!seenFileNamesMap.has(currentPath)) {
121758
121389
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
121759
121390
  seenFileNamesMap.set(currentPath, currentSourceFile);
121760
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
121391
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121761
121392
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
121762
121393
  }
121763
121394
  }
@@ -121782,9 +121413,9 @@ var ts;
121782
121413
  /**
121783
121414
  * Create the state so that we can iterate on changedFiles/affected files
121784
121415
  */
121785
- function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
121416
+ function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
121786
121417
  var _a, _b;
121787
- var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
121418
+ var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
121788
121419
  state.program = newProgram;
121789
121420
  var compilerOptions = newProgram.getCompilerOptions();
121790
121421
  state.compilerOptions = compilerOptions;
@@ -121848,7 +121479,7 @@ var ts;
121848
121479
  // Unchanged file copy diagnostics
121849
121480
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
121850
121481
  if (diagnostics) {
121851
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
121482
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
121852
121483
  if (!state.semanticDiagnosticsFromOldState) {
121853
121484
  state.semanticDiagnosticsFromOldState = new ts.Set();
121854
121485
  }
@@ -121873,16 +121504,13 @@ var ts;
121873
121504
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
121874
121505
  }
121875
121506
  // Since old states change files set is copied, any additional change means we would need to emit build info
121876
- state.buildInfoEmitPending = !useOldState ||
121877
- state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
121878
- state.fileInfos.size !== oldState.fileInfos.size;
121507
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
121879
121508
  return state;
121880
121509
  }
121881
- function convertToDiagnostics(diagnostics, newProgram) {
121510
+ function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
121882
121511
  if (!diagnostics.length)
121883
121512
  return ts.emptyArray;
121884
- var buildInfoDirectory;
121885
- var getCanonicalFileName;
121513
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
121886
121514
  return diagnostics.map(function (diagnostic) {
121887
121515
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
121888
121516
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -121898,8 +121526,7 @@ var ts;
121898
121526
  return result;
121899
121527
  });
121900
121528
  function toPath(path) {
121901
- buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
121902
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
121529
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
121903
121530
  }
121904
121531
  }
121905
121532
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -121911,9 +121538,6 @@ var ts;
121911
121538
  */
121912
121539
  function releaseCache(state) {
121913
121540
  ts.BuilderState.releaseCache(state);
121914
- // Store the resolutions if possible
121915
- if (!state.resuableCacheResolutions)
121916
- getCacheResolutions(state);
121917
121541
  state.program = undefined;
121918
121542
  }
121919
121543
  function backupBuilderProgramEmitState(state) {
@@ -121958,7 +121582,7 @@ var ts;
121958
121582
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121959
121583
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121960
121584
  */
121961
- function getNextAffectedFile(state, cancellationToken, host) {
121585
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121962
121586
  var _a, _b;
121963
121587
  while (true) {
121964
121588
  var affectedFiles = state.affectedFiles;
@@ -121970,7 +121594,7 @@ var ts;
121970
121594
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121971
121595
  // Set the next affected file as seen and remove the cached semantic diagnostics
121972
121596
  state.affectedFilesIndex = affectedFilesIndex;
121973
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
121597
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121974
121598
  return affectedFile;
121975
121599
  }
121976
121600
  affectedFilesIndex++;
@@ -121998,7 +121622,7 @@ var ts;
121998
121622
  return program;
121999
121623
  }
122000
121624
  // Get next batch of affected files
122001
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
121625
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
122002
121626
  state.currentChangedFilePath = nextKey.value;
122003
121627
  state.affectedFilesIndex = 0;
122004
121628
  if (!state.seenAffectedFiles)
@@ -122049,7 +121673,7 @@ var ts;
122049
121673
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
122050
121674
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
122051
121675
  */
122052
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
121676
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122053
121677
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
122054
121678
  // If affected files is everything except default library, then nothing more to do
122055
121679
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -122057,18 +121681,18 @@ var ts;
122057
121681
  // When a change affects the global scope, all files are considered to be affected without updating their signature
122058
121682
  // That means when affected file is handled, its signature can be out of date
122059
121683
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
122060
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
121684
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
122061
121685
  return;
122062
121686
  }
122063
121687
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
122064
121688
  return;
122065
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
121689
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
122066
121690
  }
122067
121691
  /**
122068
121692
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
122069
121693
  * Also we need to make sure signature is updated for these files
122070
121694
  */
122071
- function handleDtsMayChangeOf(state, path, cancellationToken, host) {
121695
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
122072
121696
  removeSemanticDiagnosticsOf(state, path);
122073
121697
  if (!state.changedFilesSet.has(path)) {
122074
121698
  var program = ts.Debug.checkDefined(state.program);
@@ -122079,7 +121703,7 @@ var ts;
122079
121703
  // This ensures that we dont later during incremental builds considering wrong signature.
122080
121704
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
122081
121705
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
122082
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
121706
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
122083
121707
  // If not dts emit, nothing more to do
122084
121708
  if (ts.getEmitDeclarations(state.compilerOptions)) {
122085
121709
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -122104,20 +121728,20 @@ var ts;
122104
121728
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
122105
121729
  return newSignature !== oldSignature;
122106
121730
  }
122107
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
121731
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
122108
121732
  var _a;
122109
121733
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
122110
121734
  return false;
122111
121735
  // Every file needs to be handled
122112
121736
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
122113
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
121737
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
122114
121738
  removeDiagnosticsOfLibraryFiles(state);
122115
121739
  return true;
122116
121740
  }
122117
121741
  /**
122118
121742
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
122119
121743
  */
122120
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
121744
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122121
121745
  var _a;
122122
121746
  // If there was change in signature (dts output) for the changed file,
122123
121747
  // then only we need to handle pending file emit
@@ -122135,9 +121759,9 @@ var ts;
122135
121759
  var currentPath = queue.pop();
122136
121760
  if (!seenFileNamesMap.has(currentPath)) {
122137
121761
  seenFileNamesMap.set(currentPath, true);
122138
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
121762
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
122139
121763
  return;
122140
- handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
121764
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
122141
121765
  if (isChangedSignature(state, currentPath)) {
122142
121766
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
122143
121767
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -122149,11 +121773,11 @@ var ts;
122149
121773
  // Go through exported modules from cache first
122150
121774
  // If exported modules has path, all files referencing file exported from are affected
122151
121775
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
122152
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
121776
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
122153
121777
  return true;
122154
121778
  var references = state.referencedMap.getKeys(exportedFromPath);
122155
121779
  return references && ts.forEachKey(references, function (filePath) {
122156
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
121780
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
122157
121781
  });
122158
121782
  });
122159
121783
  }
@@ -122161,22 +121785,22 @@ var ts;
122161
121785
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
122162
121786
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
122163
121787
  */
122164
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
121788
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122165
121789
  var _a, _b;
122166
121790
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
122167
121791
  return undefined;
122168
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
121792
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
122169
121793
  return true;
122170
- handleDtsMayChangeOf(state, filePath, cancellationToken, host);
121794
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
122171
121795
  // If exported modules has path, all files referencing file exported from are affected
122172
121796
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
122173
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
121797
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
122174
121798
  });
122175
121799
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
122176
121800
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
122177
121801
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
122178
121802
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
122179
- state, referencingFilePath, cancellationToken, host);
121803
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
122180
121804
  });
122181
121805
  return undefined;
122182
121806
  }
@@ -122255,46 +121879,35 @@ var ts;
122255
121879
  /**
122256
121880
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
122257
121881
  */
122258
- function getProgramBuildInfo(state, host) {
121882
+ function getProgramBuildInfo(state, getCanonicalFileName) {
122259
121883
  var outFilePath = ts.outFile(state.compilerOptions);
122260
- if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
121884
+ if (outFilePath && !state.compilerOptions.composite)
122261
121885
  return;
122262
121886
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
122263
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
122264
- var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
122265
- var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
121887
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
122266
121888
  // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path
122267
121889
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
122268
- var fileNames = [];
122269
- var fileNameToFileId = new ts.Map();
122270
- var resolutions;
122271
- var names;
122272
- var resolutionNameToResolutionNameId;
122273
- var resolutionEntries;
122274
- var resolutionEntryToResolutionEntryId;
122275
- var affectedFilesHash;
122276
121890
  if (outFilePath) {
122277
- var fileInfos_1;
122278
- if (state.compilerOptions.composite) {
122279
- state.program.getRootFileNames().forEach(function (f) {
122280
- var sourceFile = state.program.getSourceFile(f);
122281
- if (!sourceFile)
122282
- return;
122283
- var fileId = toFileId(sourceFile.resolvedPath);
122284
- (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
122285
- });
122286
- }
122287
- var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
122288
- var result_16 = {
122289
- fileNames: fileNames,
121891
+ var fileNames_1 = [];
121892
+ var fileInfos_1 = [];
121893
+ state.program.getRootFileNames().forEach(function (f) {
121894
+ var sourceFile = state.program.getSourceFile(f);
121895
+ if (!sourceFile)
121896
+ return;
121897
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121898
+ fileInfos_1.push(sourceFile.version);
121899
+ });
121900
+ var result_15 = {
121901
+ fileNames: fileNames_1,
122290
121902
  fileInfos: fileInfos_1,
122291
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
121903
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
122292
121904
  outSignature: state.outSignature,
122293
121905
  latestChangedDtsFile: latestChangedDtsFile,
122294
- cacheResolutions: cacheResolutions_1,
122295
121906
  };
122296
- return result_16;
121907
+ return result_15;
122297
121908
  }
121909
+ var fileNames = [];
121910
+ var fileNameToFileId = new ts.Map();
122298
121911
  var fileIdsList;
122299
121912
  var fileNamesToFileIdListId;
122300
121913
  var emitSignatures;
@@ -122358,7 +121971,7 @@ var ts;
122358
121971
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
122359
121972
  [
122360
121973
  toFileId(key),
122361
- value.map(toReusableDiagnostic)
121974
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
122362
121975
  ] :
122363
121976
  toFileId(key));
122364
121977
  }
@@ -122380,11 +121993,10 @@ var ts;
122380
121993
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
122381
121994
  }
122382
121995
  }
122383
- var cacheResolutions = toProgramBuildInfoCacheResolutions();
122384
121996
  var result = {
122385
121997
  fileNames: fileNames,
122386
121998
  fileInfos: fileInfos,
122387
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
121999
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
122388
122000
  fileIdsList: fileIdsList,
122389
122001
  referencedMap: referencedMap,
122390
122002
  exportedModulesMap: exportedModulesMap,
@@ -122393,7 +122005,6 @@ var ts;
122393
122005
  changeFileSet: changeFileSet,
122394
122006
  emitSignatures: emitSignatures,
122395
122007
  latestChangedDtsFile: latestChangedDtsFile,
122396
- cacheResolutions: cacheResolutions,
122397
122008
  };
122398
122009
  return result;
122399
122010
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -122402,7 +122013,7 @@ var ts;
122402
122013
  function relativeToBuildInfo(path) {
122403
122014
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
122404
122015
  }
122405
- function toFileAndAbsoluteFileId(path) {
122016
+ function toFileId(path) {
122406
122017
  var fileId = fileNameToFileId.get(path);
122407
122018
  if (fileId === undefined) {
122408
122019
  fileNames.push(relativeToBuildInfo(path));
@@ -122410,12 +122021,6 @@ var ts;
122410
122021
  }
122411
122022
  return fileId;
122412
122023
  }
122413
- function toFileId(path) {
122414
- return toFileAndAbsoluteFileId(path);
122415
- }
122416
- function toAbsoluteFileId(path) {
122417
- return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
122418
- }
122419
122024
  function toFileIdListId(set) {
122420
122025
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
122421
122026
  var key = fileIds.join();
@@ -122428,241 +122033,54 @@ var ts;
122428
122033
  }
122429
122034
  /**
122430
122035
  * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
122431
- * @param affectsModuleResolution serialize options affecting module resolution
122432
122036
  */
122433
- function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
122037
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
122434
122038
  var result;
122435
122039
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
122436
122040
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
122437
122041
  var name = _a[_i];
122438
122042
  var optionInfo = optionsNameMap.get(name.toLowerCase());
122439
- if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
122440
- (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
122441
- }
122442
- else if (affectsModuleResolution && name === "pathsBasePath") {
122443
- (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
122444
- continue;
122043
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
122044
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
122445
122045
  }
122446
122046
  }
122447
122047
  return result;
122448
122048
  }
122449
- function toReusableCompilerOptionValue(option, value) {
122450
- if (option) {
122451
- if (option.type === "list") {
122452
- var values = value;
122453
- if (option.element.isFilePath && values.length) {
122454
- return values.map(relativeToBuildInfoEnsuringAbsolutePath);
122455
- }
122456
- }
122457
- else if (option.isFilePath) {
122458
- return relativeToBuildInfoEnsuringAbsolutePath(value);
122049
+ }
122050
+ function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
122051
+ if (option) {
122052
+ if (option.type === "list") {
122053
+ var values = value;
122054
+ if (option.element.isFilePath && values.length) {
122055
+ return values.map(relativeToBuildInfo);
122459
122056
  }
122460
122057
  }
122461
- return value;
122462
- }
122463
- function toReadonlyArrayOrUndefined(array, map) {
122464
- return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
122058
+ else if (option.isFilePath) {
122059
+ return relativeToBuildInfo(value);
122060
+ }
122465
122061
  }
122466
- function toReusableDiagnostic(diagnostic) {
122467
- var result = toReusableDiagnosticRelatedInformation(diagnostic);
122062
+ return value;
122063
+ }
122064
+ function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
122065
+ ts.Debug.assert(!!diagnostics.length);
122066
+ return diagnostics.map(function (diagnostic) {
122067
+ var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
122468
122068
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
122469
122069
  result.reportDeprecated = diagnostic.reportsDeprecated;
122470
122070
  result.source = diagnostic.source;
122471
122071
  result.skippedOn = diagnostic.skippedOn;
122472
122072
  var relatedInformation = diagnostic.relatedInformation;
122473
- result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
122474
- return result;
122475
- }
122476
- function toReusableDiagnosticRelatedInformation(diagnostic) {
122477
- var file = diagnostic.file;
122478
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
122479
- }
122480
- function toProgramBuildInfoCacheResolutions() {
122481
- var cacheResolutions = getCacheResolutions(state);
122482
- var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
122483
- var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
122484
- if (!resolutions)
122485
- return;
122486
- ts.Debug.assertIsDefined(names);
122487
- ts.Debug.assertIsDefined(resolutionEntries);
122488
- state.resuableCacheResolutions = {
122489
- cache: {
122490
- resolutions: resolutions.map(toProgramBuildInfoResolution),
122491
- names: names,
122492
- hash: toProgramBuildInfoHashes(),
122493
- resolutionEntries: resolutionEntries,
122494
- modules: modules,
122495
- typeRefs: typeRefs,
122496
- },
122497
- getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
122498
- };
122499
- return state.resuableCacheResolutions.cache;
122500
- }
122501
- function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
122502
- if (!cache)
122503
- return undefined;
122504
- var ownMap = cache.getOwnMap();
122505
- var own = toProgramBuildInfoResolutionCache(ownMap);
122506
- var redirects;
122507
- cache.redirectsKeyToCache.forEach(function (_a) {
122508
- var map = _a.map, options = _a.options;
122509
- if (map === ownMap)
122510
- return;
122511
- var redirectCache = toProgramBuildInfoResolutionCache(map);
122512
- if (redirectCache) {
122513
- (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
122514
- options: toProgramBuildInfoCompilerOptions(options, /*optionKey*/ undefined, /*affectsModuleResolution*/ true),
122515
- cache: redirectCache
122516
- });
122517
- }
122518
- });
122519
- return !redirects ? own : { own: own, redirects: redirects };
122520
- }
122521
- function toProgramBuildInfoResolutionCache(cache) {
122522
- var result;
122523
- cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
122524
- (result !== null && result !== void 0 ? result : (result = [])).push([
122525
- toFileId(dirPath),
122526
- ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
122527
- ]) :
122528
- undefined; });
122073
+ result.relatedInformation = relatedInformation ?
122074
+ relatedInformation.length ?
122075
+ relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
122076
+ [] :
122077
+ undefined;
122529
122078
  return result;
122530
- }
122531
- function toProgramBuildInfoResolutionEntryId(_a) {
122532
- var name = _a[0], mode = _a[1], resolution = _a[2];
122533
- var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
122534
- var resolutionId = toProgramBuildInfoResolutionId(resolution);
122535
- var key = resolutionNameId + "," + mode + "," + resolutionId;
122536
- var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
122537
- if (resolutionEntryId === undefined) {
122538
- (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
122539
- (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
122540
- }
122541
- return resolutionEntryId;
122542
- }
122543
- function toProgramBuildInfoResolutionNameId(name) {
122544
- var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
122545
- if (resolutionNameId === undefined) {
122546
- (names !== null && names !== void 0 ? names : (names = [])).push(name);
122547
- (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
122548
- }
122549
- return resolutionNameId;
122550
- }
122551
- function toProgramBuildInfoResolutionId(resolution) {
122552
- if (resolution.serializationIndex === undefined) {
122553
- (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
122554
- resolution.serializationIndex = resolutions.length;
122555
- }
122556
- return resolution.serializationIndex;
122557
- }
122558
- function toProgramBuildInfoResolution(resolution) {
122559
- resolution.serializationIndex = undefined;
122560
- return {
122561
- resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
122562
- resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
122563
- affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
122564
- resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
122565
- };
122566
- }
122567
- function toProgramBuildInfoHashes() {
122568
- if (!affectedFilesHash)
122569
- return undefined;
122570
- var hashes = [];
122571
- for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
122572
- var key = _a[_i];
122573
- var value = affectedFilesHash.get(key);
122574
- hashes.push(value ? [key, value] : key);
122575
- }
122576
- return hashes;
122577
- }
122578
- function toAffectedFileId(file) {
122579
- var _a;
122580
- var fileId = toAbsoluteFileId(file);
122581
- if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
122582
- // Store the file hash
122583
- var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
122584
- var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
122585
- (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
122586
- }
122587
- return fileId;
122588
- }
122589
- function toProgramBuildInfoResolved(resolved) {
122590
- return resolved ? __assign(__assign({}, resolved), { resolvedFileName: toAbsoluteFileId(resolved.resolvedFileName), isExternalLibraryImport: resolved.isExternalLibraryImport ? true : undefined, originalPath: resolved.originalPath ? toAbsoluteFileId(resolved.originalPath) : undefined, primary: resolved.primary || undefined, extension: undefined }) : undefined;
122591
- }
122592
- function toProgramBuildInfoResolutionDiagnostic(d) {
122593
- return {
122594
- isImports: d.isImports || undefined,
122595
- entry: d.entry || undefined,
122596
- packagePath: toAbsoluteFileId(d.packagePath),
122597
- };
122598
- }
122599
- }
122600
- function getCacheResolutions(state) {
122601
- var _a;
122602
- if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
122603
- return state.cacheResolutions;
122604
- var modules;
122605
- var typeRefs;
122606
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
122607
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
122608
- state.program.getSourceFiles().forEach(function (f) {
122609
- modules = toPerDirectoryCache(state, getCanonicalFileName, modules, f, f.resolvedModules, moduleNameToDirectoryMap);
122610
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, f, f.resolvedTypeReferenceDirectiveNames);
122611
122079
  });
122612
- var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
122613
- if (automaticTypeDirectiveNames.length) {
122614
- var currentDirectory = state.program.getCurrentDirectory();
122615
- var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
122616
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
122617
- }
122618
- return state.cacheResolutions = {
122619
- modules: modules,
122620
- typeRefs: typeRefs,
122621
- moduleNameToDirectoryMap: moduleNameToDirectoryMap,
122622
- packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
122623
- };
122624
122080
  }
122625
- function toPerDirectoryCache(state, getCanonicalFileName, cacheWithRedirects, fOrPath, cache, moduleNameToDirectoryMap) {
122626
- if (!(cache === null || cache === void 0 ? void 0 : cache.size()))
122627
- return cacheWithRedirects;
122628
- var dirPath, redirectedReference;
122629
- if (!ts.isString(fOrPath)) {
122630
- redirectedReference = state.program.getRedirectReferenceForResolution(fOrPath);
122631
- dirPath = ts.getDirectoryPath(fOrPath.path);
122632
- }
122633
- else {
122634
- dirPath = ts.getDirectoryPath(fOrPath);
122635
- }
122636
- var perDirResolutionCache = cacheWithRedirects === null || cacheWithRedirects === void 0 ? void 0 : cacheWithRedirects.getMapOfCacheRedirects(redirectedReference);
122637
- var dirCache = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
122638
- cache.forEach(function (resolution, name, mode) {
122639
- var _a, _b, _c, _d;
122640
- if (!((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) && !((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.resolvedFileName))
122641
- return;
122642
- if (dirCache === null || dirCache === void 0 ? void 0 : dirCache.has(name, mode))
122643
- return;
122644
- // If there was already external module resolution that is same, set for child directory, dont set resolution for this directory
122645
- if (moduleNameToDirectoryMap &&
122646
- !ts.isExternalModuleNameRelative(name) &&
122647
- ((_d = (_c = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath))) {
122648
- return;
122649
- }
122650
- if (!dirCache) {
122651
- perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (cacheWithRedirects !== null && cacheWithRedirects !== void 0 ? cacheWithRedirects : (cacheWithRedirects = ts.createCacheWithRedirects(state.compilerOptions))).getOrCreateMapOfCacheRedirects(redirectedReference));
122652
- perDirResolutionCache.set(dirPath, dirCache = ts.createModeAwareCache());
122653
- }
122654
- dirCache.set(name, mode, resolution);
122655
- if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
122656
- return;
122657
- // put result in per-module name cache and delete everything that is not needed
122658
- var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(redirectedReference);
122659
- var key = ts.getModeAwareCacheKey(name, mode);
122660
- var directoryPathMap = actualModuleNameToDirectoryMap.get(key);
122661
- if (!directoryPathMap)
122662
- actualModuleNameToDirectoryMap.set(key, directoryPathMap = new ts.Map());
122663
- ts.moduleNameToDirectorySet(directoryPathMap, dirPath, resolution, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
122664
- });
122665
- return cacheWithRedirects;
122081
+ function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
122082
+ var file = diagnostic.file;
122083
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
122666
122084
  }
122667
122085
  var BuilderProgramKind;
122668
122086
  (function (BuilderProgramKind) {
@@ -122686,7 +122104,7 @@ var ts;
122686
122104
  rootNames: newProgramOrRootNames,
122687
122105
  options: hostOrOptions,
122688
122106
  host: oldProgramOrHost,
122689
- oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
122107
+ oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
122690
122108
  configFileParsingDiagnostics: configFileParsingDiagnostics,
122691
122109
  projectReferences: projectReferences
122692
122110
  });
@@ -122704,8 +122122,8 @@ var ts;
122704
122122
  function getTextHandlingSourceMapForSignature(text, data) {
122705
122123
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
122706
122124
  }
122707
- function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
122708
- var _a, _b;
122125
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
122126
+ var _a;
122709
122127
  text = getTextHandlingSourceMapForSignature(text, data);
122710
122128
  var sourceFileDirectory;
122711
122129
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -122713,7 +122131,7 @@ var ts;
122713
122131
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
122714
122132
  }).join("\n");
122715
122133
  }
122716
- return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
122134
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
122717
122135
  function flattenDiagnosticMessageText(diagnostic) {
122718
122136
  return ts.isString(diagnostic) ?
122719
122137
  diagnostic :
@@ -122732,9 +122150,8 @@ var ts;
122732
122150
  }
122733
122151
  }
122734
122152
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
122735
- function computeSignature(text, host, data) {
122736
- var _a;
122737
- return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
122153
+ function computeSignature(text, computeHash, data) {
122154
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
122738
122155
  }
122739
122156
  ts.computeSignature = computeSignature;
122740
122157
  function createBuilderProgram(kind, _a) {
@@ -122746,8 +122163,16 @@ var ts;
122746
122163
  oldState = undefined;
122747
122164
  return oldProgram;
122748
122165
  }
122749
- var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
122750
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
122166
+ /**
122167
+ * Create the canonical file name for identity
122168
+ */
122169
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
122170
+ /**
122171
+ * Computing hash to for signature verification
122172
+ */
122173
+ var computeHash = ts.maybeBind(host, host.createHash);
122174
+ var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
122175
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
122751
122176
  // To ensure that we arent storing any references to old program or new program without state
122752
122177
  newProgram = undefined; // TODO: GH#18217
122753
122178
  oldProgram = undefined;
@@ -122762,7 +122187,6 @@ var ts;
122762
122187
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
122763
122188
  builderProgram.emit = emit;
122764
122189
  builderProgram.releaseProgram = function () { return releaseCache(state); };
122765
- builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
122766
122190
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
122767
122191
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
122768
122192
  }
@@ -122789,7 +122213,7 @@ var ts;
122789
122213
  * in that order would be used to write the files
122790
122214
  */
122791
122215
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
122792
- var affected = getNextAffectedFile(state, cancellationToken, host);
122216
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122793
122217
  var emitKind = 1 /* Full */;
122794
122218
  var isPendingEmitFile = false;
122795
122219
  if (!affected) {
@@ -122835,7 +122259,7 @@ var ts;
122835
122259
  var file = sourceFiles[0];
122836
122260
  var info = state.fileInfos.get(file.resolvedPath);
122837
122261
  if (info.signature === file.version) {
122838
- var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
122262
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
122839
122263
  // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts
122840
122264
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
122841
122265
  emitSignature = signature;
@@ -122865,7 +122289,7 @@ var ts;
122865
122289
  if (state.compilerOptions.composite) {
122866
122290
  var filePath = sourceFiles[0].resolvedPath;
122867
122291
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122868
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
122292
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122869
122293
  // Dont write dts files if they didn't change
122870
122294
  if (emitSignature === oldSignature)
122871
122295
  return;
@@ -122875,7 +122299,7 @@ var ts;
122875
122299
  }
122876
122300
  }
122877
122301
  else if (state.compilerOptions.composite) {
122878
- var newSignature = computeSignature(text, host, data);
122302
+ var newSignature = computeSignature(text, computeHash, data);
122879
122303
  // Dont write dts files if they didn't change
122880
122304
  if (newSignature === state.outSignature)
122881
122305
  return;
@@ -122957,7 +122381,7 @@ var ts;
122957
122381
  */
122958
122382
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
122959
122383
  while (true) {
122960
- var affected = getNextAffectedFile(state, cancellationToken, host);
122384
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122961
122385
  if (!affected) {
122962
122386
  // Done
122963
122387
  return undefined;
@@ -123037,32 +122461,12 @@ var ts;
123037
122461
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
123038
122462
  }
123039
122463
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
123040
- function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
123041
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
123042
- var filePaths;
123043
- var fileAbsolutePaths;
123044
- return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
123045
- function toPath(path) {
123046
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
123047
- }
123048
- function toAbsolutePath(path) {
123049
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
123050
- }
123051
- function toFilePath(fileId) {
123052
- var _a;
123053
- return (_a = filePaths === null || filePaths === void 0 ? void 0 : filePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((filePaths !== null && filePaths !== void 0 ? filePaths : (filePaths = new Array(fileNames.length)))[fileId - 1] = toPath(fileNames[fileId - 1]));
123054
- }
123055
- function toFileAbsolutePath(fileId) {
123056
- var _a;
123057
- return (_a = fileAbsolutePaths === null || fileAbsolutePaths === void 0 ? void 0 : fileAbsolutePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((fileAbsolutePaths !== null && fileAbsolutePaths !== void 0 ? fileAbsolutePaths : (fileAbsolutePaths = new Array(fileNames.length)))[fileId - 1] = toAbsolutePath(fileNames[fileId - 1]));
123058
- }
123059
- }
123060
- ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
123061
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
123062
- var _a, _b, _c;
123063
- var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
123064
- var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
122464
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
122465
+ var _a, _b, _c, _d;
122466
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
122467
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
123065
122468
  var state;
122469
+ var filePaths;
123066
122470
  var filePathsSetList;
123067
122471
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
123068
122472
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -123071,13 +122475,13 @@ var ts;
123071
122475
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
123072
122476
  latestChangedDtsFile: latestChangedDtsFile,
123073
122477
  outSignature: program.outSignature,
123074
- resuableCacheResolutions: toResuableCacheResolutions(),
123075
122478
  };
123076
122479
  }
123077
122480
  else {
123078
- filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
122481
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
122482
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
123079
122483
  var fileInfos_2 = new ts.Map();
123080
- var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
122484
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
123081
122485
  program.fileInfos.forEach(function (fileInfo, index) {
123082
122486
  var path = toFilePath(index + 1);
123083
122487
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -123085,7 +122489,7 @@ var ts;
123085
122489
  if (emitSignatures_1 && stateFileInfo.signature)
123086
122490
  emitSignatures_1.set(path, stateFileInfo.signature);
123087
122491
  });
123088
- (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
122492
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
123089
122493
  if (ts.isNumber(value))
123090
122494
  emitSignatures_1.delete(toFilePath(value));
123091
122495
  else
@@ -123104,17 +122508,14 @@ var ts;
123104
122508
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
123105
122509
  latestChangedDtsFile: latestChangedDtsFile,
123106
122510
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
123107
- resuableCacheResolutions: toResuableCacheResolutions(),
123108
122511
  };
123109
122512
  }
123110
- state.compilerOptions.configFilePath = configFilePath;
123111
122513
  return {
123112
122514
  getState: function () { return state; },
123113
122515
  saveEmitState: ts.noop,
123114
122516
  restoreEmitState: ts.noop,
123115
122517
  getProgram: ts.notImplemented,
123116
122518
  getProgramOrUndefined: ts.returnUndefined,
123117
- getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
123118
122519
  releaseProgram: ts.noop,
123119
122520
  getCompilerOptions: function () { return state.compilerOptions; },
123120
122521
  getSourceFile: ts.notImplemented,
@@ -123134,6 +122535,15 @@ var ts;
123134
122535
  close: ts.noop,
123135
122536
  hasChangedEmitSignature: ts.returnFalse,
123136
122537
  };
122538
+ function toPath(path) {
122539
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
122540
+ }
122541
+ function toAbsolutePath(path) {
122542
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
122543
+ }
122544
+ function toFilePath(fileId) {
122545
+ return filePaths[fileId - 1];
122546
+ }
123137
122547
  function toFilePathsSet(fileIdsListId) {
123138
122548
  return filePathsSetList[fileIdsListId - 1];
123139
122549
  }
@@ -123148,194 +122558,8 @@ var ts;
123148
122558
  });
123149
122559
  return map;
123150
122560
  }
123151
- function toResuableCacheResolutions() {
123152
- return program.cacheResolutions && {
123153
- cache: program.cacheResolutions,
123154
- getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
123155
- };
123156
- }
123157
122561
  }
123158
122562
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
123159
- function createGetProgramOrOldBuildInfoProgramUndefined(state) {
123160
- return function () {
123161
- var _a;
123162
- return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
123163
- (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions,
123164
- // Prefer cached resolutions over serialized format
123165
- !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
123166
- undefined);
123167
- };
123168
- }
123169
- function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
123170
- if (!cacheResolutions && !resuableCacheResolutions)
123171
- return undefined;
123172
- var fileExistsMap = new ts.Map();
123173
- var affectingLoationsSameMap = new ts.Map();
123174
- var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
123175
- var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
123176
- var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
123177
- var decodedHashes;
123178
- var resolutions;
123179
- var originalPathOrResolvedFileNames;
123180
- var resolutionEntries;
123181
- return {
123182
- getCompilerOptions: function () { return compilerOptions; },
123183
- getResolvedModule: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.modules, decodedResolvedModules, dirPath, name, mode, redirectedReference, cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap); },
123184
- getResolvedTypeReferenceDirective: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.typeRefs, decodedResolvedTypeRefs, dirPath, name, mode, redirectedReference,
123185
- /*moduleNameToDirectoryMap*/ undefined,
123186
- /*decodedModuleNameToDirectoryMap*/ undefined); },
123187
- };
123188
- function fileExists(fileName) {
123189
- var result = fileExistsMap.get(fileName);
123190
- if (result === undefined)
123191
- fileExistsMap.set(fileName, result = host.fileExists(fileName));
123192
- return result;
123193
- }
123194
- function affectingLocationsSame(fileName, expected) {
123195
- var _a;
123196
- var result = affectingLoationsSameMap.get(fileName);
123197
- if (result !== undefined)
123198
- return result;
123199
- var packageJsonInfo = host.getPackageJsonInfo(fileName);
123200
- var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
123201
- if (ts.isString(expected)) {
123202
- result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
123203
- }
123204
- else {
123205
- var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
123206
- result = currentText === expectedText;
123207
- }
123208
- affectingLoationsSameMap.set(fileName, result);
123209
- return result;
123210
- }
123211
- function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
123212
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
123213
- // If we are using the cache, directly get from there
123214
- var fromCache = ((_b = (_a = cache === null || cache === void 0 ? void 0 : cache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
123215
- ((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
123216
- if (fromCache) {
123217
- return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
123218
- fromCache.resolvedTypeReferenceDirective.resolvedFileName) && ts.every(fromCache.affectingLocations, function (fileName) { var _a; return affectingLocationsSame(fileName, (_a = cacheResolutions.packageJsonCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(fileName)); }) ? fromCache : undefined;
123219
- }
123220
- if (!reusableCache)
123221
- return undefined;
123222
- // Decode so we have maps for directories
123223
- if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
123224
- if (ts.isArray(reusableCache)) {
123225
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache, decodedModuleNameToDirectoryMap);
123226
- }
123227
- else {
123228
- if (reusableCache.own)
123229
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
123230
- reusableCache.redirects.forEach(function (_a) {
123231
- var options = _a.options, cache = _a.cache;
123232
- var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
123233
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
123234
- });
123235
- }
123236
- // Ensure redirected reference verifies options before using redirects map
123237
- decodedReusableCache.clearRedirectsMap();
123238
- decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
123239
- }
123240
- var resolutionId = ((_g = (_f = decodedReusableCache.getMapOfCacheRedirects(redirectedReference)) === null || _f === void 0 ? void 0 : _f.get(dirPath)) === null || _g === void 0 ? void 0 : _g.get(name, mode)) ||
123241
- ((_j = (_h = decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _h === void 0 ? void 0 : _h.get(ts.getModeAwareCacheKey(name, mode))) === null || _j === void 0 ? void 0 : _j.get(dirPath));
123242
- return resolutionId ? toResolution(resolutionId) : undefined;
123243
- }
123244
- function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
123245
- var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
123246
- reusableCache.forEach(function (_a) {
123247
- var dirId = _a[0], entryId = _a[1];
123248
- var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
123249
- map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
123250
- });
123251
- }
123252
- function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
123253
- var modeAwareCache = ts.createModeAwareCache();
123254
- entries.forEach(function (entryId) {
123255
- var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
123256
- modeAwareCache.set(name, mode, resolutionId);
123257
- if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
123258
- return;
123259
- var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
123260
- var key = ts.getModeAwareCacheKey(name, mode);
123261
- var moduleNameMap = mapForOptions.get(key);
123262
- ;
123263
- if (!moduleNameMap)
123264
- mapForOptions.set(key, moduleNameMap = new ts.Map());
123265
- ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
123266
- });
123267
- return modeAwareCache;
123268
- }
123269
- function toResolutionEntry(entryId) {
123270
- var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
123271
- if (existing)
123272
- return existing;
123273
- resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
123274
- var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
123275
- return resolutionEntries[entryId - 1] = [
123276
- toName(nameId),
123277
- resolutionId,
123278
- mode
123279
- ];
123280
- }
123281
- function toName(nameId) {
123282
- return resuableCacheResolutions.cache.names[nameId - 1];
123283
- }
123284
- function toOriginalPathOrResolvedFileName(resolutionId) {
123285
- var _a;
123286
- return (_a = originalPathOrResolvedFileNames === null || originalPathOrResolvedFileNames === void 0 ? void 0 : originalPathOrResolvedFileNames[resolutionId - 1]) !== null && _a !== void 0 ? _a : ((originalPathOrResolvedFileNames !== null && originalPathOrResolvedFileNames !== void 0 ? originalPathOrResolvedFileNames : (originalPathOrResolvedFileNames = new Array(resuableCacheResolutions.cache.resolutions.length)))[resolutionId - 1] = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.originalPath ||
123287
- resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
123288
- }
123289
- function toAffectingFileLocation(fileId) {
123290
- if (!decodedHashes && resuableCacheResolutions.cache.hash) {
123291
- decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
123292
- }
123293
- var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
123294
- var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
123295
- return affectingLocationsSame(file, hash) ? file : undefined;
123296
- }
123297
- function toResolution(resolutionId) {
123298
- var _a, _b;
123299
- var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
123300
- if (existing !== undefined)
123301
- return existing || undefined;
123302
- resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
123303
- var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
123304
- var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
123305
- var affectingLocations;
123306
- if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
123307
- var file = toAffectingFileLocation(fileId);
123308
- if (file)
123309
- (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
123310
- return !!file;
123311
- })) {
123312
- // Type Ref doesnt need extension
123313
- var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
123314
- return resolutions[resolutionId - 1] = {
123315
- resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
123316
- resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
123317
- failedLookupLocations: ts.emptyArray,
123318
- affectingLocations: affectingLocations,
123319
- resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
123320
- };
123321
- }
123322
- resolutions[resolutionId - 1] = false;
123323
- return undefined;
123324
- }
123325
- function toResolved(resolved, resolvedFileName, extension) {
123326
- if (!resolved)
123327
- return undefined;
123328
- return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
123329
- }
123330
- function toResolutionDiagnostic(d) {
123331
- return {
123332
- isImports: !!d.isImports,
123333
- entry: d.entry || "",
123334
- packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
123335
- };
123336
- }
123337
- }
123338
- ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
123339
122563
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
123340
122564
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
123341
122565
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -123355,7 +122579,6 @@ var ts;
123355
122579
  restoreEmitState: ts.noop,
123356
122580
  getProgram: getProgram,
123357
122581
  getProgramOrUndefined: function () { return getState().program; },
123358
- getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
123359
122582
  releaseProgram: function () { return getState().program = undefined; },
123360
122583
  getCompilerOptions: function () { return getState().compilerOptions; },
123361
122584
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -123454,10 +122677,11 @@ var ts;
123454
122677
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
123455
122678
  var filesWithChangedSetOfUnresolvedImports;
123456
122679
  var filesWithInvalidatedResolutions;
122680
+ var filesWithInvalidatedNonRelativeUnresolvedImports;
122681
+ var nonRelativeExternalModuleResolutions = ts.createMultiMap();
123457
122682
  var resolutionsWithFailedLookups = [];
123458
122683
  var resolutionsWithOnlyAffectingLocations = [];
123459
122684
  var resolvedFileToResolution = ts.createMultiMap();
123460
- var resolutionsToCloseWatcherOn;
123461
122685
  var hasChangedAutomaticTypeDirectiveNames = false;
123462
122686
  var affectingPathChecks;
123463
122687
  var failedLookupChecks;
@@ -123465,15 +122689,18 @@ var ts;
123465
122689
  var isInDirectoryChecks;
123466
122690
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217
123467
122691
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
123468
- var oldModuleAndTypeRefCache;
123469
122692
  // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
123470
122693
  // The key in the map is source file's path.
123471
122694
  // The values are Map of resolutions with key being name lookedup.
123472
122695
  var resolvedModuleNames = new ts.Map();
123473
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
122696
+ var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
122697
+ var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
122698
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
122699
+ /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
123474
122700
  var resolvedTypeReferenceDirectives = new ts.Map();
122701
+ var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
123475
122702
  var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
123476
- /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache());
122703
+ /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
123477
122704
  /**
123478
122705
  * These are the extensions that failed lookup files will have by default,
123479
122706
  * any other extension of failed lookup will be store that path in custom failed lookup path
@@ -123490,23 +122717,26 @@ var ts;
123490
122717
  // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames
123491
122718
  var typeRootsWatches = new ts.Map();
123492
122719
  return {
123493
- resolvedModuleNames: resolvedModuleNames,
123494
- resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
123495
122720
  getModuleResolutionCache: function () { return moduleResolutionCache; },
123496
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
123497
122721
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
123498
122722
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
123499
122723
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
123500
122724
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
123501
- startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
122725
+ startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
123502
122726
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
123503
122727
  resolveModuleNames: resolveModuleNames,
122728
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
123504
122729
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
122730
+ removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
122731
+ removeResolutionsOfFile: removeResolutionsOfFile,
123505
122732
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
123506
122733
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123507
122734
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123508
122735
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123509
122736
  createHasInvalidatedResolution: createHasInvalidatedResolution,
122737
+ isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
122738
+ updateTypeRootsWatch: updateTypeRootsWatch,
122739
+ closeTypeRootsWatch: closeTypeRootsWatch,
123510
122740
  clear: clear
123511
122741
  };
123512
122742
  function getResolvedModule(resolution) {
@@ -123525,6 +122755,7 @@ var ts;
123525
122755
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
123526
122756
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
123527
122757
  customFailedLookupPaths.clear();
122758
+ nonRelativeExternalModuleResolutions.clear();
123528
122759
  closeTypeRootsWatch();
123529
122760
  resolvedModuleNames.clear();
123530
122761
  resolvedTypeReferenceDirectives.clear();
@@ -123535,12 +122766,9 @@ var ts;
123535
122766
  startsWithPathChecks = undefined;
123536
122767
  isInDirectoryChecks = undefined;
123537
122768
  affectingPathChecks = undefined;
123538
- resolutionsToCloseWatcherOn = undefined;
123539
122769
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
123540
122770
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
123541
- moduleResolutionCache.clear();
123542
- typeReferenceDirectiveResolutionCache.clear();
123543
- oldModuleAndTypeRefCache = undefined;
122771
+ clearPerDirectoryResolutions();
123544
122772
  hasChangedAutomaticTypeDirectiveNames = false;
123545
122773
  }
123546
122774
  function startRecordingFilesWithChangedResolutions() {
@@ -123551,6 +122779,14 @@ var ts;
123551
122779
  filesWithChangedSetOfUnresolvedImports = undefined;
123552
122780
  return collected;
123553
122781
  }
122782
+ function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
122783
+ if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
122784
+ return false;
122785
+ }
122786
+ // Invalidated if file has unresolved imports
122787
+ var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
122788
+ return !!value && !!value.length;
122789
+ }
123554
122790
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123555
122791
  // Ensure pending resolutions are applied
123556
122792
  invalidateResolutionsOfFailedLookupLocations();
@@ -123561,155 +122797,36 @@ var ts;
123561
122797
  }
123562
122798
  var collected = filesWithInvalidatedResolutions;
123563
122799
  filesWithInvalidatedResolutions = undefined;
123564
- return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
122800
+ return function (path) { return (!!collected && collected.has(path)) ||
122801
+ isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123565
122802
  }
123566
- function startCachingPerDirectoryResolution() {
122803
+ function clearPerDirectoryResolutions() {
123567
122804
  moduleResolutionCache.clear();
123568
122805
  typeReferenceDirectiveResolutionCache.clear();
123569
- moduleResolutionCache.update(resolutionHost.getCompilationSettings());
123570
- typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
123571
- if (oldModuleAndTypeRefCache) {
123572
- oldModuleAndTypeRefCache.clearRedirectsMap();
123573
- moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
123574
- typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
123575
- }
122806
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122807
+ nonRelativeExternalModuleResolutions.clear();
123576
122808
  }
123577
- function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122809
+ function finishCachingPerDirectoryResolution() {
122810
+ filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
122811
+ clearPerDirectoryResolutions();
122812
+ directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
122813
+ if (watcher.refCount === 0) {
122814
+ directoryWatchesOfFailedLookups.delete(path);
122815
+ watcher.watcher.close();
122816
+ }
122817
+ });
122818
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
122819
+ if (watcher.refCount === 0) {
122820
+ fileWatchesOfAffectingLocations.delete(path);
122821
+ watcher.watcher.close();
122822
+ // Ensure when watching symlinked package.json, we can close the actual file watcher only once
122823
+ watcher.watcher = ts.noopFileWatcher;
122824
+ }
122825
+ });
123578
122826
  hasChangedAutomaticTypeDirectiveNames = false;
123579
- if (!newProgram) {
123580
- clear();
123581
- return;
123582
- }
123583
- if (newProgram === oldProgram || newProgram.structureIsReused === 3 /* Completely */)
123584
- return;
123585
- var modules;
123586
- var typeRefs;
123587
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
123588
- // Update resolution caches
123589
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
123590
- var f = _a[_i];
123591
- modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, f.resolvedModules, f, getResolvedModule, modules, moduleNameToDirectoryMap);
123592
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, f.resolvedTypeReferenceDirectiveNames, f, getResolvedTypeReferenceDirective, typeRefs,
123593
- /*moduleNameToDirectoryMap*/ undefined);
123594
- }
123595
- var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
123596
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirective, typeRefs,
123597
- /*moduleNameToDirectoryMap*/ undefined);
123598
- if (!modules && !typeRefs) {
123599
- oldModuleAndTypeRefCache = undefined;
123600
- }
123601
- else {
123602
- oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
123603
- }
123604
- // Remove resolutions for files not in the program
123605
- if (oldProgram) {
123606
- for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
123607
- var f = _c[_b];
123608
- if (!newProgram.getSourceFileByPath(f.path))
123609
- removeResolutionsOfFile(f.path);
123610
- }
123611
- var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
123612
- if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
123613
- removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
123614
- }
123615
- }
123616
- if (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions())
123617
- updateTypeRootsWatch();
123618
- // Remove symlinked watchers that have zero ref count
123619
- resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
123620
- resolutionsToCloseWatcherOn = undefined;
123621
- fileWatchesOfAffectingLocations.forEach(closeAffectingFileWatcher);
123622
- }
123623
- function closeAffectingFileWatcher(watcher, path) {
123624
- if (watcher.refCount === 0) {
123625
- fileWatchesOfAffectingLocations.delete(path);
123626
- watcher.watcher.close();
123627
- // Ensure when watching symlinked package.json, we can close the actual file watcher only once
123628
- watcher.watcher = ts.noopFileWatcher;
123629
- }
123630
- }
123631
- function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
123632
- var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
123633
- var resolutionsInFile = perFileCache.get(path);
123634
- var seenNamesInFile = ts.createModeAwareCache();
123635
- if (fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()) {
123636
- // If keys dont match release existing resolutions
123637
- var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
123638
- var options_3 = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
123639
- var key_2 = ts.getRedirectsCacheKey(options_3);
123640
- if (resolutionsInFile && resolutionsInFile.key !== key_2) {
123641
- resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
123642
- resolutionsInFile = undefined;
123643
- }
123644
- var dirPath_1 = ts.getDirectoryPath(path);
123645
- var perDirResolutionCache_1 = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
123646
- var cacheForDir_1 = perDirResolutionCache_1 === null || perDirResolutionCache_1 === void 0 ? void 0 : perDirResolutionCache_1.get(dirPath_1);
123647
- fileCacheFromProgram.forEach(function (r, name, mode) {
123648
- seenNamesInFile.set(name, mode, true);
123649
- var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
123650
- if (existing && r !== existing)
123651
- stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
123652
- watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
123653
- if (!resolutionsInFile)
123654
- perFileCache.set(path, resolutionsInFile = { key: key_2, cache: ts.createModeAwareCache() });
123655
- resolutionsInFile.cache.set(name, mode, r);
123656
- if (cacheForDir_1 === null || cacheForDir_1 === void 0 ? void 0 : cacheForDir_1.has(name, mode))
123657
- return;
123658
- if (!cacheForDir_1) {
123659
- perDirResolutionCache_1 !== null && perDirResolutionCache_1 !== void 0 ? perDirResolutionCache_1 : (perDirResolutionCache_1 = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options_3, key_2));
123660
- perDirResolutionCache_1.set(dirPath_1, cacheForDir_1 = ts.createModeAwareCache());
123661
- }
123662
- cacheForDir_1.set(name, mode, r);
123663
- if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
123664
- return;
123665
- var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options_3, key_2);
123666
- var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
123667
- var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
123668
- if (!directoryPathMap)
123669
- actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
123670
- ts.moduleNameToDirectorySet(directoryPathMap, dirPath_1, r, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
123671
- });
123672
- }
123673
- if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
123674
- // Stop watching and remove the unused name
123675
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
123676
- if (!seenNamesInFile.has(name, mode)) {
123677
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
123678
- resolutionsInFile.cache.delete(name, mode);
123679
- }
123680
- });
123681
- if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
123682
- perFileCache.delete(path);
123683
- }
123684
- return perDirCache;
123685
- }
123686
- function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
123687
- if (!modules && !typeRefs)
123688
- return undefined;
123689
- return {
123690
- modules: {
123691
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
123692
- },
123693
- typeRefs: {
123694
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, /*moduleNameToDirectoryMap*/ undefined); }
123695
- },
123696
- clearRedirectsMap: function () {
123697
- modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
123698
- typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
123699
- moduleNameToDirectoryMap.clearRedirectsMap();
123700
- },
123701
- };
123702
- }
123703
- function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
123704
- var _a, _b, _c, _d;
123705
- if (!perDirCache)
123706
- return undefined;
123707
- var result = ((_b = (_a = perDirCache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
123708
- ((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
123709
- return result && !result.isInvalidated ? result : undefined;
123710
122827
  }
123711
122828
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
123712
- var _a;
122829
+ var _a, _b;
123713
122830
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
123714
122831
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
123715
122832
  if (!resolutionHost.getGlobalCache) {
@@ -123720,16 +122837,12 @@ var ts;
123720
122837
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
123721
122838
  // create different collection of failed lookup locations for second pass
123722
122839
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
123723
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations, affectingLocations = _b.affectingLocations, resolutionDiagnostics = _b.resolutionDiagnostics;
122840
+ var _c = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _c.resolvedModule, failedLookupLocations = _c.failedLookupLocations, affectingLocations = _c.affectingLocations;
123724
122841
  if (resolvedModule) {
123725
122842
  // Modify existing resolution so its saved in the directory cache as well
123726
122843
  primaryResult.resolvedModule = resolvedModule;
123727
- if (!compilerOptions.cacheResolutions)
123728
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
123729
- else
123730
- primaryResult.failedLookupLocations.length = 0;
123731
- primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
123732
- primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
122844
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122845
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
123733
122846
  return primaryResult;
123734
122847
  }
123735
122848
  }
@@ -123740,41 +122853,76 @@ var ts;
123740
122853
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
123741
122854
  }
123742
122855
  function resolveNamesWithLocalCache(_a) {
123743
- var _b, _c, _d, _e;
123744
- var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, perFileCache = _a.perFileCache, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, partialResolutionInfo = _a.partialResolutionInfo, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
122856
+ var _b, _c, _d;
122857
+ var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
123745
122858
  var path = resolutionHost.toPath(containingFile);
123746
- var resolutionsInFile = perFileCache.get(path);
123747
- var compilerOptions = resolutionHost.getCompilationSettings();
123748
- var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
123749
- if (!resolutionsInFile || resolutionsInFile.key !== key) {
123750
- resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
123751
- perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
122859
+ var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
122860
+ var dirPath = ts.getDirectoryPath(path);
122861
+ var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
122862
+ var perDirectoryResolution = perDirectoryCache.get(dirPath);
122863
+ if (!perDirectoryResolution) {
122864
+ perDirectoryResolution = ts.createModeAwareCache();
122865
+ perDirectoryCache.set(dirPath, perDirectoryResolution);
123752
122866
  }
123753
122867
  var resolvedModules = [];
122868
+ var compilerOptions = resolutionHost.getCompilationSettings();
122869
+ var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
122870
+ // All the resolutions in this file are invalidated if this file wasn't resolved using same redirect
122871
+ var program = resolutionHost.getCurrentProgram();
122872
+ var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
122873
+ var unmatchedRedirects = oldRedirect ?
122874
+ !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
122875
+ !!redirectedReference;
123754
122876
  var seenNamesInFile = ts.createModeAwareCache();
123755
122877
  var i = 0;
123756
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
123757
- var entry = names_4[_i];
123758
- var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
122878
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
122879
+ var entry = names_5[_i];
122880
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
123759
122881
  // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
123760
122882
  // they require calculating the mode for a given import from it's position in the resolution table, since a given
123761
122883
  // import's syntax may override the file's default mode.
123762
122884
  // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
123763
122885
  // a default file mode override if applicable.
123764
122886
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
123765
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
122887
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
123766
122888
  i++;
123767
- var resolution = resolutionsInFile.cache.get(name, mode);
122889
+ var resolution = resolutionsInFile.get(name, mode);
123768
122890
  // Resolution is valid if it is present and not invalidated
123769
- if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
122891
+ if (!seenNamesInFile.has(name, mode) &&
122892
+ unmatchedRedirects || !resolution || resolution.isInvalidated ||
122893
+ // If the name is unresolved import that was invalidated, recalculate
122894
+ (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
123770
122895
  var existingResolution = resolution;
123771
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
123772
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
123773
- resolutionHost.onDiscoveredSymlink();
122896
+ var resolutionInDirectory = perDirectoryResolution.get(name, mode);
122897
+ if (resolutionInDirectory) {
122898
+ resolution = resolutionInDirectory;
122899
+ var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
122900
+ if (ts.isTraceEnabled(compilerOptions, host)) {
122901
+ var resolved = getResolutionWithResolvedFileName(resolution);
122902
+ ts.trace(host, loader === resolveModuleName ?
122903
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
122904
+ resolved.packagetId ?
122905
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
122906
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
122907
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
122908
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
122909
+ resolved.packagetId ?
122910
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
122911
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
122912
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId));
122913
+ }
122914
+ }
122915
+ else {
122916
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
122917
+ perDirectoryResolution.set(name, mode, resolution);
122918
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
122919
+ resolutionHost.onDiscoveredSymlink();
122920
+ }
123774
122921
  }
123775
- resolutionsInFile.cache.set(name, mode, resolution);
122922
+ resolutionsInFile.set(name, mode, resolution);
122923
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
123776
122924
  if (existingResolution) {
123777
- stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
122925
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
123778
122926
  }
123779
122927
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
123780
122928
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -123788,34 +122936,28 @@ var ts;
123788
122936
  var resolved = getResolutionWithResolvedFileName(resolution);
123789
122937
  ts.trace(host, loader === resolveModuleName ?
123790
122938
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123791
- resolved.packageId ?
122939
+ resolved.packagetId ?
123792
122940
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
123793
122941
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
123794
122942
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
123795
122943
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123796
- resolved.packageId ?
122944
+ resolved.packagetId ?
123797
122945
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
123798
122946
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
123799
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packageId) && ts.packageIdToString(resolved.packageId));
122947
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId));
123800
122948
  }
123801
122949
  }
123802
122950
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
123803
122951
  seenNamesInFile.set(name, mode, true);
123804
- resolvedModules.push(resolution);
122952
+ resolvedModules.push(getResolutionWithResolvedFileName(resolution));
123805
122953
  }
123806
- (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
123807
- var name = _a.name, mode = _a.mode;
123808
- return seenNamesInFile.set(name, mode, true);
122954
+ // Stop watching and remove the unused name
122955
+ resolutionsInFile.forEach(function (resolution, name, mode) {
122956
+ if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
122957
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
122958
+ resolutionsInFile.delete(name, mode);
122959
+ }
123809
122960
  });
123810
- if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
123811
- // Stop watching and remove the unused name
123812
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
123813
- if (!seenNamesInFile.has(name, mode)) {
123814
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
123815
- resolutionsInFile.cache.delete(name, mode);
123816
- }
123817
- });
123818
- }
123819
122961
  return resolvedModules;
123820
122962
  function resolutionIsEqualTo(oldResolution, newResolution) {
123821
122963
  if (oldResolution === newResolution) {
@@ -123835,31 +122977,40 @@ var ts;
123835
122977
  return oldResult.resolvedFileName === newResult.resolvedFileName;
123836
122978
  }
123837
122979
  }
123838
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
122980
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
123839
122981
  return resolveNamesWithLocalCache({
123840
122982
  names: typeDirectiveNames,
123841
122983
  containingFile: containingFile,
123842
122984
  redirectedReference: redirectedReference,
123843
- perFileCache: resolvedTypeReferenceDirectives,
122985
+ cache: resolvedTypeReferenceDirectives,
122986
+ perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
123844
122987
  loader: resolveTypeReferenceDirective,
123845
122988
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
123846
- containingSourceFileMode: containingFileMode,
123847
- partialResolutionInfo: partialResolutionInfo,
122989
+ shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
122990
+ containingSourceFileMode: containingFileMode
123848
122991
  });
123849
122992
  }
123850
- function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
122993
+ function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
123851
122994
  return resolveNamesWithLocalCache({
123852
122995
  names: moduleNames,
123853
122996
  containingFile: containingFile,
123854
122997
  redirectedReference: redirectedReference,
123855
- perFileCache: resolvedModuleNames,
122998
+ cache: resolvedModuleNames,
122999
+ perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
123856
123000
  loader: resolveModuleName,
123857
123001
  getResolutionWithResolvedFileName: getResolvedModule,
123858
- partialResolutionInfo: partialResolutionInfo,
123002
+ shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
123003
+ reusedNames: reusedNames,
123859
123004
  logChanges: logChangesWhenResolvingModule,
123860
123005
  containingSourceFile: containingSourceFile,
123861
123006
  });
123862
123007
  }
123008
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
123009
+ var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
123010
+ if (!cache)
123011
+ return undefined;
123012
+ return cache.get(moduleName, resolutionMode);
123013
+ }
123863
123014
  function isNodeModulesAtTypesDirectory(dirPath) {
123864
123015
  return ts.endsWith(dirPath, "/node_modules/@types");
123865
123016
  }
@@ -123919,42 +123070,37 @@ var ts;
123919
123070
  function isPathWithDefaultFailedLookupExtension(path) {
123920
123071
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
123921
123072
  }
123922
- function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
123923
- if (resolution.files) {
123924
- resolution.files.add(filePath);
123925
- if (resolution.watchedFailed !== false)
123926
- watchFailedLookupLocationOfResolution(resolution);
123927
- watchAffectingLocationsOfResolution(resolution);
123928
- return;
123929
- }
123930
- resolution.files = new ts.Set();
123931
- resolution.files.add(filePath);
123932
- var resolved = getResolutionWithResolvedFileName(resolution);
123933
- if (resolved && resolved.resolvedFileName) {
123934
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
123935
- }
123936
- if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
123937
- watchFailedLookupLocationOfResolution(resolution);
123938
- watchAffectingLocationsOfResolution(resolution);
123073
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
123074
+ if (resolution.refCount) {
123075
+ resolution.refCount++;
123076
+ ts.Debug.assertIsDefined(resolution.files);
123939
123077
  }
123940
123078
  else {
123941
- resolution.watchedFailed = false;
123942
- watchAffectingLocationsOfResolution(resolution);
123079
+ resolution.refCount = 1;
123080
+ ts.Debug.assert(ts.length(resolution.files) === 0); // This resolution shouldnt be referenced by any file yet
123081
+ if (ts.isExternalModuleNameRelative(name)) {
123082
+ watchFailedLookupLocationOfResolution(resolution);
123083
+ }
123084
+ else {
123085
+ nonRelativeExternalModuleResolutions.add(name, resolution);
123086
+ }
123087
+ var resolved = getResolutionWithResolvedFileName(resolution);
123088
+ if (resolved && resolved.resolvedFileName) {
123089
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
123090
+ }
123943
123091
  }
123092
+ (resolution.files || (resolution.files = [])).push(filePath);
123944
123093
  }
123945
123094
  function watchFailedLookupLocationOfResolution(resolution) {
123946
- var failedLookupLocations = resolution.failedLookupLocations;
123947
- if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
123095
+ ts.Debug.assert(!!resolution.refCount);
123096
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
123097
+ if (!failedLookupLocations.length && !affectingLocations.length)
123948
123098
  return;
123949
- if (!resolution.watchedFailed) {
123099
+ if (failedLookupLocations.length)
123950
123100
  resolutionsWithFailedLookups.push(resolution);
123951
- // Remove resolution from only watching affected locations
123952
- if (resolution.watchedAffected)
123953
- ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
123954
- }
123955
- var setAtRoot = !!resolution.setAtRoot;
123956
- for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
123957
- var failedLookupLocation = failedLookupLocations[i];
123101
+ var setAtRoot = false;
123102
+ for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
123103
+ var failedLookupLocation = failedLookupLocations_1[_i];
123958
123104
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123959
123105
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
123960
123106
  if (toWatch) {
@@ -123974,24 +123120,24 @@ var ts;
123974
123120
  }
123975
123121
  }
123976
123122
  }
123977
- if (setAtRoot && !resolution.setAtRoot) {
123123
+ if (setAtRoot) {
123978
123124
  // This is always non recursive
123979
- setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true);
123125
+ setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
123980
123126
  }
123981
- resolution.setAtRoot = setAtRoot;
123982
- resolution.watchedFailed = failedLookupLocations.length;
123127
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
123983
123128
  }
123984
- function watchAffectingLocationsOfResolution(resolution) {
123129
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
123130
+ ts.Debug.assert(!!resolution.refCount);
123985
123131
  var affectingLocations = resolution.affectingLocations;
123986
- if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
123132
+ if (!affectingLocations.length)
123987
123133
  return;
123988
- if (!resolution.watchedFailed && !resolution.watchedAffected)
123134
+ if (addToResolutionsWithOnlyAffectingLocations)
123989
123135
  resolutionsWithOnlyAffectingLocations.push(resolution);
123990
123136
  // Watch package json
123991
- for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
123992
- createFileWatcherOfAffectingLocation(affectingLocations[i]);
123137
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
123138
+ var affectingLocation = affectingLocations_1[_i];
123139
+ createFileWatcherOfAffectingLocation(affectingLocation);
123993
123140
  }
123994
- resolution.watchedAffected = affectingLocations.length;
123995
123141
  }
123996
123142
  function createFileWatcherOfAffectingLocation(affectingLocation) {
123997
123143
  var path = resolutionHost.toPath(affectingLocation);
@@ -124032,6 +123178,15 @@ var ts;
124032
123178
  paths.add(path);
124033
123179
  }
124034
123180
  }
123181
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
123182
+ var program = resolutionHost.getCurrentProgram();
123183
+ if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
123184
+ resolutions.forEach(watchFailedLookupLocationOfResolution);
123185
+ }
123186
+ else {
123187
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
123188
+ }
123189
+ }
124035
123190
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
124036
123191
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
124037
123192
  if (dirWatcher) {
@@ -124042,28 +123197,21 @@ var ts;
124042
123197
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
124043
123198
  }
124044
123199
  }
124045
- function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
124046
- var _a, _b;
124047
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
124048
- if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
124049
- (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
124050
- }
124051
- function closeWatchersOfResolution(_a) {
124052
- var _b;
124053
- var resolution = _a.resolution, getResolved = _a.getResolved;
124054
- // If some files are using this resolution or we have already closed all watchers ignore
124055
- if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
123200
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
123201
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
123202
+ resolution.refCount--;
123203
+ if (resolution.refCount) {
124056
123204
  return;
124057
- resolution.files = undefined;
124058
- var resolved = getResolved(resolution);
123205
+ }
123206
+ var resolved = getResolutionWithResolvedFileName(resolution);
124059
123207
  if (resolved && resolved.resolvedFileName) {
124060
123208
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
124061
123209
  }
124062
- if (resolution.watchedFailed) {
124063
- ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
123210
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
123211
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
124064
123212
  var removeAtRoot = false;
124065
- for (var i = 0; i < resolution.watchedFailed; i++) {
124066
- var failedLookupLocation = resolution.failedLookupLocations[i];
123213
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
123214
+ var failedLookupLocation = failedLookupLocations_2[_i];
124067
123215
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
124068
123216
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
124069
123217
  if (toWatch) {
@@ -124086,31 +123234,23 @@ var ts;
124086
123234
  }
124087
123235
  }
124088
123236
  }
124089
- ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
124090
123237
  if (removeAtRoot) {
124091
123238
  removeDirectoryWatcher(rootPath);
124092
123239
  }
124093
123240
  }
124094
- else if (resolution.watchedAffected) {
123241
+ else if (affectingLocations.length) {
124095
123242
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
124096
123243
  }
124097
- if (resolution.watchedAffected) {
124098
- for (var i = 0; i < resolution.watchedAffected; i++) {
124099
- var affectingLocation = resolution.affectingLocations[i];
124100
- var path = resolutionHost.toPath(affectingLocation);
124101
- var watcher = fileWatchesOfAffectingLocations.get(path);
124102
- watcher.refCount--;
124103
- closeAffectingFileWatcher(watcher, path);
124104
- }
123244
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
123245
+ var affectingLocation = affectingLocations_2[_a];
123246
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
123247
+ watcher.refCount--;
124105
123248
  }
124106
123249
  }
124107
123250
  function removeDirectoryWatcher(dirPath) {
124108
123251
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
123252
+ // Do not close the watcher yet since it might be needed by other failed lookup locations.
124109
123253
  dirWatcher.refCount--;
124110
- if (dirWatcher.refCount === 0) {
124111
- directoryWatchesOfFailedLookups.delete(dirPath);
124112
- dirWatcher.watcher.close();
124113
- }
124114
123254
  }
124115
123255
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
124116
123256
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -124126,16 +123266,28 @@ var ts;
124126
123266
  // Deleted file, stop watching failed lookups for all the resolutions in the file
124127
123267
  var resolutions = cache.get(filePath);
124128
123268
  if (resolutions) {
124129
- resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
123269
+ resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
124130
123270
  cache.delete(filePath);
124131
123271
  }
124132
123272
  }
123273
+ function removeResolutionsFromProjectReferenceRedirects(filePath) {
123274
+ if (!ts.fileExtensionIs(filePath, ".json" /* Json */))
123275
+ return;
123276
+ var program = resolutionHost.getCurrentProgram();
123277
+ if (!program)
123278
+ return;
123279
+ // If this file is input file for the referenced project, get it
123280
+ var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
123281
+ if (!resolvedProjectReference)
123282
+ return;
123283
+ // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution
123284
+ resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
123285
+ }
124133
123286
  function removeResolutionsOfFile(filePath) {
124134
123287
  removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
124135
123288
  removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
124136
123289
  }
124137
123290
  function invalidateResolutions(resolutions, canInvalidate) {
124138
- var _a;
124139
123291
  if (!resolutions)
124140
123292
  return false;
124141
123293
  var invalidated = false;
@@ -124144,15 +123296,17 @@ var ts;
124144
123296
  if (resolution.isInvalidated || !canInvalidate(resolution))
124145
123297
  continue;
124146
123298
  resolution.isInvalidated = invalidated = true;
124147
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
123299
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
123300
+ var containingFilePath = _b[_a];
124148
123301
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
124149
123302
  // When its a file with inferred types resolution, invalidate type reference directive resolution
124150
123303
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
124151
- });
123304
+ }
124152
123305
  }
124153
123306
  return invalidated;
124154
123307
  }
124155
123308
  function invalidateResolutionOfFile(filePath) {
123309
+ removeResolutionsOfFile(filePath);
124156
123310
  // Resolution is invalidated if the resulting file name is same as the deleted file path
124157
123311
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
124158
123312
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
@@ -124162,28 +123316,8 @@ var ts;
124162
123316
  }
124163
123317
  }
124164
123318
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
124165
- filesMap.forEach(function (_a, filePath) {
124166
- var imports = _a.imports;
124167
- if (!imports.length)
124168
- return;
124169
- var resolvedModules = resolvedModuleNames.get(filePath);
124170
- var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
124171
- if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
124172
- return;
124173
- imports.forEach(function (_a) {
124174
- var name = _a.name, mode = _a.mode;
124175
- var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
124176
- if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
124177
- resolvedModule.isInvalidated = true;
124178
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
124179
- }
124180
- var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
124181
- if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
124182
- resolvedTypeRef.isInvalidated = true;
124183
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
124184
- }
124185
- });
124186
- });
123319
+ ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
123320
+ filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
124187
123321
  }
124188
123322
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
124189
123323
  if (isCreatingWatchedDirectory) {
@@ -124255,10 +123389,9 @@ var ts;
124255
123389
  });
124256
123390
  }
124257
123391
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
124258
- var _a;
124259
- return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) {
123392
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
124260
123393
  return affectingPathChecks.has(resolutionHost.toPath(location));
124261
- }));
123394
+ });
124262
123395
  }
124263
123396
  function closeTypeRootsWatch() {
124264
123397
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -124648,9 +123781,9 @@ var ts;
124648
123781
  if (!preferSymlinks) {
124649
123782
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
124650
123783
  // so we only need to remove them from the realpath filenames.
124651
- var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
124652
- if (result_17)
124653
- return result_17;
123784
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
123785
+ if (result_16)
123786
+ return result_16;
124654
123787
  }
124655
123788
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
124656
123789
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -124670,10 +123803,10 @@ var ts;
124670
123803
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
124671
123804
  var symlinkDirectory = symlinkDirectories_1[_i];
124672
123805
  var option = ts.resolvePath(symlinkDirectory, relative);
124673
- var result_18 = cb(option, target === referenceRedirect);
123806
+ var result_17 = cb(option, target === referenceRedirect);
124674
123807
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
124675
- if (result_18)
124676
- return result_18;
123808
+ if (result_17)
123809
+ return result_17;
124677
123810
  }
124678
123811
  });
124679
123812
  });
@@ -124739,9 +123872,9 @@ var ts;
124739
123872
  };
124740
123873
  var out_directory_1;
124741
123874
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
124742
- var state_12 = _loop_35(directory);
123875
+ var state_11 = _loop_35(directory);
124743
123876
  directory = out_directory_1;
124744
- if (state_12 === "break")
123877
+ if (state_11 === "break")
124745
123878
  break;
124746
123879
  }
124747
123880
  if (allFileNames.size) {
@@ -125710,8 +124843,7 @@ var ts;
125710
124843
  })(ts || (ts = {}));
125711
124844
  var ts;
125712
124845
  (function (ts) {
125713
- /*@internal*/
125714
- function readBuildInfoForProgram(compilerOptions, host) {
124846
+ function readBuilderProgram(compilerOptions, host) {
125715
124847
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
125716
124848
  if (!buildInfoPath)
125717
124849
  return undefined;
@@ -125732,12 +124864,7 @@ var ts;
125732
124864
  return undefined;
125733
124865
  if (!buildInfo.program)
125734
124866
  return undefined;
125735
- return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
125736
- }
125737
- ts.readBuildInfoForProgram = readBuildInfoForProgram;
125738
- function readBuilderProgram(compilerOptions, host) {
125739
- var result = readBuildInfoForProgram(compilerOptions, host);
125740
- return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
124867
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
125741
124868
  }
125742
124869
  ts.readBuilderProgram = readBuilderProgram;
125743
124870
  function createIncrementalCompilerHost(options, system) {
@@ -125876,7 +125003,7 @@ var ts;
125876
125003
  }
125877
125004
  return host.resolveModuleNames.apply(host, args);
125878
125005
  }) :
125879
- (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
125006
+ (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
125880
125007
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
125881
125008
  (function () {
125882
125009
  var args = [];
@@ -125885,13 +125012,7 @@ var ts;
125885
125012
  }
125886
125013
  return host.resolveTypeReferenceDirectives.apply(host, args);
125887
125014
  }) :
125888
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
125889
- compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
125890
- ts.maybeBind(host, host.getModuleResolutionCache) :
125891
- (function () { return resolutionCache.getModuleResolutionCache(); });
125892
- compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
125893
- ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
125894
- (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
125015
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
125895
125016
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
125896
125017
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
125897
125018
  synchronizeProgram();
@@ -125960,8 +125081,7 @@ var ts;
125960
125081
  }
125961
125082
  // All resolutions are invalid if user provided resolutions
125962
125083
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
125963
- var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
125964
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125084
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
125965
125085
  if (hasChangedConfigFileParsingErrors) {
125966
125086
  if (reportFileChangeDetectedOnCreateProgram) {
125967
125087
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -125980,11 +125100,6 @@ var ts;
125980
125100
  if (host.afterProgramCreate && program !== builderProgram) {
125981
125101
  host.afterProgramCreate(builderProgram);
125982
125102
  }
125983
- compilerHost.readFile = originalReadFile;
125984
- compilerHost.fileExists = originalFileExists;
125985
- compilerHost.directoryExists = originalDirectoryExists;
125986
- compilerHost.createDirectory = originalCreateDirectory;
125987
- compilerHost.writeFile = originalWriteFile;
125988
125103
  return builderProgram;
125989
125104
  }
125990
125105
  function createNewProgram(hasInvalidatedResolution) {
@@ -125994,16 +125109,19 @@ var ts;
125994
125109
  writeLog(" options: " + JSON.stringify(compilerOptions));
125995
125110
  if (projectReferences)
125996
125111
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
125112
+ var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
125997
125113
  hasChangedCompilerOptions = false;
125998
125114
  hasChangedConfigFileParsingErrors = false;
125999
125115
  resolutionCache.startCachingPerDirectoryResolution();
126000
125116
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126001
125117
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126002
- var oldProgram = getCurrentProgram();
126003
125118
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
126004
- resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
125119
+ resolutionCache.finishCachingPerDirectoryResolution();
126005
125120
  // Update watches
126006
125121
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
125122
+ if (needsUpdateInTypeRootWatch) {
125123
+ resolutionCache.updateTypeRootsWatch();
125124
+ }
126007
125125
  if (missingFilePathsRequestedForRelease) {
126008
125126
  // These are the paths that program creater told us as not in use any more but were missing on the disk.
126009
125127
  // We didnt remove the entry for them from sourceFiles cache so that we dont have to do File IO,
@@ -126080,6 +125198,9 @@ var ts;
126080
125198
  sourceFilesCache.set(path, false);
126081
125199
  }
126082
125200
  }
125201
+ if (sourceFile) {
125202
+ sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
125203
+ }
126083
125204
  return sourceFile;
126084
125205
  }
126085
125206
  return hostSourceFile.sourceFile;
@@ -126100,7 +125221,7 @@ var ts;
126100
125221
  var hostSourceFile = sourceFilesCache.get(path);
126101
125222
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
126102
125223
  }
126103
- function onReleaseOldSourceFile(oldSourceFile) {
125224
+ function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
126104
125225
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
126105
125226
  // If this is the source file thats in the cache and new program doesnt need it,
126106
125227
  // remove the cached entry.
@@ -126116,6 +125237,9 @@ var ts;
126116
125237
  hostSourceFileInfo.fileWatcher.close();
126117
125238
  }
126118
125239
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
125240
+ if (!hasSourceFileByPath) {
125241
+ resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
125242
+ }
126119
125243
  }
126120
125244
  }
126121
125245
  }
@@ -126372,6 +125496,7 @@ var ts;
126372
125496
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
126373
125497
  if (config)
126374
125498
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
125499
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
126375
125500
  }
126376
125501
  scheduleProgramUpdate();
126377
125502
  });
@@ -126385,6 +125510,7 @@ var ts;
126385
125510
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
126386
125511
  if (config)
126387
125512
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
125513
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
126388
125514
  scheduleProgramUpdate();
126389
125515
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
126390
125516
  // Watch Wild card
@@ -126590,23 +125716,20 @@ var ts;
126590
125716
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
126591
125717
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
126592
125718
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
126593
- compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
126594
- compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
126595
125719
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
126596
125720
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
126597
125721
  if (!compilerHost.resolveModuleNames) {
126598
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
126599
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
126600
- return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
125722
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
125723
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
125724
+ return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
126601
125725
  };
126602
125726
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
126603
125727
  }
126604
125728
  if (!compilerHost.resolveTypeReferenceDirectives) {
126605
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
125729
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
126606
125730
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
126607
- return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
125731
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
126608
125732
  };
126609
- compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
126610
125733
  }
126611
125734
  compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), /*modifiedTime*/ undefined); };
126612
125735
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -127594,7 +126717,7 @@ var ts;
127594
126717
  if (buildInfoTime && buildInfoTime < inputTime) {
127595
126718
  var version_3 = void 0;
127596
126719
  var currentVersion = void 0;
127597
- if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
126720
+ if (buildInfoProgram) {
127598
126721
  // Read files and see if they are same, read is anyways cached
127599
126722
  if (!buildInfoVersionMap)
127600
126723
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
@@ -134322,7 +133445,7 @@ var ts;
134322
133445
  // check for a version redirect
134323
133446
  var packageJsonPath = ts.findPackageJson(baseDirectory, host);
134324
133447
  if (packageJsonPath) {
134325
- var packageJson = ts.readJsonIgnoringErrors(packageJsonPath, host);
133448
+ var packageJson = ts.readJson(packageJsonPath, host);
134326
133449
  var typesVersions = packageJson.typesVersions;
134327
133450
  if (typeof typesVersions === "object") {
134328
133451
  var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths;
@@ -134501,7 +133624,7 @@ var ts;
134501
133624
  var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath);
134502
133625
  var packageFile = ts.combinePaths(packageDirectory, "package.json");
134503
133626
  if (ts.tryFileExists(host, packageFile)) {
134504
- var packageJson = ts.readJsonIgnoringErrors(packageFile, host);
133627
+ var packageJson = ts.readJson(packageFile, host);
134505
133628
  var exports_1 = packageJson.exports;
134506
133629
  if (exports_1) {
134507
133630
  if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null
@@ -134693,7 +133816,7 @@ var ts;
134693
133816
  var result = [];
134694
133817
  for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) {
134695
133818
  var packageJson = _a[_i];
134696
- var contents = ts.readJsonIgnoringErrors(packageJson, host); // Cast to assert that readFile is defined
133819
+ var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined
134697
133820
  // Provide completions for all non @types dependencies
134698
133821
  for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) {
134699
133822
  var key = nodeModulesDependencyKeys_1[_b];
@@ -138966,8 +138089,24 @@ var ts;
138966
138089
  };
138967
138090
  }
138968
138091
  ts.createDocumentRegistryInternal = createDocumentRegistryInternal;
138092
+ function compilerOptionValueToString(value) {
138093
+ var _a;
138094
+ if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null
138095
+ return "" + value;
138096
+ }
138097
+ if (ts.isArray(value)) {
138098
+ return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
138099
+ }
138100
+ var str = "{";
138101
+ for (var key in value) {
138102
+ if (ts.hasProperty(value, key)) {
138103
+ str += key + ": " + compilerOptionValueToString(value[key]);
138104
+ }
138105
+ }
138106
+ return str + "}";
138107
+ }
138969
138108
  function getKeyForCompilationSettings(settings) {
138970
- return ts.getKeyForCompilationSettings(settings, ts.sourceFileAffectingCompilerOptions);
138109
+ return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
138971
138110
  }
138972
138111
  })(ts || (ts = {}));
138973
138112
  /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
@@ -139280,22 +138419,21 @@ var ts;
139280
138419
  });
139281
138420
  }
139282
138421
  function findModuleReferences(program, sourceFiles, searchModuleSymbol) {
139283
- var _a;
139284
138422
  var refs = [];
139285
138423
  var checker = program.getTypeChecker();
139286
138424
  for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) {
139287
138425
  var referencingFile = sourceFiles_1[_i];
139288
138426
  var searchSourceFile = searchModuleSymbol.valueDeclaration;
139289
138427
  if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) {
139290
- for (var _b = 0, _c = referencingFile.referencedFiles; _b < _c.length; _b++) {
139291
- var ref = _c[_b];
138428
+ for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) {
138429
+ var ref = _b[_a];
139292
138430
  if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) {
139293
138431
  refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
139294
138432
  }
139295
138433
  }
139296
- for (var _d = 0, _e = referencingFile.typeReferenceDirectives; _d < _e.length; _d++) {
139297
- var ref = _e[_d];
139298
- var referenced = (_a = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
138434
+ for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
138435
+ var ref = _d[_c];
138436
+ var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
139299
138437
  if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
139300
138438
  refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
139301
138439
  }
@@ -140113,7 +139251,7 @@ var ts;
140113
139251
  (function (Core) {
140114
139252
  /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */
140115
139253
  function getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options, sourceFilesSet) {
140116
- var _a, _b, _c;
139254
+ var _a, _b;
140117
139255
  if (options === void 0) { options = {}; }
140118
139256
  if (sourceFilesSet === void 0) { sourceFilesSet = new ts.Set(sourceFiles.map(function (f) { return f.fileName; })); }
140119
139257
  node = getAdjustedNode(node, options);
@@ -140150,7 +139288,7 @@ var ts;
140150
139288
  if (!options.implementations && ts.isStringLiteralLike(node)) {
140151
139289
  if (ts.isModuleSpecifierLike(node)) {
140152
139290
  var fileIncludeReasons = program.getFileIncludeReasons();
140153
- var referencedFileName = (_c = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedModule) === null || _c === void 0 ? void 0 : _c.resolvedFileName;
139291
+ var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
140154
139292
  var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
140155
139293
  if (referencedFile) {
140156
139294
  return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }];
@@ -142344,7 +141482,7 @@ var ts;
142344
141482
  // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location.
142345
141483
  // TODO:GH#18217
142346
141484
  ? getSourceFileToImportFromResolved(importLiteral, ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, allFiles)
142347
- : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, oldToNew);
141485
+ : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
142348
141486
  // Need an update if the imported file moved, or the importing file moved and was using a relative path.
142349
141487
  return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
142350
141488
  ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
@@ -142362,8 +141500,7 @@ var ts;
142362
141500
  function combinePathsSafe(pathA, pathB) {
142363
141501
  return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB));
142364
141502
  }
142365
- function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, oldToNew) {
142366
- var _a;
141503
+ function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSourceFile, program, host, oldToNew) {
142367
141504
  if (importedModuleSymbol) {
142368
141505
  // `find` should succeed because we checked for ambient modules before calling this function.
142369
141506
  var oldFileName = ts.find(importedModuleSymbol.declarations, ts.isSourceFile).fileName;
@@ -142372,7 +141509,9 @@ var ts;
142372
141509
  }
142373
141510
  else {
142374
141511
  var mode = ts.getModeForUsageLocation(importingSourceFile, importLiteral);
142375
- var resolved = (_a = importingSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(importLiteral.text, mode);
141512
+ var resolved = host.resolveModuleNames
141513
+ ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode)
141514
+ : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
142376
141515
  return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
142377
141516
  }
142378
141517
  }
@@ -142444,7 +141583,7 @@ var ts;
142444
141583
  (function (GoToDefinition) {
142445
141584
  function getDefinitionAtPosition(program, sourceFile, position, searchOtherFilesOnly, stopAtAlias) {
142446
141585
  var _a;
142447
- var _b, _c;
141586
+ var _b;
142448
141587
  var resolvedRef = getReferenceAtPosition(sourceFile, position, program);
142449
141588
  var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray;
142450
141589
  if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) {
@@ -142467,7 +141606,7 @@ var ts;
142467
141606
  }
142468
141607
  if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
142469
141608
  var classDecl = node.parent.parent;
142470
- var _d = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _d.symbol, failedAliasResolution_1 = _d.failedAliasResolution;
141609
+ var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
142471
141610
  var staticBlocks = ts.filter(classDecl.members, ts.isClassStaticBlockDeclaration);
142472
141611
  var containerName_1 = symbol_1 ? typeChecker.symbolToString(symbol_1, classDecl) : "";
142473
141612
  var sourceFile_1 = node.getSourceFile();
@@ -142477,7 +141616,7 @@ var ts;
142477
141616
  return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length });
142478
141617
  });
142479
141618
  }
142480
- var _e = getSymbol(node, typeChecker, stopAtAlias), symbol = _e.symbol, failedAliasResolution = _e.failedAliasResolution;
141619
+ var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution;
142481
141620
  var fallbackNode = node;
142482
141621
  if (searchOtherFilesOnly && failedAliasResolution) {
142483
141622
  // We couldn't resolve the specific import, try on the module specifier.
@@ -142491,7 +141630,7 @@ var ts;
142491
141630
  if (!symbol && ts.isModuleSpecifierLike(fallbackNode)) {
142492
141631
  // We couldn't resolve the module specifier as an external module, but it could
142493
141632
  // be that module resolution succeeded but the target was not a module.
142494
- var ref = (_c = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode))) === null || _c === void 0 ? void 0 : _c.resolvedModule;
141633
+ var ref = (_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.get(fallbackNode.text, ts.getModeForUsageLocation(sourceFile, fallbackNode));
142495
141634
  if (ref) {
142496
141635
  return [{
142497
141636
  name: fallbackNode.text,
@@ -142612,7 +141751,7 @@ var ts;
142612
141751
  return getDefinitionFromSymbol(typeChecker, symbol, node);
142613
141752
  }
142614
141753
  function getReferenceAtPosition(sourceFile, position, program) {
142615
- var _a, _b, _c, _d;
141754
+ var _a, _b;
142616
141755
  var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position);
142617
141756
  if (referencePath) {
142618
141757
  var file = program.getSourceFileFromReference(sourceFile, referencePath);
@@ -142620,7 +141759,7 @@ var ts;
142620
141759
  }
142621
141760
  var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
142622
141761
  if (typeReferenceDirective) {
142623
- var reference = (_a = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
141762
+ var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat);
142624
141763
  var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217
142625
141764
  return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false };
142626
141765
  }
@@ -142629,10 +141768,10 @@ var ts;
142629
141768
  var file = program.getLibFileFromReference(libReferenceDirective);
142630
141769
  return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
142631
141770
  }
142632
- if ((_b = sourceFile.resolvedModules) === null || _b === void 0 ? void 0 : _b.size()) {
141771
+ if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
142633
141772
  var node = ts.getTouchingToken(sourceFile, position);
142634
141773
  if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
142635
- var verifiedFileName = (_d = (_c = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _c === void 0 ? void 0 : _c.resolvedModule) === null || _d === void 0 ? void 0 : _d.resolvedFileName;
141774
+ var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
142636
141775
  var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
142637
141776
  return {
142638
141777
  file: program.getSourceFile(fileName),
@@ -168057,25 +167196,6 @@ var ts;
168057
167196
  }
168058
167197
  return sourceFile;
168059
167198
  }
168060
- function getOldProgram(options, compilerHost) {
168061
- if (program)
168062
- return program;
168063
- if (!options.cacheResolutions)
168064
- return undefined;
168065
- var buildInfoResult = ts.readBuildInfoForProgram(options, compilerHost);
168066
- if (!(buildInfoResult === null || buildInfoResult === void 0 ? void 0 : buildInfoResult.buildInfo.program.cacheResolutions))
168067
- return undefined;
168068
- var buildInfoFilePathDecoder = ts.getProgramBuildInfoFilePathDecoder(buildInfoResult.buildInfo.program.fileNames, buildInfoResult.buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(compilerHost.useCaseSensitiveFileNames()));
168069
- var compilerOptions = buildInfoResult.buildInfo.program.options ?
168070
- ts.convertToOptionsWithAbsolutePaths(buildInfoResult.buildInfo.program.options, buildInfoFilePathDecoder.toAbsolutePath) :
168071
- {};
168072
- compilerOptions.configFilePath = options.configFilePath;
168073
- return function (host) { return ts.createOldBuildInfoProgram(host, compilerOptions,
168074
- /*cacheResolutions*/ undefined, {
168075
- cache: buildInfoResult.buildInfo.program.cacheResolutions,
168076
- getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
168077
- }); };
168078
- }
168079
167199
  function synchronizeHostData() {
168080
167200
  var _a, _b, _c;
168081
167201
  ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic);
@@ -168137,8 +167257,6 @@ var ts;
168137
167257
  trace: ts.maybeBind(host, host.trace),
168138
167258
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
168139
167259
  getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
168140
- getTypeReferenceDirectiveResolutionCache: ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache),
168141
- createHash: ts.maybeBind(host, host.createHash),
168142
167260
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
168143
167261
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
168144
167262
  getParsedCommandLine: getParsedCommandLine,
@@ -168179,13 +167297,14 @@ var ts;
168179
167297
  // the program points to old source files that have been invalidated because of
168180
167298
  // incremental parsing.
168181
167299
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168182
- program = ts.createProgram({
167300
+ var options = {
168183
167301
  rootNames: rootFileNames,
168184
167302
  options: newSettings,
168185
167303
  host: compilerHost,
168186
- oldProgram: getOldProgram(newSettings, compilerHost),
167304
+ oldProgram: program,
168187
167305
  projectReferences: projectReferences
168188
- });
167306
+ };
167307
+ program = ts.createProgram(options);
168189
167308
  // 'getOrCreateSourceFile' depends on caching but should be used past this point.
168190
167309
  // After this point, the cache needs to be cleared to allow all collected snapshots to be released
168191
167310
  compilerHost = undefined;
@@ -169286,7 +168405,6 @@ var ts;
169286
168405
  getEmitOutput: getEmitOutput,
169287
168406
  getNonBoundSourceFile: getNonBoundSourceFile,
169288
168407
  getProgram: getProgram,
169289
- getCurrentProgram: function () { return program; },
169290
168408
  getAutoImportProvider: getAutoImportProvider,
169291
168409
  updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
169292
168410
  getApplicableRefactors: getApplicableRefactors,
@@ -172219,6 +171337,8 @@ var ts;
172219
171337
  /*@internal*/
172220
171338
  /**
172221
171339
  * This is map from files to unresolved imports in it
171340
+ * Maop does not contain entries for files that do not have unresolved imports
171341
+ * This helps in containing the set of files to invalidate
172222
171342
  */
172223
171343
  this.cachedUnresolvedImportsPerFile = new ts.Map();
172224
171344
  /*@internal*/
@@ -172249,8 +171369,6 @@ var ts;
172249
171369
  /*@internal*/
172250
171370
  this.moduleSpecifierCache = server.createModuleSpecifierCache(this);
172251
171371
  /*@internal*/
172252
- this.createHash = ts.maybeBind(this.projectService.host, this.projectService.host.createHash);
172253
- /*@internal*/
172254
171372
  this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache;
172255
171373
  this.directoryStructureHost = directoryStructureHost;
172256
171374
  this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || "");
@@ -172381,7 +171499,7 @@ var ts;
172381
171499
  this.symlinks = ts.createSymlinkCache(this.getCurrentDirectory(), this.getCanonicalFileName);
172382
171500
  }
172383
171501
  if (this.program && !this.symlinks.hasProcessedResolutions()) {
172384
- this.symlinks.setSymlinksFromResolutions(this.program.getSourceFiles(), this.program.getAutomaticTypeDirectiveResolutions());
171502
+ this.symlinks.setSymlinksFromResolutions(this.program.getSourceFiles(), this.program.getResolvedTypeReferenceDirectives());
172385
171503
  }
172386
171504
  return this.symlinks;
172387
171505
  };
@@ -172472,18 +171590,17 @@ var ts;
172472
171590
  var path = this.toPath(file);
172473
171591
  return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
172474
171592
  };
172475
- Project.prototype.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
172476
- return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo);
171593
+ Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
171594
+ return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
172477
171595
  };
172478
171596
  Project.prototype.getModuleResolutionCache = function () {
172479
171597
  return this.resolutionCache.getModuleResolutionCache();
172480
171598
  };
172481
- /*@internal*/
172482
- Project.prototype.getTypeReferenceDirectiveResolutionCache = function () {
172483
- return this.resolutionCache.getTypeReferenceDirectiveResolutionCache();
171599
+ Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
171600
+ return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
172484
171601
  };
172485
- Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) {
172486
- return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo);
171602
+ Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
171603
+ return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode);
172487
171604
  };
172488
171605
  Project.prototype.directoryExists = function (path) {
172489
171606
  return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217
@@ -172617,8 +171734,8 @@ var ts;
172617
171734
  return [];
172618
171735
  }
172619
171736
  server.updateProjectIfDirty(this);
172620
- this.builderState = ts.BuilderState.create(this.program, this.builderState, /*disableUseFileVersionAsSignature*/ true);
172621
- return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, this.projectService.host), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
171737
+ this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true);
171738
+ return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash), this.getCanonicalFileName), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
172622
171739
  };
172623
171740
  /**
172624
171741
  * Returns true if emit was conducted
@@ -172662,7 +171779,6 @@ var ts;
172662
171779
  }
172663
171780
  ts.Debug.assert(this.projectService.serverMode !== ts.LanguageServiceMode.Syntactic);
172664
171781
  this.languageService.cleanupSemanticCache();
172665
- this.resolutionCache.clear();
172666
171782
  this.languageServiceEnabled = false;
172667
171783
  this.lastFileExceededProgramSize = lastFileExceededProgramSize;
172668
171784
  this.builderState = undefined;
@@ -172670,6 +171786,7 @@ var ts;
172670
171786
  this.autoImportProviderHost.close();
172671
171787
  }
172672
171788
  this.autoImportProviderHost = undefined;
171789
+ this.resolutionCache.closeTypeRootsWatch();
172673
171790
  this.clearGeneratedFileWatch();
172674
171791
  this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ false);
172675
171792
  };
@@ -172907,9 +172024,14 @@ var ts;
172907
172024
  if (this.isRoot(info)) {
172908
172025
  this.removeRoot(info);
172909
172026
  }
172910
- if (!fileExists) {
172027
+ if (fileExists) {
172028
+ // If file is present, just remove the resolutions for the file
172029
+ this.resolutionCache.removeResolutionsOfFile(info.path);
172030
+ }
172031
+ else {
172911
172032
  this.resolutionCache.invalidateResolutionOfFile(info.path);
172912
172033
  }
172034
+ this.cachedUnresolvedImportsPerFile.delete(info.path);
172913
172035
  if (detachFromProject) {
172914
172036
  info.detachFromProject(this);
172915
172037
  }
@@ -173037,7 +172159,7 @@ var ts;
173037
172159
  };
173038
172160
  Project.prototype.updateGraphWorker = function () {
173039
172161
  var _this = this;
173040
- var oldProgram = this.languageService.getCurrentProgram();
172162
+ var oldProgram = this.program;
173041
172163
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
173042
172164
  this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName());
173043
172165
  var start = ts.timestamp();
@@ -173046,14 +172168,14 @@ var ts;
173046
172168
  this.program = this.languageService.getProgram(); // TODO: GH#18217
173047
172169
  this.dirty = false;
173048
172170
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
173049
- this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram);
172171
+ this.resolutionCache.finishCachingPerDirectoryResolution();
173050
172172
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
173051
172173
  ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
173052
172174
  // bump up the version if
173053
172175
  // - oldProgram is not set - this is a first time updateGraph is called
173054
172176
  // - newProgram is different from the old program and structure of the old program was not reused.
173055
172177
  var hasNewProgram = false;
173056
- if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 3 /* Completely */))) {
172178
+ if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) {
173057
172179
  hasNewProgram = true;
173058
172180
  if (oldProgram) {
173059
172181
  for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) {
@@ -173061,7 +172183,8 @@ var ts;
173061
172183
  var newFile = this.program.getSourceFileByPath(f.resolvedPath);
173062
172184
  if (!newFile || (f.resolvedPath === f.path && newFile.resolvedPath !== f.path)) {
173063
172185
  // new program does not contain this file - detach it from the project
173064
- this.detachScriptInfoFromProject(f.fileName);
172186
+ // - remove resolutions only if the new program doesnt contain source file by the path (not resolvedPath since path is used for resolution)
172187
+ this.detachScriptInfoFromProject(f.fileName, !!this.program.getSourceFileByPath(f.path));
173065
172188
  }
173066
172189
  }
173067
172190
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
@@ -173100,6 +172223,10 @@ var ts;
173100
172223
  }
173101
172224
  }
173102
172225
  }
172226
+ // Watch the type locations that would be added to program as part of automatic type resolutions
172227
+ if (this.languageServiceEnabled && this.projectService.serverMode === ts.LanguageServiceMode.Semantic) {
172228
+ this.resolutionCache.updateTypeRootsWatch();
172229
+ }
173103
172230
  }
173104
172231
  if (this.exportMapCache && !this.exportMapCache.isEmpty()) {
173105
172232
  this.exportMapCache.releaseSymbols();
@@ -173151,9 +172278,14 @@ var ts;
173151
172278
  Project.prototype.sendPerformanceEvent = function (kind, durationMs) {
173152
172279
  this.projectService.sendPerformanceEvent(kind, durationMs);
173153
172280
  };
173154
- Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName) {
173155
- var _a;
173156
- (_a = this.projectService.getScriptInfo(uncheckedFileName)) === null || _a === void 0 ? void 0 : _a.detachFromProject(this);
172281
+ Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) {
172282
+ var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName);
172283
+ if (scriptInfoToDetach) {
172284
+ scriptInfoToDetach.detachFromProject(this);
172285
+ if (!noRemoveResolution) {
172286
+ this.resolutionCache.removeResolutionsOfFile(scriptInfoToDetach.path);
172287
+ }
172288
+ }
173157
172289
  };
173158
172290
  Project.prototype.addMissingFileWatcher = function (missingFilePath) {
173159
172291
  var _this = this;
@@ -173695,43 +172827,24 @@ var ts;
173695
172827
  var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
173696
172828
  return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
173697
172829
  }));
173698
- // Remove files from the cache if they arent in program
173699
- if (cachedUnresolvedImportsPerFile.size !== program.getSourceFiles().length) {
173700
- cachedUnresolvedImportsPerFile.forEach(function (_value, key) {
173701
- if (!program.getSourceFileByPath(key))
173702
- cachedUnresolvedImportsPerFile.delete(key);
173703
- });
173704
- }
173705
172830
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
173706
172831
  return result;
173707
172832
  }
173708
- var emptyUnresolvedImports = {
173709
- packages: server.emptyArray,
173710
- imports: server.emptyArray,
173711
- };
173712
172833
  function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
173713
- var _a;
173714
- var result = cachedUnresolvedImportsPerFile.get(file.path);
173715
- if (result)
173716
- return result.packages;
173717
- if (!((_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.size())) {
173718
- cachedUnresolvedImportsPerFile.set(file.path, emptyUnresolvedImports);
173719
- return server.emptyArray;
173720
- }
173721
- var packages;
173722
- var imports;
173723
- file.resolvedModules.forEach(function (_a, name, mode) {
173724
- var resolvedModule = _a.resolvedModule;
173725
- // pick unresolved non-relative names
173726
- if ((!resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) &&
173727
- !ts.isExternalModuleNameRelative(name) &&
173728
- !ambientModules.some(function (m) { return m === name; })) {
173729
- packages = ts.append(packages, ts.parsePackageName(name).packageName);
173730
- imports = ts.append(imports, { name: name, mode: mode });
173731
- }
172834
+ return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
172835
+ if (!file.resolvedModules)
172836
+ return server.emptyArray;
172837
+ var unresolvedImports;
172838
+ file.resolvedModules.forEach(function (resolvedModule, name) {
172839
+ // pick unresolved non-relative names
172840
+ if ((!resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) &&
172841
+ !ts.isExternalModuleNameRelative(name) &&
172842
+ !ambientModules.some(function (m) { return m === name; })) {
172843
+ unresolvedImports = ts.append(unresolvedImports, ts.parsePackageName(name).packageName);
172844
+ }
172845
+ });
172846
+ return unresolvedImports || server.emptyArray;
173732
172847
  });
173733
- cachedUnresolvedImportsPerFile.set(file.path, result = packages ? { packages: packages, imports: imports } : emptyUnresolvedImports);
173734
- return result.packages;
173735
172848
  }
173736
172849
  /**
173737
172850
  * If a file is opened and no tsconfig (or jsconfig) is found,
@@ -174040,11 +173153,6 @@ var ts;
174040
173153
  return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getModuleResolutionCache();
174041
173154
  };
174042
173155
  /*@internal*/
174043
- AutoImportProviderProject.prototype.getTypeReferenceDirectiveResolutionCache = function () {
174044
- var _a;
174045
- return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getTypeReferenceDirectiveResolutionCache();
174046
- };
174047
- /*@internal*/
174048
173156
  AutoImportProviderProject.maxDependencies = 10;
174049
173157
  /*@internal*/
174050
173158
  AutoImportProviderProject.compilerOptionsOverrides = {
@@ -175245,6 +174353,7 @@ var ts;
175245
174353
  }
175246
174354
  else {
175247
174355
  // Change in referenced project config file
174356
+ project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(_this.toPath(canonicalConfigFilePath));
175248
174357
  _this.delayUpdateProjectGraph(project);
175249
174358
  }
175250
174359
  });
@@ -179537,7 +178646,7 @@ var ts;
179537
178646
  definitions = definitions.filter(function (d) { return !d.isAmbient && !d.failedAliasResolution; });
179538
178647
  return this.mapDefinitionInfo(definitions, project);
179539
178648
  function findImplementationFileFromDtsFileName(fileName, resolveFromFile, auxiliaryProject) {
179540
- var _a, _b, _c;
178649
+ var _a;
179541
178650
  var nodeModulesPathParts = ts.getNodeModulePathParts(fileName);
179542
178651
  if (nodeModulesPathParts && fileName.lastIndexOf(ts.nodeModulesPathPart) === nodeModulesPathParts.topLevelNodeModulesIndex) {
179543
178652
  // Second check ensures the fileName only contains one `/node_modules/`. If there's more than one I give up.
@@ -179559,14 +178668,14 @@ var ts;
179559
178668
  // This file was the main entrypoint of a package. Try to resolve that same package name with
179560
178669
  // the auxiliary project that only resolves to implementation files.
179561
178670
  var implementationResolution = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile)[0];
179562
- return (_b = implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
178671
+ return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
179563
178672
  }
179564
178673
  else {
179565
178674
  // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package.
179566
178675
  var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
179567
178676
  var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage);
179568
178677
  var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0];
179569
- return (_c = implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedModule) === null || _c === void 0 ? void 0 : _c.resolvedFileName;
178678
+ return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName;
179570
178679
  }
179571
178680
  }
179572
178681
  // We're not in node_modules, and we only get to this function if non-dts module resolution failed.