@typescript-deploys/pr-build 4.9.0-pr-50293-2 → 4.9.0-pr-50294-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.
@@ -4731,13 +4731,15 @@ var ts;
4731
4731
  (function (FilePreprocessingDiagnosticsKind) {
4732
4732
  FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingReferencedDiagnostic"] = 0] = "FilePreprocessingReferencedDiagnostic";
4733
4733
  FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingFileExplainingDiagnostic"] = 1] = "FilePreprocessingFileExplainingDiagnostic";
4734
+ FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["ResolutionDiagnostics"] = 2] = "ResolutionDiagnostics";
4734
4735
  })(FilePreprocessingDiagnosticsKind = ts.FilePreprocessingDiagnosticsKind || (ts.FilePreprocessingDiagnosticsKind = {}));
4735
4736
  /* @internal */
4736
4737
  var StructureIsReused;
4737
4738
  (function (StructureIsReused) {
4738
4739
  StructureIsReused[StructureIsReused["Not"] = 0] = "Not";
4739
- StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules";
4740
- StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely";
4740
+ StructureIsReused[StructureIsReused["SafeModuleCache"] = 1] = "SafeModuleCache";
4741
+ StructureIsReused[StructureIsReused["SafeModules"] = 2] = "SafeModules";
4742
+ StructureIsReused[StructureIsReused["Completely"] = 3] = "Completely";
4741
4743
  })(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {}));
4742
4744
  /** Return code used by getEmitOutput function to indicate status of the function */
4743
4745
  var ExitStatus;
@@ -9493,6 +9495,8 @@ var ts;
9493
9495
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
9494
9496
  Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
9495
9497
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
9498
+ Directory_0_resolves_to_1_scope_according_to_cache: diag(6263, ts.DiagnosticCategory.Message, "Directory_0_resolves_to_1_scope_according_to_cache_6263", "Directory '{0}' resolves to '{1}' scope according to cache."),
9499
+ Directory_0_has_no_containing_package_json_scope_according_to_cache: diag(6264, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_according_to_cache_6264", "Directory '{0}' has no containing package.json scope according to cache."),
9496
9500
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
9497
9501
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
9498
9502
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, ts.DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -9677,6 +9681,7 @@ var ts;
9677
9681
  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."),
9678
9682
  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."),
9679
9683
  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."),
9684
+ 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."),
9680
9685
  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'."),
9681
9686
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
9682
9687
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -14418,7 +14423,8 @@ var ts;
14418
14423
  }
14419
14424
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
14420
14425
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
14421
- return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
14426
+ return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
14427
+ optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
14422
14428
  }
14423
14429
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
14424
14430
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -14496,21 +14502,20 @@ var ts;
14496
14502
  }
14497
14503
  ts.getFullWidth = getFullWidth;
14498
14504
  function getResolvedModule(sourceFile, moduleNameText, mode) {
14499
- return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
14505
+ var _a, _b;
14506
+ 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;
14500
14507
  }
14501
14508
  ts.getResolvedModule = getResolvedModule;
14502
14509
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
14503
- if (!sourceFile.resolvedModules) {
14504
- sourceFile.resolvedModules = ts.createModeAwareCache();
14505
- }
14510
+ var _a;
14511
+ (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
14506
14512
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
14507
14513
  }
14508
14514
  ts.setResolvedModule = setResolvedModule;
14509
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
14510
- if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
14511
- sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
14512
- }
14513
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
14515
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
14516
+ var _a;
14517
+ (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
14518
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
14514
14519
  }
14515
14520
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
14516
14521
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -14520,11 +14525,15 @@ var ts;
14520
14525
  }
14521
14526
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
14522
14527
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
14523
- return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
14524
- oldResolution.extension === newResolution.extension &&
14525
- oldResolution.resolvedFileName === newResolution.resolvedFileName &&
14526
- oldResolution.originalPath === newResolution.originalPath &&
14527
- packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
14528
+ return oldResolution === newResolution ||
14529
+ oldResolution.resolvedModule === newResolution.resolvedModule ||
14530
+ !!oldResolution.resolvedModule &&
14531
+ !!newResolution.resolvedModule &&
14532
+ oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
14533
+ oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
14534
+ oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
14535
+ oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
14536
+ packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
14528
14537
  }
14529
14538
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
14530
14539
  function packageIdIsEqual(a, b) {
@@ -14540,9 +14549,13 @@ var ts;
14540
14549
  }
14541
14550
  ts.packageIdToString = packageIdToString;
14542
14551
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
14543
- return oldResolution.resolvedFileName === newResolution.resolvedFileName
14544
- && oldResolution.primary === newResolution.primary
14545
- && oldResolution.originalPath === newResolution.originalPath;
14552
+ return oldResolution === newResolution ||
14553
+ oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
14554
+ !!oldResolution.resolvedTypeReferenceDirective &&
14555
+ !!newResolution.resolvedTypeReferenceDirective &&
14556
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
14557
+ !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
14558
+ oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
14546
14559
  }
14547
14560
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
14548
14561
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -19400,7 +19413,7 @@ var ts;
19400
19413
  }
19401
19414
  ts.base64decode = base64decode;
19402
19415
  function readJsonOrUndefined(path, hostOrText) {
19403
- var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
19416
+ var jsonText = ts.isString(hostOrText) || hostOrText === undefined ? hostOrText : hostOrText.readFile(path);
19404
19417
  if (!jsonText)
19405
19418
  return undefined;
19406
19419
  // gracefully handle if readFile fails or returns not JSON
@@ -19408,8 +19421,8 @@ var ts;
19408
19421
  return !result.error ? result.config : undefined;
19409
19422
  }
19410
19423
  ts.readJsonOrUndefined = readJsonOrUndefined;
19411
- function readJson(path, host) {
19412
- return readJsonOrUndefined(path, host) || {};
19424
+ function readJson(path, hostOrText) {
19425
+ return readJsonOrUndefined(path, hostOrText) || {};
19413
19426
  }
19414
19427
  ts.readJson = readJson;
19415
19428
  function directoryProbablyExists(directoryName, host) {
@@ -20493,14 +20506,15 @@ var ts;
20493
20506
  },
20494
20507
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
20495
20508
  var _this = this;
20496
- var _a;
20509
+ var _a, _b;
20497
20510
  ts.Debug.assert(!hasProcessedResolutions);
20498
20511
  hasProcessedResolutions = true;
20499
20512
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
20500
20513
  var file = files_1[_i];
20501
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
20514
+ (_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); });
20515
+ (_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); });
20502
20516
  }
20503
- typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
20517
+ typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
20504
20518
  },
20505
20519
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
20506
20520
  };
@@ -39774,6 +39788,17 @@ var ts;
39774
39788
  transpileOptionValue: undefined,
39775
39789
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
39776
39790
  },
39791
+ {
39792
+ name: "cacheResolutions",
39793
+ type: "boolean",
39794
+ category: ts.Diagnostics.Projects,
39795
+ description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
39796
+ affectsModuleResolution: true,
39797
+ affectsMultiFileEmitBuildInfo: true,
39798
+ affectsBundleEmitBuildInfo: true,
39799
+ transpileOptionValue: undefined,
39800
+ defaultValueDescription: false,
39801
+ },
39777
39802
  {
39778
39803
  name: "assumeChangesOnlyAffectDirectDependencies",
39779
39804
  type: "boolean",
@@ -41871,6 +41896,9 @@ var ts;
41871
41896
  if (result.configFilePath) {
41872
41897
  result.configFilePath = toAbsolutePath(result.configFilePath);
41873
41898
  }
41899
+ if (result.pathsBasePath) {
41900
+ result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
41901
+ }
41874
41902
  return result;
41875
41903
  }
41876
41904
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -42856,20 +42884,36 @@ var ts;
42856
42884
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
42857
42885
  return { fileName: resolved.path, packageId: resolved.packageId };
42858
42886
  }
42859
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42860
- var _a, _b;
42887
+ function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
42888
+ var _a;
42889
+ var _b;
42861
42890
  if (resultFromCache) {
42862
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42863
- (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
42891
+ if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
42892
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
42893
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
42894
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
42864
42895
  return resultFromCache;
42865
42896
  }
42866
42897
  return {
42867
42898
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
42868
- failedLookupLocations: failedLookupLocations,
42869
- affectingLocations: affectingLocations,
42870
- resolutionDiagnostics: diagnostics,
42899
+ failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
42900
+ affectingLocations: initializeResolutionField(affectingLocations),
42901
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
42871
42902
  };
42872
42903
  }
42904
+ function initializeResolutionField(value) {
42905
+ return value.length ? value : undefined;
42906
+ }
42907
+ /*@internal*/
42908
+ function updateResolutionField(to, value) {
42909
+ if (!(value === null || value === void 0 ? void 0 : value.length))
42910
+ return to;
42911
+ if (!(to === null || to === void 0 ? void 0 : to.length))
42912
+ return value;
42913
+ to.push.apply(to, value);
42914
+ return to;
42915
+ }
42916
+ ts.updateResolutionField = updateResolutionField;
42873
42917
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
42874
42918
  if (!ts.hasProperty(jsonContent, fieldName)) {
42875
42919
  if (state.traceEnabled) {
@@ -43021,8 +43065,7 @@ var ts;
43021
43065
  options = redirectedReference.commandLine.options;
43022
43066
  }
43023
43067
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
43024
- var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
43025
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
43068
+ var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, /*mode*/ resolutionMode, redirectedReference) : undefined;
43026
43069
  if (result) {
43027
43070
  if (traceEnabled) {
43028
43071
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -43080,7 +43123,7 @@ var ts;
43080
43123
  features: features,
43081
43124
  conditions: conditions,
43082
43125
  requestContainingDirectory: containingDirectory,
43083
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
43126
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
43084
43127
  };
43085
43128
  var resolved = primaryLookup();
43086
43129
  var primary = true;
@@ -43100,8 +43143,15 @@ var ts;
43100
43143
  isExternalLibraryImport: pathContainsNodeModules(fileName),
43101
43144
  };
43102
43145
  }
43103
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
43104
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
43146
+ result = {
43147
+ resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
43148
+ failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
43149
+ affectingLocations: initializeResolutionField(affectingLocations),
43150
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
43151
+ };
43152
+ if (containingDirectory && cache) {
43153
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
43154
+ }
43105
43155
  if (traceEnabled)
43106
43156
  traceResult(result);
43107
43157
  return result;
@@ -43111,10 +43161,10 @@ var ts;
43111
43161
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
43112
43162
  }
43113
43163
  else if (result.resolvedTypeReferenceDirective.packageId) {
43114
- 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);
43164
+ 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);
43115
43165
  }
43116
43166
  else {
43117
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
43167
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
43118
43168
  }
43119
43169
  }
43120
43170
  function primaryLookup() {
@@ -43231,63 +43281,186 @@ var ts;
43231
43281
  }
43232
43282
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
43233
43283
  /*@internal*/
43234
- function createCacheWithRedirects(options) {
43235
- var ownMap = new ts.Map();
43284
+ function getPackageJsconLocationFromScope(scope) {
43285
+ return ts.lastOrUndefined(scope.affectingLocations);
43286
+ }
43287
+ ts.getPackageJsconLocationFromScope = getPackageJsconLocationFromScope;
43288
+ function compilerOptionValueToString(value) {
43289
+ var _a;
43290
+ if (value === null || typeof value !== "object") { // eslint-disable-line no-null/no-null
43291
+ return "" + value;
43292
+ }
43293
+ if (ts.isArray(value)) {
43294
+ return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
43295
+ }
43296
+ var str = "{";
43297
+ for (var key in value) {
43298
+ if (ts.hasProperty(value, key)) {
43299
+ str += key + ": " + compilerOptionValueToString(value[key]);
43300
+ }
43301
+ }
43302
+ return str + "}";
43303
+ }
43304
+ /*@internal*/
43305
+ function getKeyForCompilationSettings(settings, options) {
43306
+ return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
43307
+ }
43308
+ ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
43309
+ /*@internal*/
43310
+ function getRedirectsCacheKey(options) {
43311
+ return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
43312
+ }
43313
+ ts.getRedirectsCacheKey = getRedirectsCacheKey;
43314
+ /*@internal*/
43315
+ function createCacheWithRedirects(ownOptions) {
43316
+ var ownMap;
43317
+ var ownKey;
43318
+ var redirectsKeyToCache = new ts.Map();
43236
43319
  var redirectsMap = new ts.Map();
43237
43320
  return {
43238
43321
  getOwnMap: getOwnMap,
43239
- redirectsMap: redirectsMap,
43322
+ redirectsKeyToCache: redirectsKeyToCache,
43323
+ createMapForCompilerOptions: createMapForCompilerOptions,
43324
+ getMapOfCacheRedirects: getMapOfCacheRedirects,
43240
43325
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
43241
43326
  clear: clear,
43242
- setOwnOptions: setOwnOptions,
43243
- setOwnMap: setOwnMap
43327
+ update: update,
43328
+ clearRedirectsMap: function () { return redirectsMap.clear(); },
43244
43329
  };
43245
- function getOwnMap() {
43246
- return ownMap;
43330
+ function ensureOwnKeyCached() {
43331
+ ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
43332
+ if (ownKey && !redirectsKeyToCache.has(ownKey))
43333
+ redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
43247
43334
  }
43248
- function setOwnOptions(newOptions) {
43249
- options = newOptions;
43335
+ function createMapForCompilerOptions(options, optionsKey) {
43336
+ if (options === ownOptions)
43337
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
43338
+ return getOrCreateRedirectMapAndKey(options, /*path*/ undefined, optionsKey);
43339
+ }
43340
+ function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
43341
+ var _a;
43342
+ if (path || options.configFile) {
43343
+ var redirects = redirectsMap.get(path || options.configFile.path);
43344
+ if (redirects)
43345
+ return redirects;
43346
+ }
43347
+ var key = optionsKey || getRedirectsCacheKey(options);
43348
+ var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
43349
+ if (!map) {
43350
+ ensureOwnKeyCached();
43351
+ if (ownKey === key) {
43352
+ map = ownMap;
43353
+ }
43354
+ else {
43355
+ redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
43356
+ }
43357
+ }
43358
+ if (path || options.configFile)
43359
+ redirectsMap.set(path || options.configFile.path, map);
43360
+ return map;
43250
43361
  }
43251
- function setOwnMap(newOwnMap) {
43252
- ownMap = newOwnMap;
43362
+ function getOwnMap() {
43363
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
43364
+ }
43365
+ function update(newOwnOptions) {
43366
+ // Store existing options:
43367
+ if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
43368
+ ensureOwnKeyCached();
43369
+ if (!redirectsMap.has(ownOptions.configFile.path)) {
43370
+ redirectsMap.set(ownOptions.configFile.path, ownMap);
43371
+ }
43372
+ }
43373
+ // If this is already present use it
43374
+ if (newOwnOptions.configFile) {
43375
+ var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
43376
+ if (existing_1) {
43377
+ ownMap = existing_1;
43378
+ ownOptions = newOwnOptions;
43379
+ return;
43380
+ }
43381
+ }
43382
+ var key = getRedirectsCacheKey(newOwnOptions);
43383
+ var existing = redirectsKeyToCache.get(key);
43384
+ ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
43385
+ ownKey = key;
43386
+ ownOptions = newOwnOptions;
43387
+ if (newOwnOptions.configFile)
43388
+ redirectsMap.set(newOwnOptions.configFile.path, ownMap);
43253
43389
  }
43254
- function getOrCreateMapOfCacheRedirects(redirectedReference) {
43255
- if (!redirectedReference) {
43390
+ function getMapOfCacheRedirects(redirectedReference) {
43391
+ if (!redirectedReference)
43392
+ return ownMap;
43393
+ var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
43394
+ if (directResult)
43395
+ return directResult;
43396
+ var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
43397
+ var fromKey = redirectsKeyToCache.get(key);
43398
+ if (fromKey) {
43399
+ redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
43400
+ return fromKey.map;
43401
+ }
43402
+ if (ownMap)
43403
+ ensureOwnKeyCached();
43404
+ if (ownKey === key) {
43405
+ redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
43256
43406
  return ownMap;
43257
43407
  }
43258
- var path = redirectedReference.sourceFile.path;
43259
- var redirects = redirectsMap.get(path);
43260
- if (!redirects) {
43261
- // Reuse map if redirected reference map uses same resolution
43262
- redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
43263
- redirectsMap.set(path, redirects);
43264
- }
43265
- return redirects;
43408
+ return undefined;
43409
+ }
43410
+ function getOrCreateMapOfCacheRedirects(redirectedReference) {
43411
+ return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
43412
+ getOwnMap() :
43413
+ getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, /*optionsKey*/ undefined);
43266
43414
  }
43267
43415
  function clear() {
43268
- ownMap.clear();
43416
+ ownKey = undefined;
43417
+ ownMap = undefined;
43269
43418
  redirectsMap.clear();
43419
+ redirectsKeyToCache.clear();
43270
43420
  }
43271
43421
  }
43272
43422
  ts.createCacheWithRedirects = createCacheWithRedirects;
43273
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
43274
- var cache;
43275
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
43423
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
43424
+ var dirToPackageJsonScope = new ts.Map();
43425
+ var oldPackageJsonInfoCache;
43426
+ return {
43427
+ getPackageJsonInfo: getPackageJsonInfo,
43428
+ setPackageJsonInfo: setPackageJsonInfo,
43429
+ clear: clear,
43430
+ entries: entries,
43431
+ getInternalMap: function () { return cache; },
43432
+ setInternalMap: function (value) { return cache = value; },
43433
+ clone: clone,
43434
+ getPackageJsonScope: getPackageJsonScope,
43435
+ setPackageJsonScope: setPackageJsonScope,
43436
+ setOldPackageJsonScopeCache: function (cache) { return oldPackageJsonInfoCache = cache; },
43437
+ };
43276
43438
  function getPackageJsonInfo(packageJsonPath) {
43277
- return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
43439
+ return cache === null || cache === void 0 ? void 0 : cache.get(toPath(packageJsonPath));
43278
43440
  }
43279
43441
  function setPackageJsonInfo(packageJsonPath, info) {
43280
- (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info);
43442
+ (cache || (cache = new ts.Map())).set(toPath(packageJsonPath), info);
43281
43443
  }
43282
43444
  function clear() {
43445
+ oldPackageJsonInfoCache = undefined;
43283
43446
  cache = undefined;
43447
+ dirToPackageJsonScope.clear();
43284
43448
  }
43285
43449
  function entries() {
43286
43450
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
43287
43451
  return iter ? ts.arrayFrom(iter) : [];
43288
43452
  }
43289
- function getInternalMap() {
43290
- return cache;
43453
+ function clone() {
43454
+ return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
43455
+ }
43456
+ function getPackageJsonScope(dir) {
43457
+ return dirToPackageJsonScope.get(dir) || (oldPackageJsonInfoCache === null || oldPackageJsonInfoCache === void 0 ? void 0 : oldPackageJsonInfoCache.getPackageJsonScope(dir));
43458
+ }
43459
+ function setPackageJsonScope(dir, scope) {
43460
+ moduleNameToDirectorySet(dirToPackageJsonScope, dir, scope, getPackageJsconLocationFromScope, toPath, ts.noop);
43461
+ }
43462
+ function toPath(file) {
43463
+ return ts.toPath(file, currentDirectory, getCanonicalFileName);
43291
43464
  }
43292
43465
  }
43293
43466
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
@@ -43299,47 +43472,44 @@ var ts;
43299
43472
  }
43300
43473
  return result;
43301
43474
  }
43302
- function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43303
- if (!options.configFile)
43304
- return;
43305
- if (directoryToModuleNameMap.redirectsMap.size === 0) {
43306
- // The own map will be for projectCompilerOptions
43307
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
43308
- ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
43309
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
43310
- directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
43311
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
43312
- }
43313
- else {
43314
- // Set correct own map
43315
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
43316
- var ref = {
43317
- sourceFile: options.configFile,
43318
- commandLine: { options: options }
43319
- };
43320
- directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
43321
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
43322
- }
43323
- directoryToModuleNameMap.setOwnOptions(options);
43324
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
43325
- }
43326
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
43475
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
43476
+ var directoryToModuleNameMap = createCacheWithRedirects(options);
43477
+ var oldResolutionCache;
43327
43478
  return {
43479
+ getFromCache: getFromCache,
43328
43480
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
43329
43481
  clear: clear,
43330
43482
  update: update,
43483
+ setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
43331
43484
  };
43332
43485
  function clear() {
43486
+ oldResolutionCache = undefined;
43333
43487
  directoryToModuleNameMap.clear();
43334
43488
  }
43335
43489
  function update(options) {
43336
- updateRedirectsMap(options, directoryToModuleNameMap);
43490
+ directoryToModuleNameMap.update(options);
43337
43491
  }
43338
43492
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
43339
43493
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
43340
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
43494
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
43495
+ }
43496
+ function getFromCache(directoryName, name, mode, redirectedReference) {
43497
+ var _a, _b;
43498
+ var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
43499
+ 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);
43500
+ if (result)
43501
+ return result;
43502
+ var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
43503
+ if (resultFromOld)
43504
+ getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
43505
+ return resultFromOld;
43341
43506
  }
43342
43507
  }
43508
+ /*@internal*/
43509
+ function getModeAwareCacheKey(specifier, mode) {
43510
+ return (mode === undefined ? specifier : mode + "|" + specifier);
43511
+ }
43512
+ ts.getModeAwareCacheKey = getModeAwareCacheKey;
43343
43513
  /* @internal */
43344
43514
  function createModeAwareCache() {
43345
43515
  var underlying = new ts.Map();
@@ -43365,13 +43535,22 @@ var ts;
43365
43535
  return cb(elem, specifier, mode);
43366
43536
  });
43367
43537
  },
43538
+ entries: function () {
43539
+ var keys = underlying.entries();
43540
+ return {
43541
+ next: function () {
43542
+ var next = keys.next();
43543
+ return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
43544
+ },
43545
+ };
43546
+ },
43368
43547
  size: function () {
43369
43548
  return underlying.size;
43370
- }
43549
+ },
43371
43550
  };
43372
43551
  return cache;
43373
43552
  function getUnderlyingCacheKey(specifier, mode) {
43374
- var result = mode === undefined ? specifier : mode + "|" + specifier;
43553
+ var result = getModeAwareCacheKey(specifier, mode);
43375
43554
  memoizedReverseKeys.set(result, [specifier, mode]);
43376
43555
  return result;
43377
43556
  }
@@ -43384,38 +43563,120 @@ var ts;
43384
43563
  for (var i = 0; i < keys.length; ++i) {
43385
43564
  var entry = keys[i];
43386
43565
  // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
43387
- var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
43566
+ var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
43388
43567
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
43389
43568
  map.set(name, mode, values[i]);
43390
43569
  }
43391
43570
  return map;
43392
43571
  }
43393
43572
  ts.zipToModeAwareCache = zipToModeAwareCache;
43394
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
43395
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43396
- moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
43573
+ function getCommonPrefix(directory, resolution, toPath) {
43574
+ var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
43575
+ // find first position where directory and resolution differs
43576
+ var i = 0;
43577
+ var limit = Math.min(directory.length, resolutionDirectory.length);
43578
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
43579
+ i++;
43580
+ }
43581
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
43582
+ return directory;
43583
+ }
43584
+ var rootLength = ts.getRootLength(directory);
43585
+ if (i < rootLength) {
43586
+ return undefined;
43587
+ }
43588
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
43589
+ if (sep === -1) {
43590
+ return undefined;
43591
+ }
43592
+ return directory.substr(0, Math.max(sep, rootLength));
43593
+ }
43594
+ /*@internal*/
43595
+ function getResolvedFileNameForModuleNameToDirectorySet(result) {
43596
+ return result.resolvedModule &&
43597
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
43598
+ }
43599
+ ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
43600
+ /**
43601
+ * At first this function add entry directory -> module resolution result to the table.
43602
+ * Then it computes the set of parent folders for 'directory' that should have the same module resolution result
43603
+ * and for every parent folder in set it adds entry: parent -> module resolution. .
43604
+ * Lets say we first directory name: /a/b/c/d/e and resolution result is: /a/b/bar.ts.
43605
+ * Set of parent folders that should have the same result will be:
43606
+ * [
43607
+ * /a/b/c/d, /a/b/c, /a/b
43608
+ * ]
43609
+ * this means that request for module resolution from file in any of these folder will be immediately found in cache.
43610
+ */
43611
+ /*@internal*/
43612
+ function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
43613
+ // if entry is already in cache do nothing
43614
+ if (directoryPathMap.has(directory))
43615
+ return;
43616
+ directoryPathMap.set(directory, result);
43617
+ var resolvedFileName = getResolvedFileName(result);
43618
+ // find common prefix between directory and resolved file name
43619
+ // this common prefix should be the shortest path that has the same resolution
43620
+ // directory: /a/b/c/d/e
43621
+ // resolvedFileName: /a/b/foo.d.ts
43622
+ // commonPrefix: /a/b
43623
+ // for failed lookups cache the result for every directory up to root
43624
+ var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
43625
+ var current = directory;
43626
+ while (current !== commonPrefix) {
43627
+ var parent = ts.getDirectoryPath(current);
43628
+ if (parent === current)
43629
+ break;
43630
+ if (directoryPathMap.has(parent)) {
43631
+ ancestoryWorker(parent);
43632
+ break;
43633
+ }
43634
+ directoryPathMap.set(parent, result);
43635
+ ancestoryWorker(parent);
43636
+ current = parent;
43637
+ }
43638
+ }
43639
+ ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
43640
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
43641
+ var moduleNameToDirectoryMap = createCacheWithRedirects(options);
43642
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
43397
43643
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
43398
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43644
+ var oldResolutionCache;
43645
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
43399
43646
  function clear() {
43400
- clearAllExceptPackageJsonInfoCache();
43401
- packageJsonInfoCache.clear();
43402
- }
43403
- function clearAllExceptPackageJsonInfoCache() {
43647
+ oldResolutionCache = undefined;
43404
43648
  perDirectoryResolutionCache.clear();
43405
43649
  moduleNameToDirectoryMap.clear();
43650
+ packageJsonInfoCache.clear();
43406
43651
  }
43407
43652
  function update(options) {
43408
- updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
43653
+ perDirectoryResolutionCache.update(options);
43654
+ moduleNameToDirectoryMap.update(options);
43655
+ }
43656
+ function setOldResolutionCache(cache) {
43657
+ oldResolutionCache = cache;
43658
+ perDirectoryResolutionCache.setOldResolutionCache(cache);
43659
+ }
43660
+ function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
43661
+ var _a, _b;
43662
+ ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
43663
+ 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);
43664
+ if (result)
43665
+ return result;
43666
+ var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
43667
+ if (fromOld)
43668
+ getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
43669
+ return fromOld;
43409
43670
  }
43410
43671
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
43411
43672
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
43412
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
43673
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
43413
43674
  }
43414
43675
  function createPerModuleNameCache() {
43415
43676
  var directoryPathMap = new ts.Map();
43416
43677
  return { get: get, set: set };
43417
43678
  function get(directory) {
43418
- return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
43679
+ return directoryPathMap.get(toPath(directory));
43419
43680
  }
43420
43681
  /**
43421
43682
  * At first this function add entry directory -> module resolution result to the table.
@@ -43429,74 +43690,27 @@ var ts;
43429
43690
  * this means that request for module resolution from file in any of these folder will be immediately found in cache.
43430
43691
  */
43431
43692
  function set(directory, result) {
43432
- var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
43433
- // if entry is already in cache do nothing
43434
- if (directoryPathMap.has(path)) {
43435
- return;
43436
- }
43437
- directoryPathMap.set(path, result);
43438
- var resolvedFileName = result.resolvedModule &&
43439
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
43440
- // find common prefix between directory and resolved file name
43441
- // this common prefix should be the shortest path that has the same resolution
43442
- // directory: /a/b/c/d/e
43443
- // resolvedFileName: /a/b/foo.d.ts
43444
- // commonPrefix: /a/b
43445
- // for failed lookups cache the result for every directory up to root
43446
- var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
43447
- var current = path;
43448
- while (current !== commonPrefix) {
43449
- var parent = ts.getDirectoryPath(current);
43450
- if (parent === current || directoryPathMap.has(parent)) {
43451
- break;
43452
- }
43453
- directoryPathMap.set(parent, result);
43454
- current = parent;
43455
- }
43456
- }
43457
- function getCommonPrefix(directory, resolution) {
43458
- var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
43459
- // find first position where directory and resolution differs
43460
- var i = 0;
43461
- var limit = Math.min(directory.length, resolutionDirectory.length);
43462
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
43463
- i++;
43464
- }
43465
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
43466
- return directory;
43467
- }
43468
- var rootLength = ts.getRootLength(directory);
43469
- if (i < rootLength) {
43470
- return undefined;
43471
- }
43472
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
43473
- if (sep === -1) {
43474
- return undefined;
43475
- }
43476
- return directory.substr(0, Math.max(sep, rootLength));
43693
+ return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
43477
43694
  }
43478
43695
  }
43696
+ function toPath(fileName) {
43697
+ return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
43698
+ }
43479
43699
  }
43480
43700
  ts.createModuleResolutionCache = createModuleResolutionCache;
43481
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
43482
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
43701
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
43702
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
43483
43703
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
43484
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
43704
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear });
43485
43705
  function clear() {
43486
- clearAllExceptPackageJsonInfoCache();
43487
- packageJsonInfoCache.clear();
43488
- }
43489
- function clearAllExceptPackageJsonInfoCache() {
43490
43706
  perDirectoryResolutionCache.clear();
43707
+ packageJsonInfoCache.clear();
43491
43708
  }
43492
43709
  }
43493
43710
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
43494
43711
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
43495
43712
  var containingDirectory = ts.getDirectoryPath(containingFile);
43496
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
43497
- if (!perFolderCache)
43498
- return undefined;
43499
- return perFolderCache.get(moduleName, mode);
43713
+ return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
43500
43714
  }
43501
43715
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
43502
43716
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -43511,8 +43725,7 @@ var ts;
43511
43725
  }
43512
43726
  }
43513
43727
  var containingDirectory = ts.getDirectoryPath(containingFile);
43514
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
43515
- var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
43728
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
43516
43729
  if (result) {
43517
43730
  if (traceEnabled) {
43518
43731
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -43564,8 +43777,8 @@ var ts;
43564
43777
  if (result && result.resolvedModule)
43565
43778
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
43566
43779
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
43567
- if (perFolderCache) {
43568
- perFolderCache.set(moduleName, resolutionMode, result);
43780
+ if (cache) {
43781
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
43569
43782
  if (!ts.isExternalModuleNameRelative(moduleName)) {
43570
43783
  // put result in per-module name cache
43571
43784
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
@@ -43851,10 +44064,10 @@ var ts;
43851
44064
  features: features,
43852
44065
  conditions: conditions,
43853
44066
  requestContainingDirectory: containingDirectory,
43854
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
44067
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
43855
44068
  };
43856
44069
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
43857
- 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);
44070
+ 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);
43858
44071
  function tryResolve(extensions) {
43859
44072
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
43860
44073
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -44231,25 +44444,47 @@ var ts;
44231
44444
  features: NodeResolutionFeatures.None,
44232
44445
  conditions: ts.emptyArray,
44233
44446
  requestContainingDirectory: undefined,
44234
- reportDiagnostic: ts.noop
44447
+ reportResolutionDiagnostic: ts.noop
44235
44448
  };
44236
44449
  }
44237
44450
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
44451
+ /*@internal*/
44452
+ function getPackageScope(dir, packageJsonInfoCache, host, options) {
44453
+ var state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
44454
+ var failedLookupLocations = [];
44455
+ var affectingLocations = [];
44456
+ state.failedLookupLocations = failedLookupLocations;
44457
+ state.affectingLocations = affectingLocations;
44458
+ var result = ts.forEachAncestorDirectory(dir, function (directory) {
44459
+ var _a;
44460
+ var fromCache = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonScope(directory);
44461
+ if (fromCache) {
44462
+ var host_2 = state.host, traceEnabled = state.traceEnabled;
44463
+ if (traceEnabled) {
44464
+ trace(host_2, fromCache.info ?
44465
+ ts.Diagnostics.Directory_0_resolves_to_1_scope_according_to_cache :
44466
+ ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_according_to_cache, directory, getPackageJsconLocationFromScope(fromCache));
44467
+ }
44468
+ return fromCache;
44469
+ }
44470
+ var info = getPackageJsonInfo(directory, /*onlyRecordFailures*/ false, state);
44471
+ if (info)
44472
+ return { info: info };
44473
+ }) || { info: undefined };
44474
+ result.failedLookupLocations = updateResolutionField(result.failedLookupLocations, !options.cacheResolutions || !result.info ? failedLookupLocations : undefined);
44475
+ result.affectingLocations = updateResolutionField(result.affectingLocations, affectingLocations);
44476
+ packageJsonInfoCache === null || packageJsonInfoCache === void 0 ? void 0 : packageJsonInfoCache.setPackageJsonScope(dir, result);
44477
+ return result;
44478
+ }
44479
+ ts.getPackageScope = getPackageScope;
44238
44480
  /**
44239
- * A function for locating the package.json scope for a given path
44481
+ * A function for locating the package.json scope in given directory path
44240
44482
  */
44241
44483
  /*@internal*/
44242
- function getPackageScopeForPath(fileName, state) {
44243
- var parts = ts.getPathComponents(fileName);
44244
- parts.pop();
44245
- while (parts.length > 0) {
44246
- var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
44247
- if (pkg) {
44248
- return pkg;
44249
- }
44250
- parts.pop();
44251
- }
44252
- return undefined;
44484
+ function getPackageScopeForPath(dir, state) {
44485
+ return ts.forEachAncestorDirectory(dir, function (directory) {
44486
+ return getPackageJsonInfo(directory, /*onlyRecordFailures*/ false, state);
44487
+ });
44253
44488
  }
44254
44489
  ts.getPackageScopeForPath = getPackageScopeForPath;
44255
44490
  /*@internal*/
@@ -44278,12 +44513,13 @@ var ts;
44278
44513
  }
44279
44514
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
44280
44515
  if (directoryExists && host.fileExists(packageJsonPath)) {
44281
- var packageJsonContent = ts.readJson(packageJsonPath, host);
44516
+ var packageJsonText = host.readFile(packageJsonPath);
44517
+ var packageJsonContent = ts.readJson(packageJsonPath, packageJsonText);
44282
44518
  if (traceEnabled) {
44283
44519
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
44284
44520
  }
44285
44521
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
44286
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
44522
+ var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
44287
44523
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
44288
44524
  state.affectingLocations.push(packageJsonPath);
44289
44525
  return result;
@@ -44409,7 +44645,7 @@ var ts;
44409
44645
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
44410
44646
  var _a, _b;
44411
44647
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44412
- var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44648
+ var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44413
44649
  var scope = getPackageScopeForPath(directoryPath, state);
44414
44650
  if (!scope || !scope.packageJsonContent.exports) {
44415
44651
  return undefined;
@@ -44468,7 +44704,7 @@ var ts;
44468
44704
  return toSearchResult(/*value*/ undefined);
44469
44705
  }
44470
44706
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44471
- var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44707
+ var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44472
44708
  var scope = getPackageScopeForPath(directoryPath, state);
44473
44709
  if (!scope) {
44474
44710
  if (state.traceEnabled) {
@@ -44708,12 +44944,8 @@ var ts;
44708
44944
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
44709
44945
  }
44710
44946
  }
44711
- if (commonSourceDirGuesses.length > 1) {
44712
- state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
44713
- ? 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
44714
- : 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
44715
- packagePath));
44716
- }
44947
+ if (commonSourceDirGuesses.length > 1)
44948
+ state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
44717
44949
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
44718
44950
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
44719
44951
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -44783,10 +45015,10 @@ var ts;
44783
45015
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
44784
45016
  }
44785
45017
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
44786
- var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
45018
+ var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
44787
45019
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
44788
45020
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
44789
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
45021
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
44790
45022
  if (resolutionFromCache) {
44791
45023
  return resolutionFromCache;
44792
45024
  }
@@ -44938,8 +45170,8 @@ var ts;
44938
45170
  typesPackageName;
44939
45171
  }
44940
45172
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
44941
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
44942
- var result = cache && cache.get(containingDirectory);
45173
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
45174
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
44943
45175
  if (result) {
44944
45176
  if (state.traceEnabled) {
44945
45177
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -44964,11 +45196,11 @@ var ts;
44964
45196
  features: NodeResolutionFeatures.None,
44965
45197
  conditions: [],
44966
45198
  requestContainingDirectory: containingDirectory,
44967
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
45199
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
44968
45200
  };
44969
45201
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
44970
45202
  // No originalPath because classic resolution doesn't resolve realPath
44971
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value,
45203
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value,
44972
45204
  /*isExternalLibraryImport*/ false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
44973
45205
  function tryResolve(extensions) {
44974
45206
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
@@ -44976,10 +45208,9 @@ var ts;
44976
45208
  return { value: resolvedUsingSettings };
44977
45209
  }
44978
45210
  if (!ts.isExternalModuleNameRelative(moduleName)) {
44979
- var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
44980
45211
  // Climb up parent directories looking for a module.
44981
45212
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
44982
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
45213
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, /*mode*/ undefined, directory, redirectedReference, state);
44983
45214
  if (resolutionFromCache) {
44984
45215
  return resolutionFromCache;
44985
45216
  }
@@ -45024,10 +45255,10 @@ var ts;
45024
45255
  features: NodeResolutionFeatures.None,
45025
45256
  conditions: [],
45026
45257
  requestContainingDirectory: undefined,
45027
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
45258
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
45028
45259
  };
45029
45260
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
45030
- return createResolvedModuleWithFailedLookupLocations(resolved,
45261
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved,
45031
45262
  /*isExternalLibraryImport*/ true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
45032
45263
  }
45033
45264
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
@@ -48734,9 +48965,10 @@ var ts;
48734
48965
  host.getSourceFiles().forEach(function (sf) {
48735
48966
  if (!sf.resolvedModules)
48736
48967
  return;
48737
- sf.resolvedModules.forEach(function (r) {
48738
- if (r && r.packageId)
48739
- map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
48968
+ sf.resolvedModules.forEach(function (_a) {
48969
+ var resolvedModule = _a.resolvedModule;
48970
+ if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
48971
+ map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" /* Dts */ || !!map.get(resolvedModule.packageId.name));
48740
48972
  });
48741
48973
  });
48742
48974
  return map;
@@ -51691,7 +51923,7 @@ var ts;
51691
51923
  : undefined;
51692
51924
  }
51693
51925
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
51694
- var _a, _b, _c, _d, _e, _f, _g, _h;
51926
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
51695
51927
  if (isForAugmentation === void 0) { isForAugmentation = false; }
51696
51928
  if (ts.startsWith(moduleReference, "@types/")) {
51697
51929
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -51742,7 +51974,7 @@ var ts;
51742
51974
  var diagnosticDetails = void 0;
51743
51975
  var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
51744
51976
  if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
51745
- var scope = currentSourceFile.packageJsonScope;
51977
+ var scope = (_h = currentSourceFile.packageJsonScope) === null || _h === void 0 ? void 0 : _h.info;
51746
51978
  var targetExt = ext === ".ts" /* Ts */ ? ".mts" /* Mts */ : ext === ".js" /* Js */ ? ".mjs" /* Mjs */ : undefined;
51747
51979
  if (scope && !scope.packageJsonContent.type) {
51748
51980
  if (targetExt) {
@@ -51843,10 +52075,10 @@ var ts;
51843
52075
  }
51844
52076
  else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
51845
52077
  var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
51846
- var suggestedExt = (_h = suggestedExtensions.find(function (_a) {
52078
+ var suggestedExt = (_j = suggestedExtensions.find(function (_a) {
51847
52079
  var actualExt = _a[0], _importExt = _a[1];
51848
52080
  return host.fileExists(absoluteRef_1 + actualExt);
51849
- })) === null || _h === void 0 ? void 0 : _h[1];
52081
+ })) === null || _j === void 0 ? void 0 : _j[1];
51850
52082
  if (suggestedExt) {
51851
52083
  error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
51852
52084
  }
@@ -86871,9 +87103,9 @@ var ts;
86871
87103
  var paramTag = node.parent.parent;
86872
87104
  if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
86873
87105
  // Else we will add a diagnostic, see `checkJSDocVariadicType`.
86874
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
87106
+ var host_3 = ts.getHostSignatureFromJSDoc(paramTag);
86875
87107
  var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent);
86876
- if (host_2 || isCallbackTag) {
87108
+ if (host_3 || isCallbackTag) {
86877
87109
  /*
86878
87110
  Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters.
86879
87111
  So in the following situation we will not create an array type:
@@ -86883,7 +87115,7 @@ var ts;
86883
87115
  */
86884
87116
  var lastParamDeclaration = isCallbackTag
86885
87117
  ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters)
86886
- : ts.lastOrUndefined(host_2.parameters);
87118
+ : ts.lastOrUndefined(host_3.parameters);
86887
87119
  var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
86888
87120
  if (!lastParamDeclaration ||
86889
87121
  symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -88308,11 +88540,12 @@ var ts;
88308
88540
  if (resolvedTypeReferenceDirectives) {
88309
88541
  // populate reverse mapping: file path -> type reference directive that was resolved to this file
88310
88542
  fileToDirective = new ts.Map();
88311
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
88312
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
88543
+ resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
88544
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
88545
+ if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
88313
88546
  return;
88314
88547
  }
88315
- var file = host.getSourceFile(resolvedDirective.resolvedFileName);
88548
+ var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
88316
88549
  if (file) {
88317
88550
  // Add the transitive closure of path references loaded by this file (as long as they are not)
88318
88551
  // part of an existing type reference.
@@ -89668,9 +89901,9 @@ var ts;
89668
89901
  }
89669
89902
  var parent = ts.walkUpParenthesizedTypes(node.parent);
89670
89903
  if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
89671
- var host_3 = ts.getJSDocHost(parent);
89672
- if (host_3) {
89673
- parent = ts.getSingleVariableOfVariableStatement(host_3) || host_3;
89904
+ var host_4 = ts.getJSDocHost(parent);
89905
+ if (host_4) {
89906
+ parent = ts.getSingleVariableOfVariableStatement(host_4) || host_4;
89674
89907
  }
89675
89908
  }
89676
89909
  switch (parent.kind) {
@@ -111840,7 +112073,7 @@ var ts;
111840
112073
  var sourceMap = sourceMapGenerator.toString();
111841
112074
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111842
112075
  if (printer.bundleFileInfo)
111843
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
112076
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
111844
112077
  }
111845
112078
  }
111846
112079
  else {
@@ -111852,7 +112085,7 @@ var ts;
111852
112085
  // 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
111853
112086
  // 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
111854
112087
  if (printer.bundleFileInfo)
111855
- printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
112088
+ printer.bundleFileInfo.hash = ts.computeSignature(text, host);
111856
112089
  // Reset state
111857
112090
  writer.clear();
111858
112091
  }
@@ -112005,7 +112238,6 @@ var ts;
112005
112238
  }
112006
112239
  ts.emitUsingBuildInfo = emitUsingBuildInfo;
112007
112240
  function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransformers) {
112008
- var createHash = ts.maybeBind(host, host.createHash);
112009
112241
  var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
112010
112242
  // If host directly provides buildinfo we can get it directly. This allows host to cache the buildinfo
112011
112243
  var buildInfo = host.getBuildInfo(buildInfoPath, config.options);
@@ -112017,25 +112249,25 @@ var ts;
112017
112249
  if (!jsFileText)
112018
112250
  return jsFilePath;
112019
112251
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
112020
- if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
112252
+ if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
112021
112253
  return jsFilePath;
112022
112254
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
112023
112255
  // error if no source map or for now if inline sourcemap
112024
112256
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
112025
112257
  return sourceMapFilePath || "inline sourcemap decoding";
112026
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
112258
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
112027
112259
  return sourceMapFilePath;
112028
112260
  // read declaration text
112029
112261
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
112030
112262
  if (declarationFilePath && !declarationText)
112031
112263
  return declarationFilePath;
112032
- if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
112264
+ if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
112033
112265
  return declarationFilePath;
112034
112266
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
112035
112267
  // error if no source map or for now if inline sourcemap
112036
112268
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
112037
112269
  return declarationMapPath || "inline sourcemap decoding";
112038
- if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
112270
+ if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
112039
112271
  return declarationMapPath;
112040
112272
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
112041
112273
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -112075,7 +112307,7 @@ var ts;
112075
112307
  newBuildInfo.program = buildInfo.program;
112076
112308
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
112077
112309
  // Update the output signature
112078
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
112310
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
112079
112311
  }
112080
112312
  // Update sourceFileInfo
112081
112313
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
@@ -112110,7 +112342,7 @@ var ts;
112110
112342
  getSourceFileFromReference: ts.returnUndefined,
112111
112343
  redirectTargetsMap: ts.createMultiMap(),
112112
112344
  getFileIncludeReasons: ts.notImplemented,
112113
- createHash: createHash,
112345
+ createHash: ts.maybeBind(host, host.createHash),
112114
112346
  buildInfoCallbacks: host.buildInfoCallbacks,
112115
112347
  };
112116
112348
  emitFiles(ts.notImplementedResolver, emitHost,
@@ -117614,7 +117846,7 @@ var ts;
117614
117846
  var result = void 0;
117615
117847
  var mode = getModeForFileReference(name, containingFileMode);
117616
117848
  // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
117617
- var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
117849
+ var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
117618
117850
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
117619
117851
  if (cache.has(cacheKey)) {
117620
117852
  result = cache.get(cacheKey);
@@ -117718,8 +117950,22 @@ var ts;
117718
117950
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117719
117951
  }
117720
117952
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
117953
+ var emptyResolution = {
117954
+ resolvedModule: undefined,
117955
+ resolvedTypeReferenceDirective: undefined,
117956
+ failedLookupLocations: [],
117957
+ affectingLocations: [],
117958
+ resolutionDiagnostics: [],
117959
+ };
117960
+ function isResolvedModuleWithFailedLookupLocation(resolved) {
117961
+ return !!resolved && !!resolved.failedLookupLocations;
117962
+ }
117963
+ function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
117964
+ return !!resolved && !!resolved.failedLookupLocations;
117965
+ }
117721
117966
  /* @internal */
117722
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
117967
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
117968
+ var _a;
117723
117969
  if (names.length === 0) {
117724
117970
  return [];
117725
117971
  }
@@ -117729,7 +117975,7 @@ var ts;
117729
117975
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
117730
117976
  var name = names_3[_i];
117731
117977
  var result = void 0;
117732
- var mode = getModeForResolutionAtIndex(containingFile, i);
117978
+ var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
117733
117979
  i++;
117734
117980
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
117735
117981
  if (cache.has(cacheKey)) {
@@ -117794,14 +118040,14 @@ var ts;
117794
118040
  /*@internal*/
117795
118041
  function getReferencedFileLocation(getSourceFileByPath, ref) {
117796
118042
  var _a, _b, _c;
117797
- var _d, _e, _f, _g;
118043
+ var _d, _e, _f, _g, _h, _j;
117798
118044
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
117799
118045
  var kind = ref.kind, index = ref.index;
117800
118046
  var pos, end, packageId, resolutionMode;
117801
118047
  switch (kind) {
117802
118048
  case ts.FileIncludeKind.Import:
117803
118049
  var importLiteral = getModuleNameStringLiteralAt(file, index);
117804
- 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;
118050
+ 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;
117805
118051
  if (importLiteral.pos === -1)
117806
118052
  return { file: file, packageId: packageId, text: importLiteral.text };
117807
118053
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -117812,7 +118058,7 @@ var ts;
117812
118058
  break;
117813
118059
  case ts.FileIncludeKind.TypeReferenceDirective:
117814
118060
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
117815
- 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;
118061
+ 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;
117816
118062
  break;
117817
118063
  case ts.FileIncludeKind.LibReferenceDirective:
117818
118064
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -117927,13 +118173,13 @@ var ts;
117927
118173
  return undefined;
117928
118174
  }
117929
118175
  function lookupFromPackageJson() {
117930
- var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
117931
- var packageJsonLocations = [];
117932
- state.failedLookupLocations = packageJsonLocations;
117933
- state.affectingLocations = packageJsonLocations;
117934
- var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
117935
- var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117936
- return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
118176
+ var _a;
118177
+ var packageJsonScope = ts.getPackageScope(ts.getDirectoryPath(fileName), packageJsonInfoCache, host, options);
118178
+ var impliedNodeFormat = ((_a = packageJsonScope.info) === null || _a === void 0 ? void 0 : _a.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
118179
+ return {
118180
+ impliedNodeFormat: impliedNodeFormat,
118181
+ packageJsonScope: packageJsonScope,
118182
+ };
117937
118183
  }
117938
118184
  }
117939
118185
  ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
@@ -118053,10 +118299,10 @@ var ts;
118053
118299
  };
118054
118300
  }
118055
118301
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
118056
- var _a, _b, _c, _d;
118302
+ var _a, _b, _c, _d, _e;
118057
118303
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
118058
118304
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
118059
- var oldProgram = createProgramOptions.oldProgram;
118305
+ var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
118060
118306
  var processingDefaultLibFiles;
118061
118307
  var processingOtherFiles;
118062
118308
  var files;
@@ -118070,6 +118316,8 @@ var ts;
118070
118316
  var cachedDeclarationDiagnosticsForFile = {};
118071
118317
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
118072
118318
  var fileProcessingDiagnostics;
118319
+ var automaticTypeDirectiveNames;
118320
+ var automaticTypeDirectiveResolutions;
118073
118321
  // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
118074
118322
  // This works as imported modules are discovered recursively in a depth first manner, specifically:
118075
118323
  // - For each root file, findSourceFile is called.
@@ -118091,6 +118339,11 @@ var ts;
118091
118339
  var skipDefaultLib = options.noLib;
118092
118340
  var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
118093
118341
  var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
118342
+ /**
118343
+ * Diagnostics for the program
118344
+ * Only add diagnostics directly if it always would be done irrespective of program structure reuse.
118345
+ * Otherwise fileProcessingDiagnostics is correct locations so that the diagnostics can be reported in all structure use scenarios
118346
+ */
118094
118347
  var programDiagnostics = ts.createDiagnosticCollection();
118095
118348
  var currentDirectory = host.getCurrentDirectory();
118096
118349
  var supportedExtensions = ts.getSupportedExtensions(options);
@@ -118103,30 +118356,74 @@ var ts;
118103
118356
  var actualResolveModuleNamesWorker;
118104
118357
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
118105
118358
  if (host.resolveModuleNames) {
118106
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
118107
- // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
118108
- if (!resolved || resolved.extension !== undefined) {
118109
- return resolved;
118110
- }
118111
- var withExtension = ts.clone(resolved);
118112
- withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
118113
- return withExtension;
118114
- }); };
118359
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
118360
+ var _a;
118361
+ 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) {
118362
+ var name = _a.name;
118363
+ return name;
118364
+ }), redirectedReference, options, containingFile, partialResolutionInfo);
118365
+ return result.some(isResolvedModuleWithFailedLookupLocation) ?
118366
+ result :
118367
+ result.map(function (resolved) { return resolved ?
118368
+ resolved.extension !== undefined ?
118369
+ // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
118370
+ { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
118371
+ { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
118372
+ emptyResolution; });
118373
+ };
118115
118374
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
118116
118375
  }
118117
118376
  else {
118118
118377
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
118119
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
118120
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
118378
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
118379
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
118380
+ return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
118381
+ };
118121
118382
  }
118122
118383
  var actualResolveTypeReferenceDirectiveNamesWorker;
118123
118384
  if (host.resolveTypeReferenceDirectives) {
118124
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
118385
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
118386
+ var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
118387
+ return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
118388
+ result :
118389
+ result.map(function (resolved) { return resolved ?
118390
+ { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
118391
+ emptyResolution; });
118392
+ };
118393
+ typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
118125
118394
  }
118126
118395
  else {
118127
118396
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
118128
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
118129
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
118397
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
118398
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
118399
+ return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
118400
+ };
118401
+ }
118402
+ var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
118403
+ var oldBuildInfoProgram;
118404
+ if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
118405
+ var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
118406
+ oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
118407
+ fileExists: function (fileName) { return host.fileExists(fileName); },
118408
+ createHash: ts.maybeBind(host, host.createHash),
118409
+ getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), /*onlyRecordFailures*/ false, state_11); },
118410
+ });
118411
+ if (oldBuildInfoProgram) {
118412
+ // Ensure redirected references are verified before using existing cache
118413
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
118414
+ getResolved: function (dirPath, name, mode, redirectedReference) {
118415
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
118416
+ }
118417
+ });
118418
+ typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
118419
+ getResolved: function (dirPath, name, mode, redirectedReference) {
118420
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
118421
+ }
118422
+ });
118423
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache().setOldPackageJsonScopeCache({
118424
+ getPackageJsonScope: function (dirPath) { return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getPackageJsonScope(dirPath); }
118425
+ });
118426
+ }
118130
118427
  }
118131
118428
  // Map from a stringified PackageId to the source file with that id.
118132
118429
  // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
@@ -118153,9 +118450,9 @@ var ts;
118153
118450
  var projectReferenceRedirects;
118154
118451
  var mapFromFileToProjectReferenceRedirects;
118155
118452
  var mapFromToProjectReferenceRedirectSource;
118156
- var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
118453
+ var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
118157
118454
  !options.disableSourceOfProjectReferenceRedirect;
118158
- var _e = updateHostForUseSourceOfProjectReferenceRedirect({
118455
+ var _f = updateHostForUseSourceOfProjectReferenceRedirect({
118159
118456
  compilerHost: host,
118160
118457
  getSymlinkCache: getSymlinkCache,
118161
118458
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -118163,7 +118460,7 @@ var ts;
118163
118460
  getResolvedProjectReferences: getResolvedProjectReferences,
118164
118461
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
118165
118462
  forEachResolvedProjectReference: forEachResolvedProjectReference
118166
- }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
118463
+ }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
118167
118464
  var readFile = host.readFile.bind(host);
118168
118465
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
118169
118466
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -118174,7 +118471,7 @@ var ts;
118174
118471
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {});
118175
118472
  structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
118176
118473
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118177
- if (structureIsReused !== 2 /* Completely */) {
118474
+ if (structureIsReused !== 3 /* Completely */) {
118178
118475
  processingDefaultLibFiles = [];
118179
118476
  processingOtherFiles = [];
118180
118477
  if (projectReferences) {
@@ -118215,16 +118512,15 @@ var ts;
118215
118512
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
118216
118513
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118217
118514
  // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
118218
- var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
118219
- if (typeReferences.length) {
118220
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length });
118221
- // This containingFilename needs to match with the one used in managed-side
118222
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
118223
- var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
118224
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
118225
- for (var i = 0; i < typeReferences.length; i++) {
118515
+ automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
118516
+ automaticTypeDirectiveResolutions = ts.createModeAwareCache();
118517
+ if (automaticTypeDirectiveNames.length) {
118518
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
118519
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
118520
+ for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
118226
118521
  // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
118227
- 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 });
118522
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i]);
118523
+ 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 });
118228
118524
  }
118229
118525
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118230
118526
  }
@@ -118264,13 +118560,13 @@ var ts;
118264
118560
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
118265
118561
  // old file wasn't redirect but new file is
118266
118562
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
118267
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
118563
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
118268
118564
  }
118269
118565
  }
118270
118566
  if (!host.getParsedCommandLine) {
118271
118567
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
118272
118568
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
118273
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false);
118569
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
118274
118570
  }
118275
118571
  });
118276
118572
  }
@@ -118288,6 +118584,8 @@ var ts;
118288
118584
  typeReferenceDirectiveResolutionCache = undefined;
118289
118585
  // unconditionally set oldProgram to undefined to prevent it from being captured in closure
118290
118586
  oldProgram = undefined;
118587
+ oldBuildInfoProgram = undefined;
118588
+ oldProgramOrOldBuildInfoProgramConstructor = undefined;
118291
118589
  var program = {
118292
118590
  getRootFileNames: function () { return rootNames; },
118293
118591
  getSourceFile: getSourceFile,
@@ -118295,6 +118593,7 @@ var ts;
118295
118593
  getSourceFiles: function () { return files; },
118296
118594
  getMissingFilePaths: function () { return missingFilePaths; },
118297
118595
  getModuleResolutionCache: function () { return moduleResolutionCache; },
118596
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
118298
118597
  getFilesByNameMap: function () { return filesByName; },
118299
118598
  getCompilerOptions: function () { return options; },
118300
118599
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -118319,6 +118618,9 @@ var ts;
118319
118618
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
118320
118619
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
118321
118620
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
118621
+ getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
118622
+ getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
118623
+ getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
118322
118624
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
118323
118625
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
118324
118626
  getSourceFileFromReference: getSourceFileFromReference,
@@ -118328,12 +118630,12 @@ var ts;
118328
118630
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
118329
118631
  isEmittedFile: isEmittedFile,
118330
118632
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
118331
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
118332
118633
  getProjectReferences: getProjectReferences,
118333
118634
  getResolvedProjectReferences: getResolvedProjectReferences,
118334
118635
  getProjectReferenceRedirect: getProjectReferenceRedirect,
118335
118636
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
118336
118637
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
118638
+ getRedirectReferenceForResolution: getRedirectReferenceForResolution,
118337
118639
  forEachResolvedProjectReference: forEachResolvedProjectReference,
118338
118640
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
118339
118641
  emitBuildInfo: emitBuildInfo,
@@ -118341,7 +118643,7 @@ var ts;
118341
118643
  readFile: readFile,
118342
118644
  directoryExists: directoryExists,
118343
118645
  getSymlinkCache: getSymlinkCache,
118344
- realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
118646
+ realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
118345
118647
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
118346
118648
  getFileIncludeReasons: function () { return fileReasons; },
118347
118649
  structureIsReused: structureIsReused,
@@ -118356,6 +118658,8 @@ var ts;
118356
118658
  case 0 /* FilePreprocessingReferencedDiagnostic */:
118357
118659
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
118358
118660
  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)));
118661
+ case 2 /* ResolutionDiagnostics */:
118662
+ return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
118359
118663
  default:
118360
118664
  ts.Debug.assertNever(diagnostic);
118361
118665
  }
@@ -118365,63 +118669,46 @@ var ts;
118365
118669
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
118366
118670
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118367
118671
  return program;
118368
- function addResolutionDiagnostics(list) {
118369
- if (!list)
118370
- return;
118371
- for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
118372
- var elem = list_3[_i];
118373
- programDiagnostics.add(elem);
118374
- }
118672
+ function getAutomaticTypeDirectiveContainingFile() {
118673
+ // This containingFilename needs to match with the one used in managed-side
118674
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
118675
+ return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
118375
118676
  }
118376
- function pullDiagnosticsFromCache(names, containingFile) {
118377
- var _a;
118378
- if (!moduleResolutionCache)
118677
+ function addResolutionDiagnostics(resolution) {
118678
+ if (!resolution.resolutionDiagnostics)
118379
118679
  return;
118380
- var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
118381
- var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
118382
- var containingDir = ts.getDirectoryPath(containingFileName);
118383
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
118384
- var i = 0;
118385
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
118386
- var n = names_4[_i];
118387
- // 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
118388
- var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
118389
- var name = typeof n === "string" ? n : n.fileName;
118390
- i++;
118391
- // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
118392
- // (Since diagnostics are only issued via import or export map lookup)
118393
- // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
118394
- // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
118395
- // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
118396
- if (ts.isExternalModuleNameRelative(name))
118397
- continue;
118398
- var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
118399
- addResolutionDiagnostics(diags);
118400
- }
118680
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
118681
+ kind: 2 /* ResolutionDiagnostics */,
118682
+ diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
118683
+ ? 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
118684
+ : 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
118685
+ d.packagePath); })
118686
+ });
118401
118687
  }
118402
- function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
118688
+ function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
118403
118689
  if (!moduleNames.length)
118404
118690
  return ts.emptyArray;
118405
118691
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
118406
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
118692
+ if (redirectedReference === undefined)
118693
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
118407
118694
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
118408
118695
  ts.performance.mark("beforeResolveModule");
118409
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
118696
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
118410
118697
  ts.performance.mark("afterResolveModule");
118411
118698
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
118412
118699
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
118413
- pullDiagnosticsFromCache(moduleNames, containingFile);
118414
118700
  return result;
118415
118701
  }
118416
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
118702
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
118417
118703
  if (!typeDirectiveNames.length)
118418
118704
  return [];
118419
118705
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
118420
- var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
118706
+ if (redirectedReference === undefined && !ts.isString(containingFile))
118707
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
118421
118708
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
118422
118709
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
118423
118710
  ts.performance.mark("beforeResolveTypeReference");
118424
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
118711
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
118425
118712
  ts.performance.mark("afterResolveTypeReference");
118426
118713
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
118427
118714
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -118474,9 +118761,6 @@ var ts;
118474
118761
  }
118475
118762
  return ts.libs.length + 2;
118476
118763
  }
118477
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
118478
- return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
118479
- }
118480
118764
  function toPath(fileName) {
118481
118765
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
118482
118766
  }
@@ -118501,10 +118785,11 @@ var ts;
118501
118785
  return classifiableNames;
118502
118786
  }
118503
118787
  function resolveModuleNamesReusingOldState(moduleNames, file) {
118788
+ var _a;
118504
118789
  if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) {
118505
118790
  // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules,
118506
118791
  // the best we can do is fallback to the default logic.
118507
- return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined);
118792
+ return resolveModuleNamesWorker(moduleNames, file, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
118508
118793
  }
118509
118794
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
118510
118795
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -118532,6 +118817,8 @@ var ts;
118532
118817
  // With this information, we can infer some module resolutions without performing resolution.
118533
118818
  /** An ordered list of module names for which we cannot recover the resolution. */
118534
118819
  var unknownModuleNames;
118820
+ var unknownModuleNamesIndex;
118821
+ var reusedNames;
118535
118822
  /**
118536
118823
  * The indexing of elements in this list matches that of `moduleNames`.
118537
118824
  *
@@ -118542,22 +118829,33 @@ var ts;
118542
118829
  * * ResolvedModuleFull instance: can be reused.
118543
118830
  */
118544
118831
  var result;
118545
- var reusedNames;
118546
118832
  /** A transient placeholder used to mark predicted resolution in the result list. */
118547
- var predictedToResolveToAmbientModuleMarker = {};
118833
+ var predictedToResolveToAmbientModuleMarker = true;
118834
+ var redirectedReference;
118548
118835
  for (var i = 0; i < moduleNames.length; i++) {
118549
118836
  var moduleName = moduleNames[i];
118550
118837
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
118551
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
118552
- var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
118553
- if (oldResolvedModule) {
118838
+ if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
118839
+ var mode = getModeForResolutionAtIndex(file, i);
118840
+ var oldResolution = !oldBuildInfoProgram ?
118841
+ (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
118842
+ oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
118843
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
118554
118844
  if (ts.isTraceEnabled(options, host)) {
118555
- ts.trace(host, oldResolvedModule.packageId ?
118556
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118557
- 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));
118845
+ var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
118846
+ if (!oldBuildInfoProgram) {
118847
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
118848
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118849
+ 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));
118850
+ }
118851
+ else {
118852
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
118853
+ 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 :
118854
+ 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));
118855
+ }
118558
118856
  }
118559
- (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
118560
- (reusedNames || (reusedNames = [])).push(moduleName);
118857
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
118858
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
118561
118859
  continue;
118562
118860
  }
118563
118861
  }
@@ -118576,15 +118874,16 @@ var ts;
118576
118874
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
118577
118875
  }
118578
118876
  if (resolvesToAmbientModuleInNonModifiedFile) {
118579
- (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
118877
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
118580
118878
  }
118581
118879
  else {
118582
118880
  // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
118583
- (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
118881
+ (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
118882
+ (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
118584
118883
  }
118585
118884
  }
118586
118885
  var resolutions = unknownModuleNames && unknownModuleNames.length
118587
- ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
118886
+ ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
118588
118887
  : ts.emptyArray;
118589
118888
  // Combine results of resolutions and predicted results
118590
118889
  if (!result) {
@@ -118598,7 +118897,7 @@ var ts;
118598
118897
  // `result[i]` is either a `ResolvedModuleFull` or a marker.
118599
118898
  // If it is the former, we can leave it as is.
118600
118899
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
118601
- result[i] = undefined;
118900
+ result[i] = emptyResolution;
118602
118901
  }
118603
118902
  }
118604
118903
  else {
@@ -118633,6 +118932,96 @@ var ts;
118633
118932
  return true;
118634
118933
  }
118635
118934
  }
118935
+ function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
118936
+ var _a;
118937
+ if (structureIsReused === 0 /* Not */) {
118938
+ return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*partialResolutionInfo*/ undefined, /*redirectedReference*/ undefined);
118939
+ }
118940
+ var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
118941
+ var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
118942
+ var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
118943
+ if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
118944
+ // `file` was created for the new program.
118945
+ //
118946
+ // We only set `file.resolvedTypeReferenceDirectiveNames` via work from the current function,
118947
+ // so it is defined iff we already called the current function on `file`.
118948
+ // That call happened no later than the creation of the `file` object,
118949
+ // which per above occurred during the current program creation.
118950
+ // Since we assume the filesystem does not change during program creation,
118951
+ // it is safe to reuse resolutions from the earlier call.
118952
+ var result_15 = [];
118953
+ for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
118954
+ var typeDirectiveName = _b[_i];
118955
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
118956
+ var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
118957
+ result_15.push(resolvedTypeReferenceDirective);
118958
+ }
118959
+ return result_15;
118960
+ }
118961
+ /** An ordered list of module names for which we cannot recover the resolution. */
118962
+ var unknownTypeReferenceDirectiveNames;
118963
+ var unknownTypeReferenceDirectiveNamesIndex;
118964
+ /**
118965
+ * The indexing of elements in this list matches that of `moduleNames`.
118966
+ *
118967
+ * Before combining results, result[i] is in one of the following states:
118968
+ * * undefined: needs to be recomputed,
118969
+ */
118970
+ var result;
118971
+ var reusedNames;
118972
+ var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
118973
+ containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
118974
+ !hasInvalidatedResolution(toPath(inferredTypeFile)));
118975
+ var redirectedReference;
118976
+ for (var i = 0; i < typeDirectiveNames.length; i++) {
118977
+ var entry = typeDirectiveNames[i];
118978
+ // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
118979
+ if (canReuseResolutions) {
118980
+ var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
118981
+ var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
118982
+ var oldResolution = !oldBuildInfoProgram ?
118983
+ (_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) :
118984
+ oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
118985
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
118986
+ if (ts.isTraceEnabled(options, host)) {
118987
+ var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
118988
+ if (!oldBuildInfoProgram) {
118989
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
118990
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
118991
+ 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));
118992
+ }
118993
+ else {
118994
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
118995
+ 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 :
118996
+ 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));
118997
+ }
118998
+ }
118999
+ (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
119000
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
119001
+ continue;
119002
+ }
119003
+ }
119004
+ // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result.
119005
+ (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
119006
+ (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
119007
+ }
119008
+ if (!unknownTypeReferenceDirectiveNames)
119009
+ return result || ts.emptyArray;
119010
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
119011
+ if (!result) {
119012
+ ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
119013
+ return resolutions;
119014
+ }
119015
+ var j = 0;
119016
+ for (var i = 0; i < result.length; i++) {
119017
+ if (!result[i]) {
119018
+ result[i] = resolutions[j];
119019
+ j++;
119020
+ }
119021
+ }
119022
+ ts.Debug.assert(j === resolutions.length);
119023
+ return result;
119024
+ }
118636
119025
  function canReuseProjectReferences() {
118637
119026
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
118638
119027
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -118654,14 +119043,19 @@ var ts;
118654
119043
  });
118655
119044
  }
118656
119045
  function tryReuseStructureFromOldProgram() {
118657
- var _a, _b;
118658
- if (!oldProgram) {
118659
- return 0 /* Not */;
118660
- }
118661
119046
  // check properties that can affect structure of the program or module resolution strategy
118662
119047
  // if any of these properties has changed - structure cannot be reused
118663
- var oldOptions = oldProgram.getCompilerOptions();
118664
- if (ts.changesAffectModuleResolution(oldOptions, options)) {
119048
+ var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
119049
+ if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
119050
+ return 0 /* Not */;
119051
+ }
119052
+ var result = tryReuseStructureFromOldProgramWorker();
119053
+ return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 /* Not */ ?
119054
+ 1 /* SafeModuleCache */ :
119055
+ result;
119056
+ }
119057
+ function tryReuseStructureFromOldProgramWorker() {
119058
+ if (!oldProgram) {
118665
119059
  return 0 /* Not */;
118666
119060
  }
118667
119061
  // there is an old program, check if we can reuse its structure
@@ -118679,7 +119073,7 @@ var ts;
118679
119073
  // check if program source files has changed in the way that can affect structure of the program
118680
119074
  var newSourceFiles = [];
118681
119075
  var modifiedSourceFiles = [];
118682
- structureIsReused = 2 /* Completely */;
119076
+ structureIsReused = 3 /* Completely */;
118683
119077
  // If the missing file paths are now present, it can change the progam structure,
118684
119078
  // and hence cant reuse the structure.
118685
119079
  // This is same as how we dont reuse the structure if one of the file from old program is now missing
@@ -118695,14 +119089,13 @@ var ts;
118695
119089
  var seenPackageNames = new ts.Map();
118696
119090
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
118697
119091
  var oldSourceFile = oldSourceFiles_2[_i];
118698
- var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
119092
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
118699
119093
  var newSourceFile = host.getSourceFileByPath
118700
119094
  ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
118701
119095
  : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
118702
119096
  if (!newSourceFile) {
118703
119097
  return 0 /* Not */;
118704
119098
  }
118705
- newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
118706
119099
  newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
118707
119100
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
118708
119101
  var fileChanged = void 0;
@@ -118744,41 +119137,41 @@ var ts;
118744
119137
  }
118745
119138
  if (fileChanged) {
118746
119139
  if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
118747
- structureIsReused = 1 /* SafeModules */;
119140
+ structureIsReused = 2 /* SafeModules */;
118748
119141
  }
118749
119142
  // The `newSourceFile` object was created for the new program.
118750
119143
  else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
118751
119144
  // 'lib' references has changed. Matches behavior in changesAffectModuleResolution
118752
- structureIsReused = 1 /* SafeModules */;
119145
+ structureIsReused = 2 /* SafeModules */;
118753
119146
  }
118754
119147
  else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
118755
119148
  // value of no-default-lib has changed
118756
119149
  // this will affect if default library is injected into the list of files
118757
- structureIsReused = 1 /* SafeModules */;
119150
+ structureIsReused = 2 /* SafeModules */;
118758
119151
  }
118759
119152
  // check tripleslash references
118760
119153
  else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
118761
119154
  // tripleslash references has changed
118762
- structureIsReused = 1 /* SafeModules */;
119155
+ structureIsReused = 2 /* SafeModules */;
118763
119156
  }
118764
119157
  else {
118765
119158
  // check imports and module augmentations
118766
119159
  collectExternalModuleReferences(newSourceFile);
118767
119160
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
118768
119161
  // imports has changed
118769
- structureIsReused = 1 /* SafeModules */;
119162
+ structureIsReused = 2 /* SafeModules */;
118770
119163
  }
118771
119164
  else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
118772
119165
  // moduleAugmentations has changed
118773
- structureIsReused = 1 /* SafeModules */;
119166
+ structureIsReused = 2 /* SafeModules */;
118774
119167
  }
118775
119168
  else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
118776
119169
  // dynamicImport has changed
118777
- structureIsReused = 1 /* SafeModules */;
119170
+ structureIsReused = 2 /* SafeModules */;
118778
119171
  }
118779
119172
  else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
118780
119173
  // 'types' references has changed
118781
- structureIsReused = 1 /* SafeModules */;
119174
+ structureIsReused = 2 /* SafeModules */;
118782
119175
  }
118783
119176
  }
118784
119177
  // tentatively approve the file
@@ -118786,63 +119179,72 @@ var ts;
118786
119179
  }
118787
119180
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
118788
119181
  // 'module/types' references could have changed
118789
- structureIsReused = 1 /* SafeModules */;
119182
+ structureIsReused = 2 /* SafeModules */;
118790
119183
  // add file to the modified list so that we will resolve it later
118791
119184
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
118792
119185
  }
118793
119186
  // if file has passed all checks it should be safe to reuse it
118794
119187
  newSourceFiles.push(newSourceFile);
118795
119188
  }
118796
- if (structureIsReused !== 2 /* Completely */) {
119189
+ if (structureIsReused !== 3 /* Completely */) {
118797
119190
  return structureIsReused;
118798
119191
  }
118799
119192
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
118800
- for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
118801
- var oldFile = oldSourceFiles_3[_c];
119193
+ for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
119194
+ var oldFile = oldSourceFiles_3[_a];
118802
119195
  if (!ts.contains(modifiedFiles, oldFile)) {
118803
- for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
118804
- var moduleName = _e[_d];
119196
+ for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
119197
+ var moduleName = _c[_b];
118805
119198
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
118806
119199
  }
118807
119200
  }
118808
119201
  }
118809
119202
  // try to verify results of module resolution
118810
- for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
118811
- var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
119203
+ for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
119204
+ var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
118812
119205
  var moduleNames = getModuleNames(newSourceFile);
118813
119206
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
118814
119207
  // ensure that module resolution results are still correct
118815
119208
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
118816
119209
  if (resolutionsChanged) {
118817
- structureIsReused = 1 /* SafeModules */;
119210
+ structureIsReused = 2 /* SafeModules */;
118818
119211
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
118819
119212
  }
118820
119213
  else {
118821
119214
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
118822
119215
  }
118823
119216
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
118824
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
119217
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
118825
119218
  // ensure that types resolutions are still correct
118826
119219
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
118827
119220
  if (typeReferenceResolutionsChanged) {
118828
- structureIsReused = 1 /* SafeModules */;
119221
+ structureIsReused = 2 /* SafeModules */;
118829
119222
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
118830
119223
  }
118831
119224
  else {
118832
119225
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
118833
119226
  }
118834
119227
  }
118835
- if (structureIsReused !== 2 /* Completely */) {
119228
+ if (structureIsReused !== 3 /* Completely */) {
118836
119229
  return structureIsReused;
118837
119230
  }
118838
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
118839
- return 1 /* SafeModules */;
119231
+ if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
119232
+ return 2 /* SafeModules */;
119233
+ }
119234
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
119235
+ if (host.hasChangedAutomaticTypeDirectiveNames())
119236
+ return 2 /* SafeModules */;
119237
+ }
119238
+ else {
119239
+ automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
119240
+ if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
119241
+ return 2 /* SafeModules */;
118840
119242
  }
118841
119243
  missingFilePaths = oldProgram.getMissingFilePaths();
118842
119244
  // update fileName -> file mapping
118843
119245
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
118844
- for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
118845
- var newSourceFile = newSourceFiles_1[_h];
119246
+ for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
119247
+ var newSourceFile = newSourceFiles_1[_f];
118846
119248
  filesByName.set(newSourceFile.path, newSourceFile);
118847
119249
  }
118848
119250
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -118864,10 +119266,12 @@ var ts;
118864
119266
  fileReasons = oldProgram.getFileIncludeReasons();
118865
119267
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
118866
119268
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
119269
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
119270
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
118867
119271
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
118868
119272
  redirectTargetsMap = oldProgram.redirectTargetsMap;
118869
119273
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
118870
- return 2 /* Completely */;
119274
+ return 3 /* Completely */;
118871
119275
  }
118872
119276
  function getEmitHost(writeFileCallback) {
118873
119277
  return {
@@ -119627,14 +120031,12 @@ var ts;
119627
120031
  }
119628
120032
  }
119629
120033
  function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
119630
- var _a;
119631
120034
  var redirect = Object.create(redirectTarget);
119632
120035
  redirect.fileName = fileName;
119633
120036
  redirect.path = path;
119634
120037
  redirect.resolvedPath = resolvedPath;
119635
120038
  redirect.originalFileName = originalFileName;
119636
120039
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
119637
- redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
119638
120040
  redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
119639
120041
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
119640
120042
  Object.defineProperties(redirect, {
@@ -119660,7 +120062,7 @@ var ts;
119660
120062
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119661
120063
  return result;
119662
120064
  }
119663
- function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
120065
+ function getCreateSourceFileOptions(fileName) {
119664
120066
  // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
119665
120067
  // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
119666
120068
  // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
@@ -119671,7 +120073,7 @@ var ts;
119671
120073
  { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
119672
120074
  }
119673
120075
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
119674
- var _a, _b;
120076
+ var _a;
119675
120077
  var path = toPath(fileName);
119676
120078
  if (useSourceOfProjectReferenceRedirect) {
119677
120079
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -119758,7 +120160,7 @@ var ts;
119758
120160
  }
119759
120161
  }
119760
120162
  // We haven't looked for this file, do so now and cache result
119761
- var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
120163
+ var sourceFileOptions = getCreateSourceFileOptions(fileName);
119762
120164
  var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
119763
120165
  if (packageId) {
119764
120166
  var packageIdKey = ts.packageIdToString(packageId);
@@ -119787,7 +120189,6 @@ var ts;
119787
120189
  file.path = path;
119788
120190
  file.resolvedPath = toPath(fileName);
119789
120191
  file.originalFileName = originalFileName;
119790
- file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
119791
120192
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
119792
120193
  addFileIncludeReason(file, reason);
119793
120194
  if (host.useCaseSensitiveFileNames()) {
@@ -119916,35 +120317,42 @@ var ts;
119916
120317
  }
119917
120318
  function processTypeReferenceDirectives(file) {
119918
120319
  var typeDirectives = file.typeReferenceDirectives;
119919
- if (!typeDirectives) {
120320
+ if (!typeDirectives.length) {
120321
+ file.resolvedTypeReferenceDirectiveNames = undefined;
119920
120322
  return;
119921
120323
  }
119922
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
120324
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
119923
120325
  for (var index = 0; index < typeDirectives.length; index++) {
119924
120326
  var ref = file.typeReferenceDirectives[index];
119925
120327
  var resolvedTypeReferenceDirective = resolutions[index];
119926
120328
  // store resolved type directive on the file
119927
120329
  var fileName = ts.toFileNameLowerCase(ref.fileName);
119928
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
120330
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
119929
120331
  var mode = ref.resolutionMode || file.impliedNodeFormat;
119930
120332
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
119931
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
120333
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
120334
+ kind: 2 /* ResolutionDiagnostics */,
120335
+ diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
120336
+ });
119932
120337
  }
119933
120338
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
119934
120339
  }
119935
120340
  }
119936
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119937
- 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 });
119938
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
120341
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
120342
+ 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 });
120343
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
119939
120344
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119940
120345
  }
119941
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
120346
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
120347
+ var _a;
120348
+ addResolutionDiagnostics(resolution);
119942
120349
  // If we already found this library as a primary reference - nothing to do
119943
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
120350
+ var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
119944
120351
  if (previousResolution && previousResolution.primary) {
119945
120352
  return;
119946
120353
  }
119947
120354
  var saveResolution = true;
120355
+ var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
119948
120356
  if (resolvedTypeReferenceDirective) {
119949
120357
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
119950
120358
  currentNodeModulesDepth++;
@@ -119979,7 +120387,7 @@ var ts;
119979
120387
  addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
119980
120388
  }
119981
120389
  if (saveResolution) {
119982
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
120390
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
119983
120391
  }
119984
120392
  }
119985
120393
  function pathForLibFile(libFileName) {
@@ -120012,7 +120420,7 @@ var ts;
120012
120420
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
120013
120421
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
120014
120422
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
120015
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
120423
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
120016
120424
  kind: 0 /* FilePreprocessingReferencedDiagnostic */,
120017
120425
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
120018
120426
  diagnostic: diagnostic,
@@ -120036,13 +120444,14 @@ var ts;
120036
120444
  for (var index = 0; index < moduleNames.length; index++) {
120037
120445
  var resolution = resolutions[index];
120038
120446
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
120039
- if (!resolution) {
120447
+ addResolutionDiagnostics(resolution);
120448
+ if (!resolution.resolvedModule) {
120040
120449
  continue;
120041
120450
  }
120042
- var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
120043
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
120451
+ var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
120452
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
120044
120453
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
120045
- var resolvedFileName = resolution.resolvedFileName;
120454
+ var resolvedFileName = resolution.resolvedModule.resolvedFileName;
120046
120455
  if (isFromNodeModulesSearch) {
120047
120456
  currentNodeModulesDepth++;
120048
120457
  }
@@ -120055,7 +120464,7 @@ var ts;
120055
120464
  // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs')
120056
120465
  // This may still end up being an untyped module -- the file won't be included but imports will be allowed.
120057
120466
  var shouldAddFile = resolvedFileName
120058
- && !getResolutionDiagnostic(optionsForFile, resolution)
120467
+ && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
120059
120468
  && !optionsForFile.noResolve
120060
120469
  && index < file.imports.length
120061
120470
  && !elideImport
@@ -120067,7 +120476,7 @@ var ts;
120067
120476
  else if (shouldAddFile) {
120068
120477
  findSourceFile(resolvedFileName,
120069
120478
  /*isDefaultLib*/ false,
120070
- /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
120479
+ /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
120071
120480
  }
120072
120481
  if (isFromNodeModulesSearch) {
120073
120482
  currentNodeModulesDepth--;
@@ -120171,6 +120580,9 @@ var ts;
120171
120580
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
120172
120581
  }
120173
120582
  }
120583
+ if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
120584
+ createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
120585
+ }
120174
120586
  var outputFile = ts.outFile(options);
120175
120587
  if (options.tsBuildInfoFile) {
120176
120588
  if (!ts.isIncrementalCompilation(options)) {
@@ -120439,7 +120851,7 @@ var ts;
120439
120851
  }
120440
120852
  }
120441
120853
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
120442
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
120854
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
120443
120855
  kind: 1 /* FilePreprocessingFileExplainingDiagnostic */,
120444
120856
  file: file && file.path,
120445
120857
  fileProcessingReason: fileProcessingReason,
@@ -120707,8 +121119,8 @@ var ts;
120707
121119
  if (!symlinks) {
120708
121120
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
120709
121121
  }
120710
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
120711
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
121122
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
121123
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
120712
121124
  }
120713
121125
  return symlinks;
120714
121126
  }
@@ -121121,7 +121533,8 @@ var ts;
121121
121533
  }
121122
121534
  // Handle type reference directives
121123
121535
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
121124
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
121536
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
121537
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
121125
121538
  if (!resolvedTypeReferenceDirective) {
121126
121539
  return;
121127
121540
  }
@@ -121180,12 +121593,13 @@ var ts;
121180
121593
  /**
121181
121594
  * Creates the state of file references and signature for the new program from oldState if it is safe
121182
121595
  */
121183
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
121596
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
121184
121597
  var _a, _b, _c;
121185
121598
  var fileInfos = new ts.Map();
121186
121599
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
121187
121600
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
121188
121601
  var useOldState = canReuseOldState(referencedMap, oldState);
121602
+ var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
121189
121603
  // Ensure source files have parent pointers set
121190
121604
  newProgram.getTypeChecker();
121191
121605
  // Create the reference map, and set the file infos
@@ -121238,23 +121652,23 @@ var ts;
121238
121652
  /**
121239
121653
  * Gets the files affected by the path from the program
121240
121654
  */
121241
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
121655
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
121242
121656
  var _a, _b;
121243
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
121657
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
121244
121658
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
121245
121659
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121246
121660
  return result;
121247
121661
  }
121248
121662
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
121249
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
121663
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
121250
121664
  var sourceFile = programOfThisState.getSourceFileByPath(path);
121251
121665
  if (!sourceFile) {
121252
121666
  return ts.emptyArray;
121253
121667
  }
121254
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121668
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
121255
121669
  return [sourceFile];
121256
121670
  }
121257
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
121671
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
121258
121672
  }
121259
121673
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
121260
121674
  function updateSignatureOfFile(state, signature, path) {
@@ -121265,7 +121679,7 @@ var ts;
121265
121679
  /**
121266
121680
  * Returns if the shape of the signature has changed since last emit
121267
121681
  */
121268
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
121682
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
121269
121683
  var _a;
121270
121684
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
121271
121685
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -121277,7 +121691,7 @@ var ts;
121277
121691
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
121278
121692
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
121279
121693
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
121280
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
121694
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
121281
121695
  if (latestSignature !== prevSignature) {
121282
121696
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
121283
121697
  }
@@ -121456,7 +121870,7 @@ var ts;
121456
121870
  /**
121457
121871
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
121458
121872
  */
121459
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
121873
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
121460
121874
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
121461
121875
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
121462
121876
  }
@@ -121476,7 +121890,7 @@ var ts;
121476
121890
  if (!seenFileNamesMap.has(currentPath)) {
121477
121891
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
121478
121892
  seenFileNamesMap.set(currentPath, currentSourceFile);
121479
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121893
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
121480
121894
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
121481
121895
  }
121482
121896
  }
@@ -121501,9 +121915,9 @@ var ts;
121501
121915
  /**
121502
121916
  * Create the state so that we can iterate on changedFiles/affected files
121503
121917
  */
121504
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
121918
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
121505
121919
  var _a, _b;
121506
- var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
121920
+ var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
121507
121921
  state.program = newProgram;
121508
121922
  var compilerOptions = newProgram.getCompilerOptions();
121509
121923
  state.compilerOptions = compilerOptions;
@@ -121567,7 +121981,7 @@ var ts;
121567
121981
  // Unchanged file copy diagnostics
121568
121982
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
121569
121983
  if (diagnostics) {
121570
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
121984
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
121571
121985
  if (!state.semanticDiagnosticsFromOldState) {
121572
121986
  state.semanticDiagnosticsFromOldState = new ts.Set();
121573
121987
  }
@@ -121592,13 +122006,16 @@ var ts;
121592
122006
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
121593
122007
  }
121594
122008
  // Since old states change files set is copied, any additional change means we would need to emit build info
121595
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
122009
+ state.buildInfoEmitPending = !useOldState ||
122010
+ state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
122011
+ state.fileInfos.size !== oldState.fileInfos.size;
121596
122012
  return state;
121597
122013
  }
121598
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
122014
+ function convertToDiagnostics(diagnostics, newProgram) {
121599
122015
  if (!diagnostics.length)
121600
122016
  return ts.emptyArray;
121601
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
122017
+ var buildInfoDirectory;
122018
+ var getCanonicalFileName;
121602
122019
  return diagnostics.map(function (diagnostic) {
121603
122020
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
121604
122021
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -121614,7 +122031,8 @@ var ts;
121614
122031
  return result;
121615
122032
  });
121616
122033
  function toPath(path) {
121617
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
122034
+ buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
122035
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
121618
122036
  }
121619
122037
  }
121620
122038
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -121626,6 +122044,9 @@ var ts;
121626
122044
  */
121627
122045
  function releaseCache(state) {
121628
122046
  ts.BuilderState.releaseCache(state);
122047
+ // Store the resolutions if possible
122048
+ if (!state.resuableCacheResolutions)
122049
+ getCacheResolutions(state);
121629
122050
  state.program = undefined;
121630
122051
  }
121631
122052
  function backupBuilderProgramEmitState(state) {
@@ -121670,7 +122091,7 @@ var ts;
121670
122091
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121671
122092
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121672
122093
  */
121673
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
122094
+ function getNextAffectedFile(state, cancellationToken, host) {
121674
122095
  var _a, _b;
121675
122096
  while (true) {
121676
122097
  var affectedFiles = state.affectedFiles;
@@ -121682,7 +122103,7 @@ var ts;
121682
122103
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121683
122104
  // Set the next affected file as seen and remove the cached semantic diagnostics
121684
122105
  state.affectedFilesIndex = affectedFilesIndex;
121685
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
122106
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
121686
122107
  return affectedFile;
121687
122108
  }
121688
122109
  affectedFilesIndex++;
@@ -121710,7 +122131,7 @@ var ts;
121710
122131
  return program;
121711
122132
  }
121712
122133
  // Get next batch of affected files
121713
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
122134
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
121714
122135
  state.currentChangedFilePath = nextKey.value;
121715
122136
  state.affectedFilesIndex = 0;
121716
122137
  if (!state.seenAffectedFiles)
@@ -121761,7 +122182,7 @@ var ts;
121761
122182
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121762
122183
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121763
122184
  */
121764
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122185
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
121765
122186
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121766
122187
  // If affected files is everything except default library, then nothing more to do
121767
122188
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121769,18 +122190,18 @@ var ts;
121769
122190
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121770
122191
  // That means when affected file is handled, its signature can be out of date
121771
122192
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121772
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
122193
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
121773
122194
  return;
121774
122195
  }
121775
122196
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121776
122197
  return;
121777
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
122198
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
121778
122199
  }
121779
122200
  /**
121780
122201
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121781
122202
  * Also we need to make sure signature is updated for these files
121782
122203
  */
121783
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
122204
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
121784
122205
  removeSemanticDiagnosticsOf(state, path);
121785
122206
  if (!state.changedFilesSet.has(path)) {
121786
122207
  var program = ts.Debug.checkDefined(state.program);
@@ -121791,7 +122212,7 @@ var ts;
121791
122212
  // This ensures that we dont later during incremental builds considering wrong signature.
121792
122213
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121793
122214
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121794
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
122215
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
121795
122216
  // If not dts emit, nothing more to do
121796
122217
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121797
122218
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121816,20 +122237,20 @@ var ts;
121816
122237
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121817
122238
  return newSignature !== oldSignature;
121818
122239
  }
121819
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
122240
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
121820
122241
  var _a;
121821
122242
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121822
122243
  return false;
121823
122244
  // Every file needs to be handled
121824
122245
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121825
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
122246
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
121826
122247
  removeDiagnosticsOfLibraryFiles(state);
121827
122248
  return true;
121828
122249
  }
121829
122250
  /**
121830
122251
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121831
122252
  */
121832
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122253
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
121833
122254
  var _a;
121834
122255
  // If there was change in signature (dts output) for the changed file,
121835
122256
  // then only we need to handle pending file emit
@@ -121847,9 +122268,9 @@ var ts;
121847
122268
  var currentPath = queue.pop();
121848
122269
  if (!seenFileNamesMap.has(currentPath)) {
121849
122270
  seenFileNamesMap.set(currentPath, true);
121850
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
122271
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
121851
122272
  return;
121852
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
122273
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
121853
122274
  if (isChangedSignature(state, currentPath)) {
121854
122275
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121855
122276
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121861,11 +122282,11 @@ var ts;
121861
122282
  // Go through exported modules from cache first
121862
122283
  // If exported modules has path, all files referencing file exported from are affected
121863
122284
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121864
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
122285
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
121865
122286
  return true;
121866
122287
  var references = state.referencedMap.getKeys(exportedFromPath);
121867
122288
  return references && ts.forEachKey(references, function (filePath) {
121868
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
122289
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
121869
122290
  });
121870
122291
  });
121871
122292
  }
@@ -121873,22 +122294,22 @@ var ts;
121873
122294
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121874
122295
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121875
122296
  */
121876
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
122297
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
121877
122298
  var _a, _b;
121878
122299
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121879
122300
  return undefined;
121880
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
122301
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
121881
122302
  return true;
121882
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
122303
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
121883
122304
  // If exported modules has path, all files referencing file exported from are affected
121884
122305
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121885
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
122306
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
121886
122307
  });
121887
122308
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121888
122309
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121889
122310
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121890
122311
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121891
- state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
122312
+ state, referencingFilePath, cancellationToken, host);
121892
122313
  });
121893
122314
  return undefined;
121894
122315
  }
@@ -121967,35 +122388,46 @@ var ts;
121967
122388
  /**
121968
122389
  * Gets the program information to be emitted in buildInfo so that we can use it to create new program
121969
122390
  */
121970
- function getProgramBuildInfo(state, getCanonicalFileName) {
122391
+ function getProgramBuildInfo(state, host) {
121971
122392
  var outFilePath = ts.outFile(state.compilerOptions);
121972
- if (outFilePath && !state.compilerOptions.composite)
122393
+ if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
121973
122394
  return;
121974
122395
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
121975
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
122396
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
122397
+ var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
122398
+ var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
121976
122399
  // 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
121977
122400
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
122401
+ var fileNames = [];
122402
+ var fileNameToFileId = new ts.Map();
122403
+ var resolutions;
122404
+ var names;
122405
+ var resolutionNameToResolutionNameId;
122406
+ var resolutionEntries;
122407
+ var resolutionEntryToResolutionEntryId;
122408
+ var affectedFilesHash;
121978
122409
  if (outFilePath) {
121979
- var fileNames_1 = [];
121980
- var fileInfos_1 = [];
121981
- state.program.getRootFileNames().forEach(function (f) {
121982
- var sourceFile = state.program.getSourceFile(f);
121983
- if (!sourceFile)
121984
- return;
121985
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
121986
- fileInfos_1.push(sourceFile.version);
121987
- });
121988
- var result_15 = {
121989
- fileNames: fileNames_1,
122410
+ var fileInfos_1;
122411
+ if (state.compilerOptions.composite) {
122412
+ state.program.getRootFileNames().forEach(function (f) {
122413
+ var sourceFile = state.program.getSourceFile(f);
122414
+ if (!sourceFile)
122415
+ return;
122416
+ var fileId = toFileId(sourceFile.resolvedPath);
122417
+ (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
122418
+ });
122419
+ }
122420
+ var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
122421
+ var result_16 = {
122422
+ fileNames: fileNames,
121990
122423
  fileInfos: fileInfos_1,
121991
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
122424
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
121992
122425
  outSignature: state.outSignature,
121993
122426
  latestChangedDtsFile: latestChangedDtsFile,
122427
+ cacheResolutions: cacheResolutions_1,
121994
122428
  };
121995
- return result_15;
122429
+ return result_16;
121996
122430
  }
121997
- var fileNames = [];
121998
- var fileNameToFileId = new ts.Map();
121999
122431
  var fileIdsList;
122000
122432
  var fileNamesToFileIdListId;
122001
122433
  var emitSignatures;
@@ -122059,7 +122491,7 @@ var ts;
122059
122491
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
122060
122492
  [
122061
122493
  toFileId(key),
122062
- convertToReusableDiagnostics(value, relativeToBuildInfo)
122494
+ value.map(toReusableDiagnostic)
122063
122495
  ] :
122064
122496
  toFileId(key));
122065
122497
  }
@@ -122081,10 +122513,11 @@ var ts;
122081
122513
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
122082
122514
  }
122083
122515
  }
122516
+ var cacheResolutions = toProgramBuildInfoCacheResolutions();
122084
122517
  var result = {
122085
122518
  fileNames: fileNames,
122086
122519
  fileInfos: fileInfos,
122087
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
122520
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
122088
122521
  fileIdsList: fileIdsList,
122089
122522
  referencedMap: referencedMap,
122090
122523
  exportedModulesMap: exportedModulesMap,
@@ -122093,6 +122526,7 @@ var ts;
122093
122526
  changeFileSet: changeFileSet,
122094
122527
  emitSignatures: emitSignatures,
122095
122528
  latestChangedDtsFile: latestChangedDtsFile,
122529
+ cacheResolutions: cacheResolutions,
122096
122530
  };
122097
122531
  return result;
122098
122532
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -122101,7 +122535,7 @@ var ts;
122101
122535
  function relativeToBuildInfo(path) {
122102
122536
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
122103
122537
  }
122104
- function toFileId(path) {
122538
+ function toFileAndAbsoluteFileId(path) {
122105
122539
  var fileId = fileNameToFileId.get(path);
122106
122540
  if (fileId === undefined) {
122107
122541
  fileNames.push(relativeToBuildInfo(path));
@@ -122109,6 +122543,12 @@ var ts;
122109
122543
  }
122110
122544
  return fileId;
122111
122545
  }
122546
+ function toFileId(path) {
122547
+ return toFileAndAbsoluteFileId(path);
122548
+ }
122549
+ function toAbsoluteFileId(path) {
122550
+ return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
122551
+ }
122112
122552
  function toFileIdListId(set) {
122113
122553
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
122114
122554
  var key = fileIds.join();
@@ -122121,54 +122561,238 @@ var ts;
122121
122561
  }
122122
122562
  /**
122123
122563
  * @param optionKey key of CommandLineOption to use to determine if the option should be serialized in tsbuildinfo
122564
+ * @param affectsModuleResolution serialize options affecting module resolution
122124
122565
  */
122125
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
122566
+ function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
122126
122567
  var result;
122127
122568
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
122128
122569
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
122129
122570
  var name = _a[_i];
122130
122571
  var optionInfo = optionsNameMap.get(name.toLowerCase());
122131
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
122132
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
122572
+ if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
122573
+ (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
122574
+ }
122575
+ else if (affectsModuleResolution && name === "pathsBasePath") {
122576
+ (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
122577
+ continue;
122133
122578
  }
122134
122579
  }
122135
122580
  return result;
122136
122581
  }
122137
- }
122138
- function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
122139
- if (option) {
122140
- if (option.type === "list") {
122141
- var values = value;
122142
- if (option.element.isFilePath && values.length) {
122143
- return values.map(relativeToBuildInfo);
122582
+ function toReusableCompilerOptionValue(option, value) {
122583
+ if (option) {
122584
+ if (option.type === "list") {
122585
+ var values = value;
122586
+ if (option.element.isFilePath && values.length) {
122587
+ return values.map(relativeToBuildInfoEnsuringAbsolutePath);
122588
+ }
122589
+ }
122590
+ else if (option.isFilePath) {
122591
+ return relativeToBuildInfoEnsuringAbsolutePath(value);
122144
122592
  }
122145
122593
  }
122146
- else if (option.isFilePath) {
122147
- return relativeToBuildInfo(value);
122148
- }
122594
+ return value;
122149
122595
  }
122150
- return value;
122151
- }
122152
- function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
122153
- ts.Debug.assert(!!diagnostics.length);
122154
- return diagnostics.map(function (diagnostic) {
122155
- var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
122596
+ function toReadonlyArrayOrUndefined(array, map) {
122597
+ return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
122598
+ }
122599
+ function toReusableDiagnostic(diagnostic) {
122600
+ var result = toReusableDiagnosticRelatedInformation(diagnostic);
122156
122601
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
122157
122602
  result.reportDeprecated = diagnostic.reportsDeprecated;
122158
122603
  result.source = diagnostic.source;
122159
122604
  result.skippedOn = diagnostic.skippedOn;
122160
122605
  var relatedInformation = diagnostic.relatedInformation;
122161
- result.relatedInformation = relatedInformation ?
122162
- relatedInformation.length ?
122163
- relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
122164
- [] :
122165
- undefined;
122606
+ result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
122166
122607
  return result;
122608
+ }
122609
+ function toReusableDiagnosticRelatedInformation(diagnostic) {
122610
+ var file = diagnostic.file;
122611
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
122612
+ }
122613
+ function toProgramBuildInfoCacheResolutions() {
122614
+ var cacheResolutions = getCacheResolutions(state);
122615
+ var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
122616
+ var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
122617
+ var packageJsons = toProgramBuildInfoPackageJsons(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.perDirPackageJsonMap);
122618
+ if (!resolutions)
122619
+ return;
122620
+ ts.Debug.assertIsDefined(names);
122621
+ ts.Debug.assertIsDefined(resolutionEntries);
122622
+ state.resuableCacheResolutions = {
122623
+ cache: {
122624
+ resolutions: resolutions.map(toProgramBuildInfoResolution),
122625
+ names: names,
122626
+ hash: toProgramBuildInfoHashes(),
122627
+ resolutionEntries: resolutionEntries,
122628
+ modules: modules,
122629
+ typeRefs: typeRefs,
122630
+ packageJsons: packageJsons,
122631
+ },
122632
+ getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
122633
+ };
122634
+ return state.resuableCacheResolutions.cache;
122635
+ }
122636
+ function toProgramBuildInfoPackageJsons(cache) {
122637
+ var result;
122638
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (packageJson, dirPath) {
122639
+ var packageJsonDirPath = ts.getDirectoryPath(ts.toPath(packageJson, currentDirectory, getCanonicalFileName));
122640
+ // Dont need to store package json found in same directory
122641
+ if (packageJsonDirPath !== dirPath) {
122642
+ (result !== null && result !== void 0 ? result : (result = [])).push([
122643
+ toFileId(dirPath),
122644
+ toAbsoluteFileId(packageJson),
122645
+ ]);
122646
+ }
122647
+ });
122648
+ return result;
122649
+ }
122650
+ function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
122651
+ if (!cache)
122652
+ return undefined;
122653
+ var ownMap = cache.getOwnMap();
122654
+ var own = toProgramBuildInfoResolutionCache(ownMap);
122655
+ var redirects;
122656
+ cache.redirectsKeyToCache.forEach(function (_a) {
122657
+ var map = _a.map, options = _a.options;
122658
+ if (map === ownMap)
122659
+ return;
122660
+ var redirectCache = toProgramBuildInfoResolutionCache(map);
122661
+ if (redirectCache) {
122662
+ (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
122663
+ options: toProgramBuildInfoCompilerOptions(options, /*optionKey*/ undefined, /*affectsModuleResolution*/ true),
122664
+ cache: redirectCache
122665
+ });
122666
+ }
122667
+ });
122668
+ return !redirects ? own : { own: own, redirects: redirects };
122669
+ }
122670
+ function toProgramBuildInfoResolutionCache(cache) {
122671
+ var result;
122672
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
122673
+ (result !== null && result !== void 0 ? result : (result = [])).push([
122674
+ toFileId(dirPath),
122675
+ ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
122676
+ ]) :
122677
+ undefined; });
122678
+ return result;
122679
+ }
122680
+ function toProgramBuildInfoResolutionEntryId(_a) {
122681
+ var name = _a[0], mode = _a[1], resolution = _a[2];
122682
+ var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
122683
+ var resolutionId = toProgramBuildInfoResolutionId(resolution);
122684
+ var key = resolutionNameId + "," + mode + "," + resolutionId;
122685
+ var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
122686
+ if (resolutionEntryId === undefined) {
122687
+ (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
122688
+ (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
122689
+ }
122690
+ return resolutionEntryId;
122691
+ }
122692
+ function toProgramBuildInfoResolutionNameId(name) {
122693
+ var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
122694
+ if (resolutionNameId === undefined) {
122695
+ (names !== null && names !== void 0 ? names : (names = [])).push(name);
122696
+ (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
122697
+ }
122698
+ return resolutionNameId;
122699
+ }
122700
+ function toProgramBuildInfoResolutionId(resolution) {
122701
+ if (resolution.serializationIndex === undefined) {
122702
+ (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
122703
+ resolution.serializationIndex = resolutions.length;
122704
+ }
122705
+ return resolution.serializationIndex;
122706
+ }
122707
+ function toProgramBuildInfoResolution(resolution) {
122708
+ resolution.serializationIndex = undefined;
122709
+ return {
122710
+ resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
122711
+ resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
122712
+ affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
122713
+ resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
122714
+ };
122715
+ }
122716
+ function toProgramBuildInfoHashes() {
122717
+ if (!affectedFilesHash)
122718
+ return undefined;
122719
+ var hashes = [];
122720
+ for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
122721
+ var key = _a[_i];
122722
+ var value = affectedFilesHash.get(key);
122723
+ hashes.push(value ? [key, value] : key);
122724
+ }
122725
+ return hashes;
122726
+ }
122727
+ function toAffectedFileId(file) {
122728
+ var _a;
122729
+ var fileId = toAbsoluteFileId(file);
122730
+ if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
122731
+ // Store the file hash
122732
+ var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
122733
+ var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
122734
+ (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
122735
+ }
122736
+ return fileId;
122737
+ }
122738
+ function toProgramBuildInfoResolved(resolved) {
122739
+ 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;
122740
+ }
122741
+ function toProgramBuildInfoResolutionDiagnostic(d) {
122742
+ return {
122743
+ isImports: d.isImports || undefined,
122744
+ entry: d.entry || undefined,
122745
+ packagePath: toAbsoluteFileId(d.packagePath),
122746
+ };
122747
+ }
122748
+ }
122749
+ function getCacheResolutions(state) {
122750
+ var _a;
122751
+ if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
122752
+ return state.cacheResolutions;
122753
+ var modules;
122754
+ var typeRefs;
122755
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
122756
+ var dirToPackageJsonScope = new ts.Map();
122757
+ var perDirPackageJsonMap;
122758
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
122759
+ state.program.getSourceFiles().forEach(function (f) {
122760
+ var _a;
122761
+ modules = toPerDirectoryCache(state, getCanonicalFileName, modules, ts.getResolvedModuleOfResolution, f, f.resolvedModules, moduleNameToDirectoryMap);
122762
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, f, f.resolvedTypeReferenceDirectiveNames);
122763
+ if ((_a = f.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
122764
+ var dirPath = ts.getDirectoryPath(f.resolvedPath);
122765
+ if (!(dirToPackageJsonScope === null || dirToPackageJsonScope === void 0 ? void 0 : dirToPackageJsonScope.has(dirPath))) {
122766
+ (perDirPackageJsonMap !== null && perDirPackageJsonMap !== void 0 ? perDirPackageJsonMap : (perDirPackageJsonMap = new ts.Map())).set(dirPath, ts.getPackageJsconLocationFromScope(f.packageJsonScope));
122767
+ ts.moduleNameToDirectorySet(dirToPackageJsonScope, dirPath, f.packageJsonScope, ts.getPackageJsconLocationFromScope, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { return perDirPackageJsonMap === null || perDirPackageJsonMap === void 0 ? void 0 : perDirPackageJsonMap.delete(ancestorPath); });
122768
+ }
122769
+ }
122167
122770
  });
122771
+ var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
122772
+ if (automaticTypeDirectiveNames.length) {
122773
+ var currentDirectory = state.program.getCurrentDirectory();
122774
+ var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
122775
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
122776
+ }
122777
+ return state.cacheResolutions = {
122778
+ modules: modules,
122779
+ typeRefs: typeRefs,
122780
+ moduleNameToDirectoryMap: moduleNameToDirectoryMap,
122781
+ dirToPackageJsonScope: dirToPackageJsonScope,
122782
+ perDirPackageJsonMap: perDirPackageJsonMap,
122783
+ packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
122784
+ };
122168
122785
  }
122169
- function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
122170
- var file = diagnostic.file;
122171
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
122786
+ function toPerDirectoryCache(state, getCanonicalFileName, perDirCache, getResolutionWithResolvedFileName, sourceFileOrPath, fileCacheFromProgram, moduleNameToDirectoryMap) {
122787
+ return ts.toPerDirectoryResolution(state.program, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, ts.noop, function (r, name, mode, _key, redirectedReference, dirPath) {
122788
+ var _a, _b, _c;
122789
+ // If this is not resolved, dont put in per dir Cache
122790
+ return !((_a = getResolutionWithResolvedFileName(r)) === null || _a === void 0 ? void 0 : _a.resolvedFileName) ||
122791
+ // If there was already external module resolution that is same, set for child directory, dont set resolution for this directory
122792
+ (moduleNameToDirectoryMap &&
122793
+ !ts.isExternalModuleNameRelative(name) &&
122794
+ ((_c = (_b = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _b === void 0 ? void 0 : _b.get(ts.getModeAwareCacheKey(name, mode))) === null || _c === void 0 ? void 0 : _c.get(dirPath)));
122795
+ }, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath, name, mode, perDirResolutionCache) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
122172
122796
  }
122173
122797
  var BuilderProgramKind;
122174
122798
  (function (BuilderProgramKind) {
@@ -122192,7 +122816,7 @@ var ts;
122192
122816
  rootNames: newProgramOrRootNames,
122193
122817
  options: hostOrOptions,
122194
122818
  host: oldProgramOrHost,
122195
- oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
122819
+ oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
122196
122820
  configFileParsingDiagnostics: configFileParsingDiagnostics,
122197
122821
  projectReferences: projectReferences
122198
122822
  });
@@ -122210,8 +122834,8 @@ var ts;
122210
122834
  function getTextHandlingSourceMapForSignature(text, data) {
122211
122835
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
122212
122836
  }
122213
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
122214
- var _a;
122837
+ function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
122838
+ var _a, _b;
122215
122839
  text = getTextHandlingSourceMapForSignature(text, data);
122216
122840
  var sourceFileDirectory;
122217
122841
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -122219,7 +122843,7 @@ var ts;
122219
122843
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
122220
122844
  }).join("\n");
122221
122845
  }
122222
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
122846
+ return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
122223
122847
  function flattenDiagnosticMessageText(diagnostic) {
122224
122848
  return ts.isString(diagnostic) ?
122225
122849
  diagnostic :
@@ -122238,8 +122862,9 @@ var ts;
122238
122862
  }
122239
122863
  }
122240
122864
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
122241
- function computeSignature(text, computeHash, data) {
122242
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
122865
+ function computeSignature(text, host, data) {
122866
+ var _a;
122867
+ return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
122243
122868
  }
122244
122869
  ts.computeSignature = computeSignature;
122245
122870
  function createBuilderProgram(kind, _a) {
@@ -122251,16 +122876,8 @@ var ts;
122251
122876
  oldState = undefined;
122252
122877
  return oldProgram;
122253
122878
  }
122254
- /**
122255
- * Create the canonical file name for identity
122256
- */
122257
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
122258
- /**
122259
- * Computing hash to for signature verification
122260
- */
122261
- var computeHash = ts.maybeBind(host, host.createHash);
122262
- var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
122263
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
122879
+ var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
122880
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
122264
122881
  // To ensure that we arent storing any references to old program or new program without state
122265
122882
  newProgram = undefined; // TODO: GH#18217
122266
122883
  oldProgram = undefined;
@@ -122275,6 +122892,7 @@ var ts;
122275
122892
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
122276
122893
  builderProgram.emit = emit;
122277
122894
  builderProgram.releaseProgram = function () { return releaseCache(state); };
122895
+ builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
122278
122896
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
122279
122897
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
122280
122898
  }
@@ -122301,7 +122919,7 @@ var ts;
122301
122919
  * in that order would be used to write the files
122302
122920
  */
122303
122921
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
122304
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122922
+ var affected = getNextAffectedFile(state, cancellationToken, host);
122305
122923
  var emitKind = 1 /* Full */;
122306
122924
  var isPendingEmitFile = false;
122307
122925
  if (!affected) {
@@ -122347,7 +122965,7 @@ var ts;
122347
122965
  var file = sourceFiles[0];
122348
122966
  var info = state.fileInfos.get(file.resolvedPath);
122349
122967
  if (info.signature === file.version) {
122350
- var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
122968
+ var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
122351
122969
  // 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
122352
122970
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
122353
122971
  emitSignature = signature;
@@ -122377,7 +122995,7 @@ var ts;
122377
122995
  if (state.compilerOptions.composite) {
122378
122996
  var filePath = sourceFiles[0].resolvedPath;
122379
122997
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122380
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122998
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
122381
122999
  // Dont write dts files if they didn't change
122382
123000
  if (emitSignature === oldSignature)
122383
123001
  return;
@@ -122387,7 +123005,7 @@ var ts;
122387
123005
  }
122388
123006
  }
122389
123007
  else if (state.compilerOptions.composite) {
122390
- var newSignature = computeSignature(text, computeHash, data);
123008
+ var newSignature = computeSignature(text, host, data);
122391
123009
  // Dont write dts files if they didn't change
122392
123010
  if (newSignature === state.outSignature)
122393
123011
  return;
@@ -122469,7 +123087,7 @@ var ts;
122469
123087
  */
122470
123088
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
122471
123089
  while (true) {
122472
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
123090
+ var affected = getNextAffectedFile(state, cancellationToken, host);
122473
123091
  if (!affected) {
122474
123092
  // Done
122475
123093
  return undefined;
@@ -122549,12 +123167,32 @@ var ts;
122549
123167
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
122550
123168
  }
122551
123169
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
122552
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
122553
- var _a, _b, _c, _d;
122554
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
122555
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
122556
- var state;
123170
+ function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
123171
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
122557
123172
  var filePaths;
123173
+ var fileAbsolutePaths;
123174
+ return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
123175
+ function toPath(path) {
123176
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
123177
+ }
123178
+ function toAbsolutePath(path) {
123179
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
123180
+ }
123181
+ function toFilePath(fileId) {
123182
+ var _a;
123183
+ 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]));
123184
+ }
123185
+ function toFileAbsolutePath(fileId) {
123186
+ var _a;
123187
+ 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]));
123188
+ }
123189
+ }
123190
+ ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
123191
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
123192
+ var _a, _b, _c;
123193
+ var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
123194
+ var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
123195
+ var state;
122558
123196
  var filePathsSetList;
122559
123197
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
122560
123198
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -122563,13 +123201,13 @@ var ts;
122563
123201
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
122564
123202
  latestChangedDtsFile: latestChangedDtsFile,
122565
123203
  outSignature: program.outSignature,
123204
+ resuableCacheResolutions: toResuableCacheResolutions(),
122566
123205
  };
122567
123206
  }
122568
123207
  else {
122569
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
122570
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
123208
+ filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
122571
123209
  var fileInfos_2 = new ts.Map();
122572
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
123210
+ var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
122573
123211
  program.fileInfos.forEach(function (fileInfo, index) {
122574
123212
  var path = toFilePath(index + 1);
122575
123213
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -122577,7 +123215,7 @@ var ts;
122577
123215
  if (emitSignatures_1 && stateFileInfo.signature)
122578
123216
  emitSignatures_1.set(path, stateFileInfo.signature);
122579
123217
  });
122580
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
123218
+ (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
122581
123219
  if (ts.isNumber(value))
122582
123220
  emitSignatures_1.delete(toFilePath(value));
122583
123221
  else
@@ -122596,14 +123234,17 @@ var ts;
122596
123234
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
122597
123235
  latestChangedDtsFile: latestChangedDtsFile,
122598
123236
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
123237
+ resuableCacheResolutions: toResuableCacheResolutions(),
122599
123238
  };
122600
123239
  }
123240
+ state.compilerOptions.configFilePath = configFilePath;
122601
123241
  return {
122602
123242
  getState: function () { return state; },
122603
123243
  saveEmitState: ts.noop,
122604
123244
  restoreEmitState: ts.noop,
122605
123245
  getProgram: ts.notImplemented,
122606
123246
  getProgramOrUndefined: ts.returnUndefined,
123247
+ getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
122607
123248
  releaseProgram: ts.noop,
122608
123249
  getCompilerOptions: function () { return state.compilerOptions; },
122609
123250
  getSourceFile: ts.notImplemented,
@@ -122623,15 +123264,6 @@ var ts;
122623
123264
  close: ts.noop,
122624
123265
  hasChangedEmitSignature: ts.returnFalse,
122625
123266
  };
122626
- function toPath(path) {
122627
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
122628
- }
122629
- function toAbsolutePath(path) {
122630
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
122631
- }
122632
- function toFilePath(fileId) {
122633
- return filePaths[fileId - 1];
122634
- }
122635
123267
  function toFilePathsSet(fileIdsListId) {
122636
123268
  return filePathsSetList[fileIdsListId - 1];
122637
123269
  }
@@ -122646,8 +123278,249 @@ var ts;
122646
123278
  });
122647
123279
  return map;
122648
123280
  }
123281
+ function toResuableCacheResolutions() {
123282
+ return program.cacheResolutions && {
123283
+ cache: program.cacheResolutions,
123284
+ getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
123285
+ };
123286
+ }
122649
123287
  }
122650
123288
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
123289
+ function createGetProgramOrOldBuildInfoProgramUndefined(state) {
123290
+ return function () {
123291
+ var _a;
123292
+ return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
123293
+ (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions,
123294
+ // Prefer cached resolutions over serialized format
123295
+ !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
123296
+ undefined);
123297
+ };
123298
+ }
123299
+ function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
123300
+ if (!cacheResolutions && !resuableCacheResolutions)
123301
+ return undefined;
123302
+ var fileExistsMap = new ts.Map();
123303
+ var packageJsonInfoMap = new ts.Map();
123304
+ var affectingLoationsSameMap = new ts.Map();
123305
+ var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
123306
+ var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
123307
+ var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
123308
+ var decodedPackageJsonMap;
123309
+ var packageJsonScopes;
123310
+ var decodedHashes;
123311
+ var resolutions;
123312
+ var originalPathOrResolvedFileNames;
123313
+ var resolutionEntries;
123314
+ return {
123315
+ getCompilerOptions: function () { return compilerOptions; },
123316
+ 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); },
123317
+ 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,
123318
+ /*moduleNameToDirectoryMap*/ undefined,
123319
+ /*decodedModuleNameToDirectoryMap*/ undefined); },
123320
+ getPackageJsonScope: getPackageJsonScope,
123321
+ };
123322
+ function fileExists(fileName) {
123323
+ var result = fileExistsMap.get(fileName);
123324
+ if (result === undefined)
123325
+ fileExistsMap.set(fileName, result = host.fileExists(fileName));
123326
+ return result;
123327
+ }
123328
+ function getPackageJsonInfo(fileName) {
123329
+ var result = packageJsonInfoMap.get(fileName);
123330
+ if (result === undefined)
123331
+ packageJsonInfoMap.set(fileName, result = host.getPackageJsonInfo(fileName) || false);
123332
+ return result || undefined;
123333
+ }
123334
+ function affectingLocationsSame(fileName, expected) {
123335
+ var _a;
123336
+ var result = affectingLoationsSameMap.get(fileName);
123337
+ if (result !== undefined)
123338
+ return result;
123339
+ var packageJsonInfo = getPackageJsonInfo(fileName);
123340
+ var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
123341
+ if (ts.isString(expected)) {
123342
+ result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
123343
+ }
123344
+ else {
123345
+ var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
123346
+ result = currentText === expectedText;
123347
+ }
123348
+ affectingLoationsSameMap.set(fileName, result);
123349
+ return result;
123350
+ }
123351
+ function getPackageJsonScope(dirPath) {
123352
+ var _a;
123353
+ var fromCache = (_a = cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.dirToPackageJsonScope) === null || _a === void 0 ? void 0 : _a.get(dirPath);
123354
+ if (fromCache) {
123355
+ var packageJson = ts.getPackageJsconLocationFromScope(fromCache);
123356
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(packageJson);
123357
+ if (result === undefined) {
123358
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map())).set(packageJson, result = affectingLocationsSame(packageJson, fromCache.info) ?
123359
+ fromCache :
123360
+ fileExists(packageJson) ?
123361
+ { info: getPackageJsonInfo(packageJson), affectingLocations: [packageJson] } :
123362
+ false);
123363
+ }
123364
+ return result || undefined;
123365
+ }
123366
+ if (!(resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.packageJsons))
123367
+ return;
123368
+ if (!decodedPackageJsonMap) {
123369
+ decodedPackageJsonMap = new ts.Map();
123370
+ var filePathDecoder_1 = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder();
123371
+ for (var _i = 0, _b = resuableCacheResolutions.cache.packageJsons; _i < _b.length; _i++) {
123372
+ var dirIdOrDirAndPackageJson = _b[_i];
123373
+ var dirPath_1 = filePathDecoder_1.toFilePath(dirIdOrDirAndPackageJson[0]);
123374
+ var packageJson = filePathDecoder_1.toFileAbsolutePath(dirIdOrDirAndPackageJson[1]);
123375
+ ts.moduleNameToDirectorySet(decodedPackageJsonMap, dirPath_1, packageJson, ts.identity, function (fileName) { return ts.toPath(fileName, filePathDecoder_1.currentDirectory, filePathDecoder_1.getCanonicalFileName); }, ts.noop);
123376
+ }
123377
+ }
123378
+ return toPackageJsonScope(decodedPackageJsonMap.get(dirPath));
123379
+ }
123380
+ function toPackageJsonScope(file) {
123381
+ if (!file)
123382
+ return undefined;
123383
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(file);
123384
+ if (result !== undefined)
123385
+ return result || undefined;
123386
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map()));
123387
+ if (fileExists(file)) {
123388
+ result = {
123389
+ info: getPackageJsonInfo(file),
123390
+ affectingLocations: [file]
123391
+ };
123392
+ }
123393
+ packageJsonScopes.set(file, result || false);
123394
+ return result;
123395
+ }
123396
+ function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
123397
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
123398
+ // If we are using the cache, directly get from there
123399
+ 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)) ||
123400
+ ((_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));
123401
+ if (fromCache) {
123402
+ return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
123403
+ 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;
123404
+ }
123405
+ if (!reusableCache)
123406
+ return undefined;
123407
+ // Decode so we have maps for directories
123408
+ if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
123409
+ if (ts.isArray(reusableCache)) {
123410
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache, decodedModuleNameToDirectoryMap);
123411
+ }
123412
+ else {
123413
+ if (reusableCache.own)
123414
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, /*optionsKey*/ undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
123415
+ reusableCache.redirects.forEach(function (_a) {
123416
+ var options = _a.options, cache = _a.cache;
123417
+ var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
123418
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
123419
+ });
123420
+ }
123421
+ // Ensure redirected reference verifies options before using redirects map
123422
+ decodedReusableCache.clearRedirectsMap();
123423
+ decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
123424
+ }
123425
+ 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)) ||
123426
+ ((_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));
123427
+ return resolutionId ? toResolution(resolutionId) : undefined;
123428
+ }
123429
+ function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
123430
+ var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
123431
+ reusableCache.forEach(function (_a) {
123432
+ var dirId = _a[0], entryId = _a[1];
123433
+ var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
123434
+ map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
123435
+ });
123436
+ }
123437
+ function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
123438
+ var modeAwareCache = ts.createModeAwareCache();
123439
+ entries.forEach(function (entryId) {
123440
+ var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
123441
+ modeAwareCache.set(name, mode, resolutionId);
123442
+ if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
123443
+ return;
123444
+ var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
123445
+ var key = ts.getModeAwareCacheKey(name, mode);
123446
+ var moduleNameMap = mapForOptions.get(key);
123447
+ ;
123448
+ if (!moduleNameMap)
123449
+ mapForOptions.set(key, moduleNameMap = new ts.Map());
123450
+ ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
123451
+ });
123452
+ return modeAwareCache;
123453
+ }
123454
+ function toResolutionEntry(entryId) {
123455
+ var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
123456
+ if (existing)
123457
+ return existing;
123458
+ resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
123459
+ var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
123460
+ return resolutionEntries[entryId - 1] = [
123461
+ toName(nameId),
123462
+ resolutionId,
123463
+ mode
123464
+ ];
123465
+ }
123466
+ function toName(nameId) {
123467
+ return resuableCacheResolutions.cache.names[nameId - 1];
123468
+ }
123469
+ function toOriginalPathOrResolvedFileName(resolutionId) {
123470
+ var _a;
123471
+ 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 ||
123472
+ resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
123473
+ }
123474
+ function toAffectingFileLocation(fileId) {
123475
+ if (!decodedHashes && resuableCacheResolutions.cache.hash) {
123476
+ decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
123477
+ }
123478
+ var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
123479
+ var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
123480
+ return affectingLocationsSame(file, hash) ? file : undefined;
123481
+ }
123482
+ function toResolution(resolutionId) {
123483
+ var _a, _b;
123484
+ var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
123485
+ if (existing !== undefined)
123486
+ return existing || undefined;
123487
+ resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
123488
+ var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
123489
+ var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
123490
+ var affectingLocations;
123491
+ if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
123492
+ var file = toAffectingFileLocation(fileId);
123493
+ if (file)
123494
+ (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
123495
+ return !!file;
123496
+ })) {
123497
+ // Type Ref doesnt need extension
123498
+ var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
123499
+ return resolutions[resolutionId - 1] = {
123500
+ resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
123501
+ resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
123502
+ failedLookupLocations: ts.emptyArray,
123503
+ affectingLocations: affectingLocations,
123504
+ resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
123505
+ };
123506
+ }
123507
+ resolutions[resolutionId - 1] = false;
123508
+ return undefined;
123509
+ }
123510
+ function toResolved(resolved, resolvedFileName, extension) {
123511
+ if (!resolved)
123512
+ return undefined;
123513
+ return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
123514
+ }
123515
+ function toResolutionDiagnostic(d) {
123516
+ return {
123517
+ isImports: !!d.isImports,
123518
+ entry: d.entry || "",
123519
+ packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
123520
+ };
123521
+ }
123522
+ }
123523
+ ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
122651
123524
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
122652
123525
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
122653
123526
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -122667,6 +123540,7 @@ var ts;
122667
123540
  restoreEmitState: ts.noop,
122668
123541
  getProgram: getProgram,
122669
123542
  getProgramOrUndefined: function () { return getState().program; },
123543
+ getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
122670
123544
  releaseProgram: function () { return getState().program = undefined; },
122671
123545
  getCompilerOptions: function () { return getState().compilerOptions; },
122672
123546
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -122762,15 +123636,57 @@ var ts;
122762
123636
  return true;
122763
123637
  }
122764
123638
  ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
123639
+ function getResolvedModuleOfResolution(resolution) {
123640
+ return resolution.resolvedModule;
123641
+ }
123642
+ ts.getResolvedModuleOfResolution = getResolvedModuleOfResolution;
123643
+ function getResolvedTypeReferenceDirectiveOfResolution(resolution) {
123644
+ return resolution.resolvedTypeReferenceDirective;
123645
+ }
123646
+ ts.getResolvedTypeReferenceDirectiveOfResolution = getResolvedTypeReferenceDirectiveOfResolution;
123647
+ function toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, onRedirectedReferenceKey, forEachResolution, toPath, ancestoryWorker) {
123648
+ if (!(fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()))
123649
+ return perDirCache;
123650
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
123651
+ var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
123652
+ var options = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
123653
+ var key = ts.getRedirectsCacheKey(options);
123654
+ onRedirectedReferenceKey(key);
123655
+ var dirPath = ts.getDirectoryPath(path);
123656
+ var perDirResolutionCache = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
123657
+ var cacheForDir = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
123658
+ fileCacheFromProgram.forEach(function (r, name, mode) {
123659
+ if (forEachResolution(r, name, mode, key, redirectedReference, dirPath))
123660
+ return;
123661
+ if (cacheForDir === null || cacheForDir === void 0 ? void 0 : cacheForDir.has(name, mode))
123662
+ return;
123663
+ if (!cacheForDir) {
123664
+ perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options, key));
123665
+ perDirResolutionCache.set(dirPath, cacheForDir = ts.createModeAwareCache());
123666
+ }
123667
+ cacheForDir.set(name, mode, r);
123668
+ if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
123669
+ return;
123670
+ var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options, key);
123671
+ var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
123672
+ var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
123673
+ if (!directoryPathMap)
123674
+ actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
123675
+ ts.moduleNameToDirectorySet(directoryPathMap, dirPath, r, ts.getResolvedFileNameForModuleNameToDirectorySet, toPath, function (ancestorPath) { return ancestoryWorker(ancestorPath, name, mode, perDirResolutionCache); });
123676
+ });
123677
+ return perDirCache;
123678
+ }
123679
+ ts.toPerDirectoryResolution = toPerDirectoryResolution;
122765
123680
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
122766
123681
  var filesWithChangedSetOfUnresolvedImports;
122767
123682
  var filesWithInvalidatedResolutions;
122768
- var filesWithInvalidatedNonRelativeUnresolvedImports;
122769
- var nonRelativeExternalModuleResolutions = ts.createMultiMap();
122770
123683
  var resolutionsWithFailedLookups = [];
122771
123684
  var resolutionsWithOnlyAffectingLocations = [];
122772
123685
  var resolvedFileToResolution = ts.createMultiMap();
122773
- var impliedFormatPackageJsons = new ts.Map();
123686
+ var perFilePackageJsonScope = new ts.Map();
123687
+ var watchedPackageJsonScopes = [];
123688
+ var packageJsonsToCloseWatcherOn;
123689
+ var resolutionsToCloseWatcherOn;
122774
123690
  var hasChangedAutomaticTypeDirectiveNames = false;
122775
123691
  var affectingPathChecksForFile;
122776
123692
  var affectingPathChecks;
@@ -122779,18 +123695,16 @@ var ts;
122779
123695
  var isInDirectoryChecks;
122780
123696
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217
122781
123697
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
123698
+ var oldModuleAndTypeRefCache;
123699
+ var oldPackageJsonInfoCache;
122782
123700
  // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
122783
123701
  // The key in the map is source file's path.
122784
123702
  // The values are Map of resolutions with key being name lookedup.
122785
123703
  var resolvedModuleNames = new ts.Map();
122786
- var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
122787
- var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
122788
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
122789
- /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
123704
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
122790
123705
  var resolvedTypeReferenceDirectives = new ts.Map();
122791
- var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
122792
123706
  var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName,
122793
- /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
123707
+ /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache());
122794
123708
  /**
122795
123709
  * These are the extensions that failed lookup files will have by default,
122796
123710
  * any other extension of failed lookup will be store that path in custom failed lookup path
@@ -122807,34 +123721,23 @@ var ts;
122807
123721
  // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames
122808
123722
  var typeRootsWatches = new ts.Map();
122809
123723
  return {
123724
+ resolvedModuleNames: resolvedModuleNames,
123725
+ resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
122810
123726
  getModuleResolutionCache: function () { return moduleResolutionCache; },
123727
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
122811
123728
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
122812
123729
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
122813
- // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122814
- // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122815
123730
  startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
122816
123731
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
122817
123732
  resolveModuleNames: resolveModuleNames,
122818
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
122819
123733
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
122820
- removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
122821
- removeResolutionsOfFile: removeResolutionsOfFile,
122822
123734
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
122823
123735
  invalidateResolutionOfFile: invalidateResolutionOfFile,
122824
123736
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
122825
123737
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
122826
123738
  createHasInvalidatedResolution: createHasInvalidatedResolution,
122827
- isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
122828
- updateTypeRootsWatch: updateTypeRootsWatch,
122829
- closeTypeRootsWatch: closeTypeRootsWatch,
122830
123739
  clear: clear
122831
123740
  };
122832
- function getResolvedModule(resolution) {
122833
- return resolution.resolvedModule;
122834
- }
122835
- function getResolvedTypeReferenceDirective(resolution) {
122836
- return resolution.resolvedTypeReferenceDirective;
122837
- }
122838
123741
  function isInDirectoryPath(dir, file) {
122839
123742
  if (dir === undefined || file.length <= dir.length) {
122840
123743
  return false;
@@ -122845,21 +123748,25 @@ var ts;
122845
123748
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
122846
123749
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
122847
123750
  customFailedLookupPaths.clear();
122848
- nonRelativeExternalModuleResolutions.clear();
122849
123751
  closeTypeRootsWatch();
122850
123752
  resolvedModuleNames.clear();
122851
123753
  resolvedTypeReferenceDirectives.clear();
122852
123754
  resolvedFileToResolution.clear();
122853
123755
  resolutionsWithFailedLookups.length = 0;
122854
123756
  resolutionsWithOnlyAffectingLocations.length = 0;
123757
+ watchedPackageJsonScopes.length = 0;
122855
123758
  failedLookupChecks = undefined;
122856
123759
  startsWithPathChecks = undefined;
122857
123760
  isInDirectoryChecks = undefined;
122858
123761
  affectingPathChecks = undefined;
122859
123762
  affectingPathChecksForFile = undefined;
123763
+ resolutionsToCloseWatcherOn = undefined;
123764
+ packageJsonsToCloseWatcherOn = undefined;
123765
+ oldModuleAndTypeRefCache = undefined;
123766
+ oldPackageJsonInfoCache = undefined;
122860
123767
  moduleResolutionCache.clear();
122861
123768
  typeReferenceDirectiveResolutionCache.clear();
122862
- impliedFormatPackageJsons.clear();
123769
+ perFilePackageJsonScope.clear();
122863
123770
  hasChangedAutomaticTypeDirectiveNames = false;
122864
123771
  }
122865
123772
  function startRecordingFilesWithChangedResolutions() {
@@ -122870,14 +123777,6 @@ var ts;
122870
123777
  filesWithChangedSetOfUnresolvedImports = undefined;
122871
123778
  return collected;
122872
123779
  }
122873
- function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
122874
- if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
122875
- return false;
122876
- }
122877
- // Invalidated if file has unresolved imports
122878
- var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
122879
- return !!value && !!value.length;
122880
- }
122881
123780
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
122882
123781
  // Ensure pending resolutions are applied
122883
123782
  invalidateResolutionsOfFailedLookupLocations();
@@ -122888,63 +123787,232 @@ var ts;
122888
123787
  }
122889
123788
  var collected = filesWithInvalidatedResolutions;
122890
123789
  filesWithInvalidatedResolutions = undefined;
122891
- return function (path) { return (!!collected && collected.has(path)) ||
122892
- isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123790
+ return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
122893
123791
  }
122894
123792
  function startCachingPerDirectoryResolution() {
122895
- moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
122896
- typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
122897
- // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
122898
- // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
122899
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122900
- nonRelativeExternalModuleResolutions.clear();
123793
+ var packageJsonInfoCache = moduleResolutionCache.getPackageJsonInfoCache();
123794
+ var internalCache = packageJsonInfoCache.getInternalMap();
123795
+ moduleResolutionCache.clear();
123796
+ typeReferenceDirectiveResolutionCache.clear();
123797
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
123798
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
123799
+ if (oldModuleAndTypeRefCache) {
123800
+ oldModuleAndTypeRefCache.clearRedirectsMap();
123801
+ moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
123802
+ typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
123803
+ }
123804
+ packageJsonInfoCache.setInternalMap(internalCache);
123805
+ packageJsonInfoCache.setOldPackageJsonScopeCache(oldPackageJsonInfoCache);
122901
123806
  }
122902
123807
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
122903
- filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
122904
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
122905
- nonRelativeExternalModuleResolutions.clear();
122906
- // Update file watches
122907
- if (newProgram !== oldProgram) {
122908
- newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
122909
- var _a, _b, _c;
122910
- var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
122911
- var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
122912
- for (var i = existing.length; i < expected; i++) {
122913
- createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
122914
- }
122915
- if (existing.length > expected) {
122916
- for (var i = expected; i < existing.length; i++) {
122917
- fileWatchesOfAffectingLocations.get(existing[i]).files--;
122918
- }
123808
+ hasChangedAutomaticTypeDirectiveNames = false;
123809
+ if (!newProgram) {
123810
+ clear();
123811
+ return;
123812
+ }
123813
+ if (newProgram === oldProgram)
123814
+ return;
123815
+ var needsResolutionUpdate = newProgram.structureIsReused !== 3 /* Completely */;
123816
+ var modules;
123817
+ var typeRefs;
123818
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
123819
+ var dirToPackageJsonScope = new ts.Map();
123820
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
123821
+ var newFile = _a[_i];
123822
+ if (needsResolutionUpdate) {
123823
+ modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, newFile.resolvedModules, newFile, getResolvedModuleOfResolution, modules, moduleNameToDirectoryMap);
123824
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newFile.resolvedTypeReferenceDirectiveNames, newFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs,
123825
+ /*moduleNameToDirectoryMap*/ undefined);
123826
+ }
123827
+ ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope);
123828
+ }
123829
+ if (needsResolutionUpdate) {
123830
+ var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
123831
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs,
123832
+ /*moduleNameToDirectoryMap*/ undefined);
123833
+ if (!modules && !typeRefs) {
123834
+ oldModuleAndTypeRefCache = undefined;
123835
+ }
123836
+ else {
123837
+ oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
123838
+ }
123839
+ // Remove resolutions for files not in the program
123840
+ if (oldProgram) {
123841
+ for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
123842
+ var f = _c[_b];
123843
+ if (!newProgram.getSourceFileByPath(f.path))
123844
+ removeResolutionsOfFile(f.path);
122919
123845
  }
122920
- if (expected)
122921
- impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
122922
- else
122923
- impliedFormatPackageJsons.delete(newFile.path);
122924
- });
122925
- impliedFormatPackageJsons.forEach(function (existing, path) {
122926
- if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
122927
- existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
122928
- impliedFormatPackageJsons.delete(path);
123846
+ var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
123847
+ if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
123848
+ removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
122929
123849
  }
122930
- });
123850
+ }
122931
123851
  }
122932
- directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
122933
- if (watcher.refCount === 0) {
122934
- directoryWatchesOfFailedLookups.delete(path);
122935
- watcher.watcher.close();
123852
+ perFilePackageJsonScope.forEach(function (existing, path) {
123853
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
123854
+ stopWatchingPackageJsonScope(existing, path);
123855
+ perFilePackageJsonScope.delete(path);
122936
123856
  }
122937
123857
  });
123858
+ if (dirToPackageJsonScope.size) {
123859
+ oldPackageJsonInfoCache = getOldPackageJsonInfoCache(dirToPackageJsonScope);
123860
+ }
123861
+ else {
123862
+ oldPackageJsonInfoCache = undefined;
123863
+ }
123864
+ if (needsResolutionUpdate && (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions()))
123865
+ updateTypeRootsWatch();
123866
+ // Remove symlinked watchers that have zero ref count
123867
+ resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
123868
+ resolutionsToCloseWatcherOn = undefined;
123869
+ packageJsonsToCloseWatcherOn === null || packageJsonsToCloseWatcherOn === void 0 ? void 0 : packageJsonsToCloseWatcherOn.forEach(closeWatchersOfPackageJsonScope);
123870
+ packageJsonsToCloseWatcherOn = undefined;
122938
123871
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
122939
123872
  if (watcher.files === 0 && watcher.resolutions === 0) {
122940
123873
  fileWatchesOfAffectingLocations.delete(path);
122941
123874
  watcher.watcher.close();
122942
123875
  }
122943
123876
  });
122944
- hasChangedAutomaticTypeDirectiveNames = false;
122945
123877
  }
122946
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
123878
+ function ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope) {
123879
+ var _a;
123880
+ var existing = perFilePackageJsonScope.get(newFile.path);
123881
+ var scope = ts.isExternalOrCommonJsModule(newFile) ? newFile.packageJsonScope : undefined;
123882
+ if (scope) {
123883
+ ((_a = scope.files) !== null && _a !== void 0 ? _a : (scope.files = new ts.Set())).add(newFile.path);
123884
+ watchPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
123885
+ watchPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
123886
+ perFilePackageJsonScope.set(newFile.path, scope);
123887
+ ts.moduleNameToDirectorySet(dirToPackageJsonScope, ts.getDirectoryPath(newFile.resolvedPath), scope, ts.getPackageJsconLocationFromScope, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
123888
+ }
123889
+ if (existing && scope !== existing)
123890
+ stopWatchingPackageJsonScope(existing, newFile.path);
123891
+ }
123892
+ function stopWatchingPackageJsonScope(scope, path) {
123893
+ var _a, _b;
123894
+ (_a = scope.files) === null || _a === void 0 ? void 0 : _a.delete(path);
123895
+ if (!((_b = scope.files) === null || _b === void 0 ? void 0 : _b.size))
123896
+ (packageJsonsToCloseWatcherOn !== null && packageJsonsToCloseWatcherOn !== void 0 ? packageJsonsToCloseWatcherOn : (packageJsonsToCloseWatcherOn = [])).push(scope);
123897
+ }
123898
+ function watchPackageJsonScopeLocations(scope, locations, field) {
122947
123899
  var _a, _b;
123900
+ var locationsLength = (_a = locations === null || locations === void 0 ? void 0 : locations.length) !== null && _a !== void 0 ? _a : 0;
123901
+ if (!locationsLength || scope[field] === locationsLength)
123902
+ return;
123903
+ if (!scope.watchedFailed && !scope.watchedAffected)
123904
+ watchedPackageJsonScopes.push(scope);
123905
+ for (var i = (_b = scope[field]) !== null && _b !== void 0 ? _b : 0; i < locationsLength; i++) {
123906
+ createFileWatcherOfAffectingLocation(locations[i], /*forResolution*/ false);
123907
+ }
123908
+ scope[field] = locationsLength;
123909
+ }
123910
+ function closeWatchersOfPackageJsonScope(scope) {
123911
+ var _a;
123912
+ // Either in use or already closed, skip
123913
+ if (((_a = scope.files) === null || _a === void 0 ? void 0 : _a.size) || !scope.files)
123914
+ return;
123915
+ scope.files = undefined;
123916
+ ts.unorderedRemoveItem(watchedPackageJsonScopes, scope);
123917
+ stopWatchingPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
123918
+ stopWatchingPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
123919
+ }
123920
+ function stopWatchingPackageJsonScopeLocations(scope, locations, field) {
123921
+ if (!scope[field])
123922
+ return;
123923
+ for (var i = 0; i < scope[field]; i++) {
123924
+ fileWatchesOfAffectingLocations.get(locations[i]).files--;
123925
+ }
123926
+ scope[field] = undefined;
123927
+ }
123928
+ function getOldPackageJsonInfoCache(dirToPackageJsonScope) {
123929
+ var packageJsons;
123930
+ return {
123931
+ getPackageJsonScope: function (dir) {
123932
+ var _a;
123933
+ var scope = dirToPackageJsonScope.get(dir);
123934
+ if (!scope)
123935
+ return undefined;
123936
+ if (!scope.isInvalidated)
123937
+ return scope;
123938
+ if (!resolutionHost.getCompilationSettings().cacheResolutions || !scope.info)
123939
+ return undefined;
123940
+ var packageJson = ts.getPackageJsconLocationFromScope(scope);
123941
+ var result = packageJsons === null || packageJsons === void 0 ? void 0 : packageJsons.get(packageJson);
123942
+ if (result !== undefined)
123943
+ return result || undefined;
123944
+ if (resolutionHost.fileExists(packageJson)) {
123945
+ result = {
123946
+ info: ts.getPackageJsonInfo(ts.getDirectoryPath(packageJson),
123947
+ /*onlyRecordFailures*/ false, ts.getTemporaryModuleResolutionState(moduleResolutionCache.getPackageJsonInfoCache(), ((_a = resolutionHost.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(resolutionHost)) || resolutionHost, resolutionHost.getCompilationSettings())),
123948
+ affectingLocations: [packageJson],
123949
+ };
123950
+ }
123951
+ (packageJsons !== null && packageJsons !== void 0 ? packageJsons : (packageJsons = new ts.Map())).set(packageJson, result || false);
123952
+ return result;
123953
+ }
123954
+ };
123955
+ }
123956
+ function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
123957
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
123958
+ var resolutionsInFile = perFileCache.get(path);
123959
+ var seenNamesInFile = ts.createModeAwareCache();
123960
+ perDirCache = toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, function (key) {
123961
+ // If keys dont match release existing resolutions
123962
+ if (resolutionsInFile && resolutionsInFile.key !== key) {
123963
+ resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
123964
+ resolutionsInFile = undefined;
123965
+ }
123966
+ }, function (r, name, mode, key) {
123967
+ seenNamesInFile.set(name, mode, true);
123968
+ var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
123969
+ if (existing && r !== existing)
123970
+ stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
123971
+ watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
123972
+ if (!resolutionsInFile)
123973
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
123974
+ resolutionsInFile.cache.set(name, mode, r);
123975
+ }, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
123976
+ if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
123977
+ // Stop watching and remove the unused name
123978
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
123979
+ if (!seenNamesInFile.has(name, mode)) {
123980
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
123981
+ resolutionsInFile.cache.delete(name, mode);
123982
+ }
123983
+ });
123984
+ if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
123985
+ perFileCache.delete(path);
123986
+ }
123987
+ return perDirCache;
123988
+ }
123989
+ function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
123990
+ if (!modules && !typeRefs)
123991
+ return undefined;
123992
+ return {
123993
+ modules: {
123994
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
123995
+ },
123996
+ typeRefs: {
123997
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, /*moduleNameToDirectoryMap*/ undefined); }
123998
+ },
123999
+ clearRedirectsMap: function () {
124000
+ modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
124001
+ typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
124002
+ moduleNameToDirectoryMap.clearRedirectsMap();
124003
+ },
124004
+ };
124005
+ }
124006
+ function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
124007
+ var _a, _b, _c, _d;
124008
+ if (!perDirCache)
124009
+ return undefined;
124010
+ 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)) ||
124011
+ ((_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));
124012
+ return result && !result.isInvalidated ? result : undefined;
124013
+ }
124014
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
124015
+ var _a;
122948
124016
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
122949
124017
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
122950
124018
  if (!resolutionHost.getGlobalCache) {
@@ -122955,12 +124023,16 @@ var ts;
122955
124023
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
122956
124024
  // create different collection of failed lookup locations for second pass
122957
124025
  // if it will fail and we've already found something during the first pass - we don't want to pollute its results
122958
- 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;
124026
+ 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;
122959
124027
  if (resolvedModule) {
122960
124028
  // Modify existing resolution so its saved in the directory cache as well
122961
124029
  primaryResult.resolvedModule = resolvedModule;
122962
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
122963
- (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
124030
+ if (!compilerOptions.cacheResolutions)
124031
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
124032
+ else
124033
+ primaryResult.failedLookupLocations.length = 0;
124034
+ primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
124035
+ primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
122964
124036
  return primaryResult;
122965
124037
  }
122966
124038
  }
@@ -122971,76 +124043,41 @@ var ts;
122971
124043
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
122972
124044
  }
122973
124045
  function resolveNamesWithLocalCache(_a) {
122974
- var _b, _c, _d;
122975
- 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;
124046
+ var _b, _c, _d, _e;
124047
+ 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;
122976
124048
  var path = resolutionHost.toPath(containingFile);
122977
- var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
122978
- var dirPath = ts.getDirectoryPath(path);
122979
- var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
122980
- var perDirectoryResolution = perDirectoryCache.get(dirPath);
122981
- if (!perDirectoryResolution) {
122982
- perDirectoryResolution = ts.createModeAwareCache();
122983
- perDirectoryCache.set(dirPath, perDirectoryResolution);
124049
+ var resolutionsInFile = perFileCache.get(path);
124050
+ var compilerOptions = resolutionHost.getCompilationSettings();
124051
+ var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
124052
+ if (!resolutionsInFile || resolutionsInFile.key !== key) {
124053
+ resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
124054
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
122984
124055
  }
122985
124056
  var resolvedModules = [];
122986
- var compilerOptions = resolutionHost.getCompilationSettings();
122987
- var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
122988
- // All the resolutions in this file are invalidated if this file wasn't resolved using same redirect
122989
- var program = resolutionHost.getCurrentProgram();
122990
- var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
122991
- var unmatchedRedirects = oldRedirect ?
122992
- !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
122993
- !!redirectedReference;
122994
124057
  var seenNamesInFile = ts.createModeAwareCache();
122995
124058
  var i = 0;
122996
- for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
122997
- var entry = names_5[_i];
122998
- var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
124059
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
124060
+ var entry = names_4[_i];
124061
+ var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
122999
124062
  // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
123000
124063
  // they require calculating the mode for a given import from it's position in the resolution table, since a given
123001
124064
  // import's syntax may override the file's default mode.
123002
124065
  // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
123003
124066
  // a default file mode override if applicable.
123004
124067
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
123005
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
124068
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
123006
124069
  i++;
123007
- var resolution = resolutionsInFile.get(name, mode);
124070
+ var resolution = resolutionsInFile.cache.get(name, mode);
123008
124071
  // Resolution is valid if it is present and not invalidated
123009
- if (!seenNamesInFile.has(name, mode) &&
123010
- unmatchedRedirects || !resolution || resolution.isInvalidated ||
123011
- // If the name is unresolved import that was invalidated, recalculate
123012
- (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
124072
+ if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
123013
124073
  var existingResolution = resolution;
123014
- var resolutionInDirectory = perDirectoryResolution.get(name, mode);
123015
- if (resolutionInDirectory) {
123016
- resolution = resolutionInDirectory;
123017
- var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
123018
- if (ts.isTraceEnabled(compilerOptions, host)) {
123019
- var resolved = getResolutionWithResolvedFileName(resolution);
123020
- ts.trace(host, loader === resolveModuleName ?
123021
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123022
- resolved.packagetId ?
123023
- 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 :
123024
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
123025
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
123026
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123027
- resolved.packagetId ?
123028
- 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 :
123029
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
123030
- 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));
123031
- }
123032
- }
123033
- else {
123034
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
123035
- perDirectoryResolution.set(name, mode, resolution);
123036
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
123037
- resolutionHost.onDiscoveredSymlink();
123038
- }
124074
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
124075
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
124076
+ resolutionHost.onDiscoveredSymlink();
123039
124077
  }
123040
- resolutionsInFile.set(name, mode, resolution);
123041
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
124078
+ resolutionsInFile.cache.set(name, mode, resolution);
123042
124079
  if (existingResolution) {
123043
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
124080
+ stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
123044
124081
  }
123045
124082
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
123046
124083
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -123054,28 +124091,34 @@ var ts;
123054
124091
  var resolved = getResolutionWithResolvedFileName(resolution);
123055
124092
  ts.trace(host, loader === resolveModuleName ?
123056
124093
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123057
- resolved.packagetId ?
124094
+ resolved.packageId ?
123058
124095
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
123059
124096
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
123060
124097
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
123061
124098
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
123062
- resolved.packagetId ?
124099
+ resolved.packageId ?
123063
124100
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
123064
124101
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
123065
- 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));
124102
+ 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));
123066
124103
  }
123067
124104
  }
123068
124105
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
123069
124106
  seenNamesInFile.set(name, mode, true);
123070
- resolvedModules.push(getResolutionWithResolvedFileName(resolution));
124107
+ resolvedModules.push(resolution);
123071
124108
  }
123072
- // Stop watching and remove the unused name
123073
- resolutionsInFile.forEach(function (resolution, name, mode) {
123074
- if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
123075
- stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
123076
- resolutionsInFile.delete(name, mode);
123077
- }
124109
+ (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
124110
+ var name = _a.name, mode = _a.mode;
124111
+ return seenNamesInFile.set(name, mode, true);
123078
124112
  });
124113
+ if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
124114
+ // Stop watching and remove the unused name
124115
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
124116
+ if (!seenNamesInFile.has(name, mode)) {
124117
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
124118
+ resolutionsInFile.cache.delete(name, mode);
124119
+ }
124120
+ });
124121
+ }
123079
124122
  return resolvedModules;
123080
124123
  function resolutionIsEqualTo(oldResolution, newResolution) {
123081
124124
  if (oldResolution === newResolution) {
@@ -123095,40 +124138,31 @@ var ts;
123095
124138
  return oldResult.resolvedFileName === newResult.resolvedFileName;
123096
124139
  }
123097
124140
  }
123098
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
124141
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
123099
124142
  return resolveNamesWithLocalCache({
123100
124143
  names: typeDirectiveNames,
123101
124144
  containingFile: containingFile,
123102
124145
  redirectedReference: redirectedReference,
123103
- cache: resolvedTypeReferenceDirectives,
123104
- perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
124146
+ perFileCache: resolvedTypeReferenceDirectives,
123105
124147
  loader: resolveTypeReferenceDirective,
123106
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
123107
- shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
123108
- containingSourceFileMode: containingFileMode
124148
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveOfResolution,
124149
+ containingSourceFileMode: containingFileMode,
124150
+ partialResolutionInfo: partialResolutionInfo,
123109
124151
  });
123110
124152
  }
123111
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
124153
+ function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
123112
124154
  return resolveNamesWithLocalCache({
123113
124155
  names: moduleNames,
123114
124156
  containingFile: containingFile,
123115
124157
  redirectedReference: redirectedReference,
123116
- cache: resolvedModuleNames,
123117
- perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
124158
+ perFileCache: resolvedModuleNames,
123118
124159
  loader: resolveModuleName,
123119
- getResolutionWithResolvedFileName: getResolvedModule,
123120
- shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
123121
- reusedNames: reusedNames,
124160
+ getResolutionWithResolvedFileName: getResolvedModuleOfResolution,
124161
+ partialResolutionInfo: partialResolutionInfo,
123122
124162
  logChanges: logChangesWhenResolvingModule,
123123
124163
  containingSourceFile: containingSourceFile,
123124
124164
  });
123125
124165
  }
123126
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
123127
- var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
123128
- if (!cache)
123129
- return undefined;
123130
- return cache.get(moduleName, resolutionMode);
123131
- }
123132
124166
  function isNodeModulesAtTypesDirectory(dirPath) {
123133
124167
  return ts.endsWith(dirPath, "/node_modules/@types");
123134
124168
  }
@@ -123188,37 +124222,42 @@ var ts;
123188
124222
  function isPathWithDefaultFailedLookupExtension(path) {
123189
124223
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
123190
124224
  }
123191
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
123192
- if (resolution.refCount) {
123193
- resolution.refCount++;
123194
- ts.Debug.assertIsDefined(resolution.files);
124225
+ function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
124226
+ if (resolution.files) {
124227
+ resolution.files.add(filePath);
124228
+ if (resolution.watchedFailed !== false)
124229
+ watchFailedLookupLocationOfResolution(resolution);
124230
+ watchAffectingLocationsOfResolution(resolution);
124231
+ return;
124232
+ }
124233
+ resolution.files = new ts.Set();
124234
+ resolution.files.add(filePath);
124235
+ var resolved = getResolutionWithResolvedFileName(resolution);
124236
+ if (resolved && resolved.resolvedFileName) {
124237
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
124238
+ }
124239
+ if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
124240
+ watchFailedLookupLocationOfResolution(resolution);
124241
+ watchAffectingLocationsOfResolution(resolution);
123195
124242
  }
123196
124243
  else {
123197
- resolution.refCount = 1;
123198
- ts.Debug.assert(ts.length(resolution.files) === 0); // This resolution shouldnt be referenced by any file yet
123199
- if (ts.isExternalModuleNameRelative(name)) {
123200
- watchFailedLookupLocationOfResolution(resolution);
123201
- }
123202
- else {
123203
- nonRelativeExternalModuleResolutions.add(name, resolution);
123204
- }
123205
- var resolved = getResolutionWithResolvedFileName(resolution);
123206
- if (resolved && resolved.resolvedFileName) {
123207
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
123208
- }
124244
+ resolution.watchedFailed = false;
124245
+ watchAffectingLocationsOfResolution(resolution);
123209
124246
  }
123210
- (resolution.files || (resolution.files = [])).push(filePath);
123211
124247
  }
123212
124248
  function watchFailedLookupLocationOfResolution(resolution) {
123213
- ts.Debug.assert(!!resolution.refCount);
123214
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
123215
- if (!failedLookupLocations.length && !affectingLocations.length)
124249
+ var failedLookupLocations = resolution.failedLookupLocations;
124250
+ if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
123216
124251
  return;
123217
- if (failedLookupLocations.length)
124252
+ if (!resolution.watchedFailed) {
123218
124253
  resolutionsWithFailedLookups.push(resolution);
123219
- var setAtRoot = false;
123220
- for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
123221
- var failedLookupLocation = failedLookupLocations_1[_i];
124254
+ // Remove resolution from only watching affected locations
124255
+ if (resolution.watchedAffected)
124256
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
124257
+ }
124258
+ var setAtRoot = !!resolution.setAtRoot;
124259
+ for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
124260
+ var failedLookupLocation = failedLookupLocations[i];
123222
124261
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123223
124262
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
123224
124263
  if (toWatch) {
@@ -123238,24 +124277,24 @@ var ts;
123238
124277
  }
123239
124278
  }
123240
124279
  }
123241
- if (setAtRoot) {
124280
+ if (setAtRoot && !resolution.setAtRoot) {
123242
124281
  // This is always non recursive
123243
- setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217
124282
+ setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true);
123244
124283
  }
123245
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
124284
+ resolution.setAtRoot = setAtRoot;
124285
+ resolution.watchedFailed = failedLookupLocations.length;
123246
124286
  }
123247
- function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
123248
- ts.Debug.assert(!!resolution.refCount);
124287
+ function watchAffectingLocationsOfResolution(resolution) {
123249
124288
  var affectingLocations = resolution.affectingLocations;
123250
- if (!affectingLocations.length)
124289
+ if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
123251
124290
  return;
123252
- if (addToResolutionsWithOnlyAffectingLocations)
124291
+ if (!resolution.watchedFailed && !resolution.watchedAffected)
123253
124292
  resolutionsWithOnlyAffectingLocations.push(resolution);
123254
124293
  // Watch package json
123255
- for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
123256
- var affectingLocation = affectingLocations_1[_i];
123257
- createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
124294
+ for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
124295
+ createFileWatcherOfAffectingLocation(affectingLocations[i], /*forResolution*/ true);
123258
124296
  }
124297
+ resolution.watchedAffected = affectingLocations.length;
123259
124298
  }
123260
124299
  function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
123261
124300
  var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
@@ -123315,15 +124354,6 @@ var ts;
123315
124354
  paths.add(affectingLocation);
123316
124355
  }
123317
124356
  }
123318
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
123319
- var program = resolutionHost.getCurrentProgram();
123320
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
123321
- resolutions.forEach(watchFailedLookupLocationOfResolution);
123322
- }
123323
- else {
123324
- resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, /*addToResolutionWithOnlyAffectingLocations*/ true); });
123325
- }
123326
- }
123327
124357
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
123328
124358
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
123329
124359
  if (dirWatcher) {
@@ -123334,21 +124364,28 @@ var ts;
123334
124364
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
123335
124365
  }
123336
124366
  }
123337
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
123338
- ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
123339
- resolution.refCount--;
123340
- if (resolution.refCount) {
124367
+ function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
124368
+ var _a, _b;
124369
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
124370
+ if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
124371
+ (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
124372
+ }
124373
+ function closeWatchersOfResolution(_a) {
124374
+ var _b;
124375
+ var resolution = _a.resolution, getResolved = _a.getResolved;
124376
+ // If some files are using this resolution or we have already closed all watchers ignore
124377
+ if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
123341
124378
  return;
123342
- }
123343
- var resolved = getResolutionWithResolvedFileName(resolution);
124379
+ resolution.files = undefined;
124380
+ var resolved = getResolved(resolution);
123344
124381
  if (resolved && resolved.resolvedFileName) {
123345
124382
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
123346
124383
  }
123347
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
123348
- if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
124384
+ if (resolution.watchedFailed) {
124385
+ ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
123349
124386
  var removeAtRoot = false;
123350
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
123351
- var failedLookupLocation = failedLookupLocations_2[_i];
124387
+ for (var i = 0; i < resolution.watchedFailed; i++) {
124388
+ var failedLookupLocation = resolution.failedLookupLocations[i];
123352
124389
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
123353
124390
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
123354
124391
  if (toWatch) {
@@ -123371,23 +124408,28 @@ var ts;
123371
124408
  }
123372
124409
  }
123373
124410
  }
124411
+ ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
123374
124412
  if (removeAtRoot) {
123375
124413
  removeDirectoryWatcher(rootPath);
123376
124414
  }
123377
124415
  }
123378
- else if (affectingLocations.length) {
124416
+ else if (resolution.watchedAffected) {
123379
124417
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
123380
124418
  }
123381
- for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
123382
- var affectingLocation = affectingLocations_2[_a];
123383
- var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
123384
- watcher.resolutions--;
124419
+ if (resolution.watchedAffected) {
124420
+ for (var i = 0; i < resolution.watchedAffected; i++) {
124421
+ var watcher = fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]);
124422
+ watcher.resolutions--;
124423
+ }
123385
124424
  }
123386
124425
  }
123387
124426
  function removeDirectoryWatcher(dirPath) {
123388
124427
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
123389
- // Do not close the watcher yet since it might be needed by other failed lookup locations.
123390
124428
  dirWatcher.refCount--;
124429
+ if (dirWatcher.refCount === 0) {
124430
+ directoryWatchesOfFailedLookups.delete(dirPath);
124431
+ dirWatcher.watcher.close();
124432
+ }
123391
124433
  }
123392
124434
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
123393
124435
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -123403,28 +124445,16 @@ var ts;
123403
124445
  // Deleted file, stop watching failed lookups for all the resolutions in the file
123404
124446
  var resolutions = cache.get(filePath);
123405
124447
  if (resolutions) {
123406
- resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
124448
+ resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
123407
124449
  cache.delete(filePath);
123408
124450
  }
123409
124451
  }
123410
- function removeResolutionsFromProjectReferenceRedirects(filePath) {
123411
- if (!ts.fileExtensionIs(filePath, ".json" /* Json */))
123412
- return;
123413
- var program = resolutionHost.getCurrentProgram();
123414
- if (!program)
123415
- return;
123416
- // If this file is input file for the referenced project, get it
123417
- var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
123418
- if (!resolvedProjectReference)
123419
- return;
123420
- // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution
123421
- resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
123422
- }
123423
124452
  function removeResolutionsOfFile(filePath) {
123424
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
123425
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
124453
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleOfResolution);
124454
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveOfResolution);
123426
124455
  }
123427
124456
  function invalidateResolutions(resolutions, canInvalidate) {
124457
+ var _a;
123428
124458
  if (!resolutions)
123429
124459
  return false;
123430
124460
  var invalidated = false;
@@ -123433,17 +124463,15 @@ var ts;
123433
124463
  if (resolution.isInvalidated || !canInvalidate(resolution))
123434
124464
  continue;
123435
124465
  resolution.isInvalidated = invalidated = true;
123436
- for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
123437
- var containingFilePath = _b[_a];
124466
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
123438
124467
  (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
123439
124468
  // When its a file with inferred types resolution, invalidate type reference directive resolution
123440
124469
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
123441
- }
124470
+ });
123442
124471
  }
123443
124472
  return invalidated;
123444
124473
  }
123445
124474
  function invalidateResolutionOfFile(filePath) {
123446
- removeResolutionsOfFile(filePath);
123447
124475
  // Resolution is invalidated if the resulting file name is same as the deleted file path
123448
124476
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
123449
124477
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
@@ -123453,8 +124481,28 @@ var ts;
123453
124481
  }
123454
124482
  }
123455
124483
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
123456
- ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
123457
- filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
124484
+ filesMap.forEach(function (_a, filePath) {
124485
+ var imports = _a.imports;
124486
+ if (!imports.length)
124487
+ return;
124488
+ var resolvedModules = resolvedModuleNames.get(filePath);
124489
+ var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
124490
+ if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
124491
+ return;
124492
+ imports.forEach(function (_a) {
124493
+ var name = _a.name, mode = _a.mode;
124494
+ var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
124495
+ if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
124496
+ resolvedModule.isInvalidated = true;
124497
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
124498
+ }
124499
+ var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
124500
+ if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
124501
+ resolvedTypeRef.isInvalidated = true;
124502
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
124503
+ }
124504
+ });
124505
+ });
123458
124506
  }
123459
124507
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
123460
124508
  if (isCreatingWatchedDirectory) {
@@ -123505,12 +124553,17 @@ var ts;
123505
124553
  var _a;
123506
124554
  var invalidated = false;
123507
124555
  if (affectingPathChecksForFile) {
123508
- (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
123509
- if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
123510
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
124556
+ for (var _i = 0, watchedPackageJsonScopes_1 = watchedPackageJsonScopes; _i < watchedPackageJsonScopes_1.length; _i++) {
124557
+ var scope = watchedPackageJsonScopes_1[_i];
124558
+ if (scope.isInvalidated)
124559
+ continue;
124560
+ if (ts.some(scope.failedLookupLocations, function (location) { return affectingPathChecksForFile.has(location); }) ||
124561
+ ts.some(scope.affectingLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
124562
+ scope.isInvalidated = true;
123511
124563
  invalidated = true;
124564
+ (_a = scope.files) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(path); });
123512
124565
  }
123513
- });
124566
+ }
123514
124567
  affectingPathChecksForFile = undefined;
123515
124568
  }
123516
124569
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
@@ -123541,7 +124594,8 @@ var ts;
123541
124594
  ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
123542
124595
  }
123543
124596
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
123544
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
124597
+ var _a;
124598
+ return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) { return affectingPathChecks.has(location); }));
123545
124599
  }
123546
124600
  function closeTypeRootsWatch() {
123547
124601
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -123930,9 +124984,9 @@ var ts;
123930
124984
  if (!preferSymlinks) {
123931
124985
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
123932
124986
  // so we only need to remove them from the realpath filenames.
123933
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
123934
- if (result_16)
123935
- return result_16;
124987
+ var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
124988
+ if (result_17)
124989
+ return result_17;
123936
124990
  }
123937
124991
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
123938
124992
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -123952,10 +125006,10 @@ var ts;
123952
125006
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
123953
125007
  var symlinkDirectory = symlinkDirectories_1[_i];
123954
125008
  var option = ts.resolvePath(symlinkDirectory, relative);
123955
- var result_17 = cb(option, target === referenceRedirect);
125009
+ var result_18 = cb(option, target === referenceRedirect);
123956
125010
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
123957
- if (result_17)
123958
- return result_17;
125011
+ if (result_18)
125012
+ return result_18;
123959
125013
  }
123960
125014
  });
123961
125015
  });
@@ -124021,9 +125075,9 @@ var ts;
124021
125075
  };
124022
125076
  var out_directory_1;
124023
125077
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
124024
- var state_11 = _loop_35(directory);
125078
+ var state_12 = _loop_35(directory);
124025
125079
  directory = out_directory_1;
124026
- if (state_11 === "break")
125080
+ if (state_12 === "break")
124027
125081
  break;
124028
125082
  }
124029
125083
  if (allFileNames.size) {
@@ -124159,9 +125213,9 @@ var ts;
124159
125213
  };
124160
125214
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
124161
125215
  var patternText_1 = _a[_i];
124162
- var state_12 = _loop_36(patternText_1);
124163
- if (typeof state_12 === "object")
124164
- return state_12.value;
125216
+ var state_13 = _loop_36(patternText_1);
125217
+ if (typeof state_13 === "object")
125218
+ return state_13.value;
124165
125219
  }
124166
125220
  }
124167
125221
  function validateEnding(_a) {
@@ -124666,7 +125720,7 @@ var ts;
124666
125720
  }
124667
125721
  ts.explainFiles = explainFiles;
124668
125722
  function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
124669
- var _a;
125723
+ var _a, _b;
124670
125724
  var result;
124671
125725
  if (file.path !== file.resolvedPath) {
124672
125726
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
@@ -124679,19 +125733,19 @@ var ts;
124679
125733
  if (ts.isExternalOrCommonJsModule(file)) {
124680
125734
  switch (file.impliedNodeFormat) {
124681
125735
  case ts.ModuleKind.ESNext:
124682
- if (file.packageJsonScope) {
125736
+ if ((_a = file.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
124683
125737
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124684
- /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
125738
+ /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
124685
125739
  }
124686
125740
  break;
124687
125741
  case ts.ModuleKind.CommonJS:
124688
- if (file.packageJsonScope) {
125742
+ if ((_b = file.packageJsonScope) === null || _b === void 0 ? void 0 : _b.info) {
124689
125743
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124690
- /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
125744
+ /*details*/ undefined, file.packageJsonScope.info.packageJsonContent.type ?
124691
125745
  ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
124692
- ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
125746
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
124693
125747
  }
124694
- else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
125748
+ else if (file.packageJsonScope) {
124695
125749
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
124696
125750
  /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
124697
125751
  }
@@ -125069,7 +126123,8 @@ var ts;
125069
126123
  })(ts || (ts = {}));
125070
126124
  var ts;
125071
126125
  (function (ts) {
125072
- function readBuilderProgram(compilerOptions, host) {
126126
+ /*@internal*/
126127
+ function readBuildInfoForProgram(compilerOptions, host) {
125073
126128
  var _a;
125074
126129
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
125075
126130
  if (!buildInfoPath)
@@ -125088,7 +126143,12 @@ var ts;
125088
126143
  }
125089
126144
  if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
125090
126145
  return undefined;
125091
- return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
126146
+ return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
126147
+ }
126148
+ ts.readBuildInfoForProgram = readBuildInfoForProgram;
126149
+ function readBuilderProgram(compilerOptions, host) {
126150
+ var result = readBuildInfoForProgram(compilerOptions, host);
126151
+ return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
125092
126152
  }
125093
126153
  ts.readBuilderProgram = readBuilderProgram;
125094
126154
  function createIncrementalCompilerHost(options, system) {
@@ -125227,7 +126287,7 @@ var ts;
125227
126287
  }
125228
126288
  return host.resolveModuleNames.apply(host, args);
125229
126289
  }) :
125230
- (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
126290
+ (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
125231
126291
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
125232
126292
  (function () {
125233
126293
  var args = [];
@@ -125236,10 +126296,13 @@ var ts;
125236
126296
  }
125237
126297
  return host.resolveTypeReferenceDirectives.apply(host, args);
125238
126298
  }) :
125239
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
126299
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
125240
126300
  compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
125241
126301
  ts.maybeBind(host, host.getModuleResolutionCache) :
125242
126302
  (function () { return resolutionCache.getModuleResolutionCache(); });
126303
+ compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
126304
+ ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
126305
+ (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
125243
126306
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
125244
126307
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
125245
126308
  synchronizeProgram();
@@ -125342,7 +126405,6 @@ var ts;
125342
126405
  writeLog(" options: " + JSON.stringify(compilerOptions));
125343
126406
  if (projectReferences)
125344
126407
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
125345
- var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
125346
126408
  hasChangedCompilerOptions = false;
125347
126409
  hasChangedConfigFileParsingErrors = false;
125348
126410
  resolutionCache.startCachingPerDirectoryResolution();
@@ -125353,9 +126415,6 @@ var ts;
125353
126415
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
125354
126416
  // Update watches
125355
126417
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
125356
- if (needsUpdateInTypeRootWatch) {
125357
- resolutionCache.updateTypeRootsWatch();
125358
- }
125359
126418
  if (missingFilePathsRequestedForRelease) {
125360
126419
  // These are the paths that program creater told us as not in use any more but were missing on the disk.
125361
126420
  // We didnt remove the entry for them from sourceFiles cache so that we dont have to do File IO,
@@ -125452,7 +126511,7 @@ var ts;
125452
126511
  var hostSourceFile = sourceFilesCache.get(path);
125453
126512
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
125454
126513
  }
125455
- function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
126514
+ function onReleaseOldSourceFile(oldSourceFile) {
125456
126515
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
125457
126516
  // If this is the source file thats in the cache and new program doesnt need it,
125458
126517
  // remove the cached entry.
@@ -125468,9 +126527,6 @@ var ts;
125468
126527
  hostSourceFileInfo.fileWatcher.close();
125469
126528
  }
125470
126529
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
125471
- if (!hasSourceFileByPath) {
125472
- resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
125473
- }
125474
126530
  }
125475
126531
  }
125476
126532
  }
@@ -125727,7 +126783,6 @@ var ts;
125727
126783
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
125728
126784
  if (config)
125729
126785
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
125730
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
125731
126786
  }
125732
126787
  scheduleProgramUpdate();
125733
126788
  });
@@ -125741,7 +126796,6 @@ var ts;
125741
126796
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
125742
126797
  if (config)
125743
126798
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
125744
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
125745
126799
  scheduleProgramUpdate();
125746
126800
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
125747
126801
  // Watch Wild card
@@ -125949,20 +127003,22 @@ var ts;
125949
127003
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
125950
127004
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
125951
127005
  compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
127006
+ compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
125952
127007
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
125953
127008
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
125954
127009
  if (!compilerHost.resolveModuleNames) {
125955
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
125956
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
125957
- return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
127010
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
127011
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
127012
+ return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
125958
127013
  };
125959
127014
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
125960
127015
  }
125961
127016
  if (!compilerHost.resolveTypeReferenceDirectives) {
125962
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
127017
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
125963
127018
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
125964
- return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
127019
+ return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
125965
127020
  };
127021
+ compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
125966
127022
  }
125967
127023
  compilerHost.getBuildInfo = function (fileName, options) { return getBuildInfo(state, fileName, options, toResolvedConfigFilePath(state, options.configFilePath), /*modifiedTime*/ undefined); };
125968
127024
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -126971,7 +128027,7 @@ var ts;
126971
128027
  if (buildInfoTime && buildInfoTime < inputTime) {
126972
128028
  var version_3 = void 0;
126973
128029
  var currentVersion = void 0;
126974
- if (buildInfoProgram) {
128030
+ if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
126975
128031
  // Read files and see if they are same, read is anyways cached
126976
128032
  if (!buildInfoVersionMap)
126977
128033
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);