@typescript-deploys/pr-build 4.8.0-pr-49981-17 → 4.8.0-pr-50007-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.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-insiders.20220721";
72
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220728";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -1484,6 +1484,10 @@ var ts;
1484
1484
  ts.cast = cast;
1485
1485
  function noop(_) { }
1486
1486
  ts.noop = noop;
1487
+ ts.noopPush = {
1488
+ push: noop,
1489
+ length: 0
1490
+ };
1487
1491
  function returnFalse() {
1488
1492
  return false;
1489
1493
  }
@@ -4317,8 +4321,10 @@ var ts;
4317
4321
  watchPresentFileSystemEntry();
4318
4322
  return {
4319
4323
  close: function () {
4320
- watcher.close();
4321
- watcher = undefined;
4324
+ if (watcher) {
4325
+ watcher.close();
4326
+ watcher = undefined;
4327
+ }
4322
4328
  }
4323
4329
  };
4324
4330
  function updateWatcher(createWatcher) {
@@ -5729,6 +5735,7 @@ var ts;
5729
5735
  Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
5730
5736
  auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
5731
5737
  An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
5738
+ Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
5732
5739
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
5733
5740
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
5734
5741
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true),
@@ -5942,6 +5949,7 @@ var ts;
5942
5949
  Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
5943
5950
  Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
5944
5951
  Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
5952
+ A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."),
5945
5953
  Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
5946
5954
  All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
5947
5955
  Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
@@ -6808,6 +6816,7 @@ var ts;
6808
6816
  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."),
6809
6817
  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."),
6810
6818
  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."),
6819
+ 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."),
6811
6820
  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'."),
6812
6821
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
6813
6822
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -10945,7 +10954,8 @@ var ts;
10945
10954
  }
10946
10955
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
10947
10956
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
10948
- return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10957
+ return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
10958
+ optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10949
10959
  }
10950
10960
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
10951
10961
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -11017,21 +11027,20 @@ var ts;
11017
11027
  }
11018
11028
  ts.getFullWidth = getFullWidth;
11019
11029
  function getResolvedModule(sourceFile, moduleNameText, mode) {
11020
- return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
11030
+ var _a, _b;
11031
+ 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;
11021
11032
  }
11022
11033
  ts.getResolvedModule = getResolvedModule;
11023
11034
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
11024
- if (!sourceFile.resolvedModules) {
11025
- sourceFile.resolvedModules = ts.createModeAwareCache();
11026
- }
11035
+ var _a;
11036
+ (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
11027
11037
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
11028
11038
  }
11029
11039
  ts.setResolvedModule = setResolvedModule;
11030
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
11031
- if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
11032
- sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
11033
- }
11034
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, undefined, resolvedTypeReferenceDirective);
11040
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
11041
+ var _a;
11042
+ (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
11043
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
11035
11044
  }
11036
11045
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
11037
11046
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -11041,11 +11050,15 @@ var ts;
11041
11050
  }
11042
11051
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
11043
11052
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
11044
- return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
11045
- oldResolution.extension === newResolution.extension &&
11046
- oldResolution.resolvedFileName === newResolution.resolvedFileName &&
11047
- oldResolution.originalPath === newResolution.originalPath &&
11048
- packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
11053
+ return oldResolution === newResolution ||
11054
+ oldResolution.resolvedModule === newResolution.resolvedModule ||
11055
+ !!oldResolution.resolvedModule &&
11056
+ !!newResolution.resolvedModule &&
11057
+ oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
11058
+ oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
11059
+ oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
11060
+ oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
11061
+ packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
11049
11062
  }
11050
11063
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
11051
11064
  function packageIdIsEqual(a, b) {
@@ -11061,9 +11074,13 @@ var ts;
11061
11074
  }
11062
11075
  ts.packageIdToString = packageIdToString;
11063
11076
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
11064
- return oldResolution.resolvedFileName === newResolution.resolvedFileName
11065
- && oldResolution.primary === newResolution.primary
11066
- && oldResolution.originalPath === newResolution.originalPath;
11077
+ return oldResolution === newResolution ||
11078
+ oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
11079
+ !!oldResolution.resolvedTypeReferenceDirective &&
11080
+ !!newResolution.resolvedTypeReferenceDirective &&
11081
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
11082
+ !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
11083
+ oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
11067
11084
  }
11068
11085
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
11069
11086
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -15262,22 +15279,20 @@ var ts;
15262
15279
  return getStringFromExpandedCharCodes(expandedCharCodes);
15263
15280
  }
15264
15281
  ts.base64decode = base64decode;
15265
- function readJson(path, host) {
15266
- try {
15267
- var jsonText = host.readFile(path);
15268
- if (!jsonText)
15269
- return {};
15270
- var result = ts.parseConfigFileTextToJson(path, jsonText);
15271
- if (result.error) {
15272
- return {};
15273
- }
15274
- return result.config;
15275
- }
15276
- catch (e) {
15282
+ function readJsonIgnoringErrors(path, host) {
15283
+ return readJsonIgnoringErrorsFromText(path, host.readFile(path));
15284
+ }
15285
+ ts.readJsonIgnoringErrors = readJsonIgnoringErrors;
15286
+ function readJsonIgnoringErrorsFromText(path, jsonText) {
15287
+ if (!jsonText)
15288
+ return {};
15289
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
15290
+ if (result.error) {
15277
15291
  return {};
15278
15292
  }
15293
+ return result.config;
15279
15294
  }
15280
- ts.readJson = readJson;
15295
+ ts.readJsonIgnoringErrorsFromText = readJsonIgnoringErrorsFromText;
15281
15296
  function directoryProbablyExists(directoryName, host) {
15282
15297
  return !host.directoryExists || host.directoryExists(directoryName);
15283
15298
  }
@@ -16255,14 +16270,15 @@ var ts;
16255
16270
  },
16256
16271
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
16257
16272
  var _this = this;
16258
- var _a;
16273
+ var _a, _b;
16259
16274
  ts.Debug.assert(!hasProcessedResolutions);
16260
16275
  hasProcessedResolutions = true;
16261
16276
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
16262
16277
  var file = files_1[_i];
16263
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
16278
+ (_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); });
16279
+ (_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); });
16264
16280
  }
16265
- typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
16281
+ typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
16266
16282
  },
16267
16283
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
16268
16284
  };
@@ -26878,7 +26894,9 @@ var ts;
26878
26894
  case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26879
26895
  case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26880
26896
  case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
26881
- default: return [undefined];
26897
+ case 24: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected);
26898
+ case 25: return ts.Debug.fail("ParsingContext.Count used as a context");
26899
+ default: ts.Debug.assertNever(context);
26882
26900
  }
26883
26901
  }
26884
26902
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
@@ -27224,7 +27242,7 @@ var ts;
27224
27242
  if (allowAmbiguity === void 0) { allowAmbiguity = true; }
27225
27243
  var pos = getNodePos();
27226
27244
  var hasJSDoc = hasPrecedingJSDocComment();
27227
- var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
27245
+ var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators);
27228
27246
  if (token() === 108) {
27229
27247
  var node_1 = factory.createParameterDeclaration(decorators, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
27230
27248
  if (decorators) {
@@ -32167,6 +32185,17 @@ var ts;
32167
32185
  transpileOptionValue: undefined,
32168
32186
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
32169
32187
  },
32188
+ {
32189
+ name: "cacheResolutions",
32190
+ type: "boolean",
32191
+ category: ts.Diagnostics.Projects,
32192
+ description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
32193
+ affectsModuleResolution: true,
32194
+ affectsMultiFileEmitBuildInfo: true,
32195
+ affectsBundleEmitBuildInfo: true,
32196
+ transpileOptionValue: undefined,
32197
+ defaultValueDescription: false,
32198
+ },
32170
32199
  {
32171
32200
  name: "assumeChangesOnlyAffectDirectDependencies",
32172
32201
  type: "boolean",
@@ -34123,6 +34152,9 @@ var ts;
34123
34152
  if (result.configFilePath) {
34124
34153
  result.configFilePath = toAbsolutePath(result.configFilePath);
34125
34154
  }
34155
+ if (result.pathsBasePath) {
34156
+ result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
34157
+ }
34126
34158
  return result;
34127
34159
  }
34128
34160
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -34948,20 +34980,35 @@ var ts;
34948
34980
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
34949
34981
  return { fileName: resolved.path, packageId: resolved.packageId };
34950
34982
  }
34951
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
34952
- var _a, _b;
34983
+ function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
34984
+ var _a;
34985
+ var _b;
34953
34986
  if (resultFromCache) {
34954
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
34955
- (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
34987
+ if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
34988
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
34989
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
34990
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
34956
34991
  return resultFromCache;
34957
34992
  }
34958
34993
  return {
34959
34994
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
34960
- failedLookupLocations: failedLookupLocations,
34961
- affectingLocations: affectingLocations,
34962
- resolutionDiagnostics: diagnostics,
34995
+ failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
34996
+ affectingLocations: initializeResolutionField(affectingLocations),
34997
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
34963
34998
  };
34964
34999
  }
35000
+ function initializeResolutionField(value) {
35001
+ return value.length ? value : undefined;
35002
+ }
35003
+ function updateResolutionField(to, value) {
35004
+ if (!(value === null || value === void 0 ? void 0 : value.length))
35005
+ return to;
35006
+ if (!(to === null || to === void 0 ? void 0 : to.length))
35007
+ return value;
35008
+ to.push.apply(to, value);
35009
+ return to;
35010
+ }
35011
+ ts.updateResolutionField = updateResolutionField;
34965
35012
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
34966
35013
  if (!ts.hasProperty(jsonContent, fieldName)) {
34967
35014
  if (state.traceEnabled) {
@@ -35100,8 +35147,7 @@ var ts;
35100
35147
  options = redirectedReference.commandLine.options;
35101
35148
  }
35102
35149
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
35103
- var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
35104
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35150
+ var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, resolutionMode, redirectedReference) : undefined;
35105
35151
  if (result) {
35106
35152
  if (traceEnabled) {
35107
35153
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35152,7 +35198,7 @@ var ts;
35152
35198
  features: features,
35153
35199
  conditions: conditions,
35154
35200
  requestContainingDirectory: containingDirectory,
35155
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35201
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35156
35202
  };
35157
35203
  var resolved = primaryLookup();
35158
35204
  var primary = true;
@@ -35172,8 +35218,15 @@ var ts;
35172
35218
  isExternalLibraryImport: pathContainsNodeModules(fileName),
35173
35219
  };
35174
35220
  }
35175
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
35176
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35221
+ result = {
35222
+ resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
35223
+ failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
35224
+ affectingLocations: initializeResolutionField(affectingLocations),
35225
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
35226
+ };
35227
+ if (containingDirectory && cache) {
35228
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35229
+ }
35177
35230
  if (traceEnabled)
35178
35231
  traceResult(result);
35179
35232
  return result;
@@ -35183,10 +35236,10 @@ var ts;
35183
35236
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
35184
35237
  }
35185
35238
  else if (result.resolvedTypeReferenceDirective.packageId) {
35186
- 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);
35239
+ 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);
35187
35240
  }
35188
35241
  else {
35189
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
35242
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
35190
35243
  }
35191
35244
  }
35192
35245
  function primaryLookup() {
@@ -35241,18 +35294,7 @@ var ts;
35241
35294
  NodeResolutionFeatures.None;
35242
35295
  }
35243
35296
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
35244
- var moduleResolutionState = {
35245
- compilerOptions: options,
35246
- host: host,
35247
- traceEnabled: isTraceEnabled(options, host),
35248
- failedLookupLocations: [],
35249
- affectingLocations: [],
35250
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
35251
- conditions: ts.emptyArray,
35252
- features: NodeResolutionFeatures.None,
35253
- requestContainingDirectory: containingDirectory,
35254
- reportDiagnostic: ts.noop
35255
- };
35297
+ var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
35256
35298
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
35257
35299
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
35258
35300
  var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
@@ -35277,7 +35319,7 @@ var ts;
35277
35319
  var typeDirectivePath = _b[_a];
35278
35320
  var normalized = ts.normalizePath(typeDirectivePath);
35279
35321
  var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
35280
- var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
35322
+ var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJsonIgnoringErrors(packageJsonPath, host).typings === null;
35281
35323
  if (!isNotNeededPackage) {
35282
35324
  var baseFileName = ts.getBaseFileName(normalized);
35283
35325
  if (baseFileName.charCodeAt(0) !== 46) {
@@ -35292,47 +35334,138 @@ var ts;
35292
35334
  return result;
35293
35335
  }
35294
35336
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
35295
- function createCacheWithRedirects(options) {
35296
- var ownMap = new ts.Map();
35337
+ function compilerOptionValueToString(value) {
35338
+ var _a;
35339
+ if (value === null || typeof value !== "object") {
35340
+ return "" + value;
35341
+ }
35342
+ if (ts.isArray(value)) {
35343
+ return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
35344
+ }
35345
+ var str = "{";
35346
+ for (var key in value) {
35347
+ if (ts.hasProperty(value, key)) {
35348
+ str += key + ": " + compilerOptionValueToString(value[key]);
35349
+ }
35350
+ }
35351
+ return str + "}";
35352
+ }
35353
+ function getKeyForCompilationSettings(settings, options) {
35354
+ return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
35355
+ }
35356
+ ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
35357
+ function getRedirectsCacheKey(options) {
35358
+ return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
35359
+ }
35360
+ ts.getRedirectsCacheKey = getRedirectsCacheKey;
35361
+ function createCacheWithRedirects(ownOptions) {
35362
+ var ownMap;
35363
+ var ownKey;
35364
+ var redirectsKeyToCache = new ts.Map();
35297
35365
  var redirectsMap = new ts.Map();
35298
35366
  return {
35299
35367
  getOwnMap: getOwnMap,
35300
- redirectsMap: redirectsMap,
35368
+ redirectsKeyToCache: redirectsKeyToCache,
35369
+ createMapForCompilerOptions: createMapForCompilerOptions,
35370
+ getMapOfCacheRedirects: getMapOfCacheRedirects,
35301
35371
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
35302
35372
  clear: clear,
35303
- setOwnOptions: setOwnOptions,
35304
- setOwnMap: setOwnMap
35373
+ update: update,
35374
+ clearRedirectsMap: function () { return redirectsMap.clear(); },
35305
35375
  };
35306
- function getOwnMap() {
35307
- return ownMap;
35376
+ function ensureOwnKeyCached() {
35377
+ ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
35378
+ if (ownKey && !redirectsKeyToCache.has(ownKey))
35379
+ redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
35308
35380
  }
35309
- function setOwnOptions(newOptions) {
35310
- options = newOptions;
35381
+ function createMapForCompilerOptions(options, optionsKey) {
35382
+ if (options === ownOptions)
35383
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35384
+ return getOrCreateRedirectMapAndKey(options, undefined, optionsKey);
35311
35385
  }
35312
- function setOwnMap(newOwnMap) {
35313
- ownMap = newOwnMap;
35386
+ function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
35387
+ var _a;
35388
+ if (path || options.configFile) {
35389
+ var redirects = redirectsMap.get(path || options.configFile.path);
35390
+ if (redirects)
35391
+ return redirects;
35392
+ }
35393
+ var key = optionsKey || getRedirectsCacheKey(options);
35394
+ var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
35395
+ if (!map) {
35396
+ ensureOwnKeyCached();
35397
+ if (ownKey === key) {
35398
+ map = ownMap;
35399
+ }
35400
+ else {
35401
+ redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
35402
+ }
35403
+ }
35404
+ if (path || options.configFile)
35405
+ redirectsMap.set(path || options.configFile.path, map);
35406
+ return map;
35314
35407
  }
35315
- function getOrCreateMapOfCacheRedirects(redirectedReference) {
35316
- if (!redirectedReference) {
35317
- return ownMap;
35408
+ function getOwnMap() {
35409
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35410
+ }
35411
+ function update(newOwnOptions) {
35412
+ if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
35413
+ ensureOwnKeyCached();
35414
+ if (!redirectsMap.has(ownOptions.configFile.path)) {
35415
+ redirectsMap.set(ownOptions.configFile.path, ownMap);
35416
+ }
35318
35417
  }
35319
- var path = redirectedReference.sourceFile.path;
35320
- var redirects = redirectsMap.get(path);
35321
- if (!redirects) {
35322
- redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
35323
- redirectsMap.set(path, redirects);
35418
+ if (newOwnOptions.configFile) {
35419
+ var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
35420
+ if (existing_1) {
35421
+ ownMap = existing_1;
35422
+ ownOptions = newOwnOptions;
35423
+ return;
35424
+ }
35425
+ }
35426
+ var key = getRedirectsCacheKey(newOwnOptions);
35427
+ var existing = redirectsKeyToCache.get(key);
35428
+ ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
35429
+ ownKey = key;
35430
+ ownOptions = newOwnOptions;
35431
+ if (newOwnOptions.configFile)
35432
+ redirectsMap.set(newOwnOptions.configFile.path, ownMap);
35433
+ }
35434
+ function getMapOfCacheRedirects(redirectedReference) {
35435
+ if (!redirectedReference)
35436
+ return ownMap;
35437
+ var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
35438
+ if (directResult)
35439
+ return directResult;
35440
+ var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
35441
+ var fromKey = redirectsKeyToCache.get(key);
35442
+ if (fromKey) {
35443
+ redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
35444
+ return fromKey.map;
35445
+ }
35446
+ if (ownMap)
35447
+ ensureOwnKeyCached();
35448
+ if (ownKey === key) {
35449
+ redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
35450
+ return ownMap;
35324
35451
  }
35325
- return redirects;
35452
+ return undefined;
35453
+ }
35454
+ function getOrCreateMapOfCacheRedirects(redirectedReference) {
35455
+ return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
35456
+ getOwnMap() :
35457
+ getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, undefined);
35326
35458
  }
35327
35459
  function clear() {
35328
- ownMap.clear();
35460
+ ownKey = undefined;
35461
+ ownMap = undefined;
35329
35462
  redirectsMap.clear();
35463
+ redirectsKeyToCache.clear();
35330
35464
  }
35331
35465
  }
35332
35466
  ts.createCacheWithRedirects = createCacheWithRedirects;
35333
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35334
- var cache;
35335
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
35467
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
35468
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, clone: clone };
35336
35469
  function getPackageJsonInfo(packageJsonPath) {
35337
35470
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35338
35471
  }
@@ -35346,6 +35479,9 @@ var ts;
35346
35479
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35347
35480
  return iter ? ts.arrayFrom(iter) : [];
35348
35481
  }
35482
+ function clone() {
35483
+ return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
35484
+ }
35349
35485
  }
35350
35486
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
35351
35487
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -35356,45 +35492,42 @@ var ts;
35356
35492
  }
35357
35493
  return result;
35358
35494
  }
35359
- function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35360
- if (!options.configFile)
35361
- return;
35362
- if (directoryToModuleNameMap.redirectsMap.size === 0) {
35363
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35364
- ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35365
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35366
- directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35367
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35368
- }
35369
- else {
35370
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35371
- var ref = {
35372
- sourceFile: options.configFile,
35373
- commandLine: { options: options }
35374
- };
35375
- directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35376
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35377
- }
35378
- directoryToModuleNameMap.setOwnOptions(options);
35379
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35380
- }
35381
35495
  function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35496
+ var oldResolutionCache;
35382
35497
  return {
35498
+ getFromCache: getFromCache,
35383
35499
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
35384
35500
  clear: clear,
35385
35501
  update: update,
35502
+ setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
35386
35503
  };
35387
35504
  function clear() {
35505
+ oldResolutionCache = undefined;
35388
35506
  directoryToModuleNameMap.clear();
35389
35507
  }
35390
35508
  function update(options) {
35391
- updateRedirectsMap(options, directoryToModuleNameMap);
35509
+ directoryToModuleNameMap.update(options);
35392
35510
  }
35393
35511
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35394
35512
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35395
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
35513
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
35514
+ }
35515
+ function getFromCache(directoryName, name, mode, redirectedReference) {
35516
+ var _a, _b;
35517
+ var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35518
+ 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);
35519
+ if (result)
35520
+ return result;
35521
+ var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
35522
+ if (resultFromOld)
35523
+ getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
35524
+ return resultFromOld;
35396
35525
  }
35397
35526
  }
35527
+ function getModeAwareCacheKey(specifier, mode) {
35528
+ return (mode === undefined ? specifier : mode + "|" + specifier);
35529
+ }
35530
+ ts.getModeAwareCacheKey = getModeAwareCacheKey;
35398
35531
  function createModeAwareCache() {
35399
35532
  var underlying = new ts.Map();
35400
35533
  var memoizedReverseKeys = new ts.Map();
@@ -35419,13 +35552,22 @@ var ts;
35419
35552
  return cb(elem, specifier, mode);
35420
35553
  });
35421
35554
  },
35555
+ entries: function () {
35556
+ var keys = underlying.entries();
35557
+ return {
35558
+ next: function () {
35559
+ var next = keys.next();
35560
+ return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
35561
+ },
35562
+ };
35563
+ },
35422
35564
  size: function () {
35423
35565
  return underlying.size;
35424
- }
35566
+ },
35425
35567
  };
35426
35568
  return cache;
35427
35569
  function getUnderlyingCacheKey(specifier, mode) {
35428
- var result = mode === undefined ? specifier : mode + "|" + specifier;
35570
+ var result = getModeAwareCacheKey(specifier, mode);
35429
35571
  memoizedReverseKeys.set(result, [specifier, mode]);
35430
35572
  return result;
35431
35573
  }
@@ -35436,80 +35578,113 @@ var ts;
35436
35578
  var map = createModeAwareCache();
35437
35579
  for (var i = 0; i < keys.length; ++i) {
35438
35580
  var entry = keys[i];
35439
- var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
35581
+ var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
35440
35582
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
35441
35583
  map.set(name, mode, values[i]);
35442
35584
  }
35443
35585
  return map;
35444
35586
  }
35445
35587
  ts.zipToModeAwareCache = zipToModeAwareCache;
35446
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35447
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35448
- moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35588
+ function getCommonPrefix(directory, resolution, toPath) {
35589
+ var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
35590
+ var i = 0;
35591
+ var limit = Math.min(directory.length, resolutionDirectory.length);
35592
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35593
+ i++;
35594
+ }
35595
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35596
+ return directory;
35597
+ }
35598
+ var rootLength = ts.getRootLength(directory);
35599
+ if (i < rootLength) {
35600
+ return undefined;
35601
+ }
35602
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35603
+ if (sep === -1) {
35604
+ return undefined;
35605
+ }
35606
+ return directory.substr(0, Math.max(sep, rootLength));
35607
+ }
35608
+ function getResolvedFileNameForModuleNameToDirectorySet(result) {
35609
+ return result.resolvedModule &&
35610
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35611
+ }
35612
+ ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
35613
+ function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
35614
+ if (directoryPathMap.has(directory))
35615
+ return;
35616
+ directoryPathMap.set(directory, result);
35617
+ var resolvedFileName = getResolvedFileName(result);
35618
+ var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
35619
+ var current = directory;
35620
+ while (current !== commonPrefix) {
35621
+ var parent = ts.getDirectoryPath(current);
35622
+ if (parent === current)
35623
+ break;
35624
+ if (directoryPathMap.has(parent)) {
35625
+ ancestoryWorker(parent);
35626
+ break;
35627
+ }
35628
+ directoryPathMap.set(parent, result);
35629
+ ancestoryWorker(parent);
35630
+ current = parent;
35631
+ }
35632
+ }
35633
+ ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
35634
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35635
+ var directoryToModuleNameMap = createCacheWithRedirects(options);
35636
+ var moduleNameToDirectoryMap = createCacheWithRedirects(options);
35637
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35449
35638
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35450
- return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
35639
+ var oldResolutionCache;
35640
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
35451
35641
  function clear() {
35452
- preDirectoryResolutionCache.clear();
35642
+ oldResolutionCache = undefined;
35643
+ perDirectoryResolutionCache.clear();
35453
35644
  moduleNameToDirectoryMap.clear();
35454
35645
  packageJsonInfoCache.clear();
35455
35646
  }
35456
35647
  function update(options) {
35457
- updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35648
+ directoryToModuleNameMap.update(options);
35649
+ moduleNameToDirectoryMap.update(options);
35650
+ }
35651
+ function setOldResolutionCache(cache) {
35652
+ oldResolutionCache = cache;
35653
+ perDirectoryResolutionCache.setOldResolutionCache(cache);
35654
+ }
35655
+ function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
35656
+ var _a, _b;
35657
+ ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35658
+ 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);
35659
+ if (result)
35660
+ return result;
35661
+ var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
35662
+ if (fromOld)
35663
+ getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
35664
+ return fromOld;
35458
35665
  }
35459
35666
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35460
35667
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35461
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
35668
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35462
35669
  }
35463
35670
  function createPerModuleNameCache() {
35464
35671
  var directoryPathMap = new ts.Map();
35465
35672
  return { get: get, set: set };
35466
35673
  function get(directory) {
35467
- return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
35674
+ return directoryPathMap.get(toPath(directory));
35468
35675
  }
35469
35676
  function set(directory, result) {
35470
- var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
35471
- if (directoryPathMap.has(path)) {
35472
- return;
35473
- }
35474
- directoryPathMap.set(path, result);
35475
- var resolvedFileName = result.resolvedModule &&
35476
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35477
- var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35478
- var current = path;
35479
- while (current !== commonPrefix) {
35480
- var parent = ts.getDirectoryPath(current);
35481
- if (parent === current || directoryPathMap.has(parent)) {
35482
- break;
35483
- }
35484
- directoryPathMap.set(parent, result);
35485
- current = parent;
35486
- }
35487
- }
35488
- function getCommonPrefix(directory, resolution) {
35489
- var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
35490
- var i = 0;
35491
- var limit = Math.min(directory.length, resolutionDirectory.length);
35492
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35493
- i++;
35494
- }
35495
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35496
- return directory;
35497
- }
35498
- var rootLength = ts.getRootLength(directory);
35499
- if (i < rootLength) {
35500
- return undefined;
35501
- }
35502
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35503
- if (sep === -1) {
35504
- return undefined;
35505
- }
35506
- return directory.substr(0, Math.max(sep, rootLength));
35677
+ return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
35507
35678
  }
35508
35679
  }
35680
+ function toPath(fileName) {
35681
+ return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
35682
+ }
35509
35683
  }
35510
35684
  ts.createModuleResolutionCache = createModuleResolutionCache;
35511
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35512
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35685
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35686
+ var directoryToModuleNameMap = createCacheWithRedirects(options);
35687
+ var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35513
35688
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35514
35689
  return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
35515
35690
  function clear() {
@@ -35520,10 +35695,7 @@ var ts;
35520
35695
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35521
35696
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35522
35697
  var containingDirectory = ts.getDirectoryPath(containingFile);
35523
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35524
- if (!perFolderCache)
35525
- return undefined;
35526
- return perFolderCache.get(moduleName, mode);
35698
+ return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
35527
35699
  }
35528
35700
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
35529
35701
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -35538,8 +35710,7 @@ var ts;
35538
35710
  }
35539
35711
  }
35540
35712
  var containingDirectory = ts.getDirectoryPath(containingFile);
35541
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35542
- var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35713
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
35543
35714
  if (result) {
35544
35715
  if (traceEnabled) {
35545
35716
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -35591,8 +35762,8 @@ var ts;
35591
35762
  if (result && result.resolvedModule)
35592
35763
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
35593
35764
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
35594
- if (perFolderCache) {
35595
- perFolderCache.set(moduleName, resolutionMode, result);
35765
+ if (cache) {
35766
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35596
35767
  if (!ts.isExternalModuleNameRelative(moduleName)) {
35597
35768
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35598
35769
  }
@@ -35796,10 +35967,10 @@ var ts;
35796
35967
  features: features,
35797
35968
  conditions: conditions,
35798
35969
  requestContainingDirectory: containingDirectory,
35799
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35970
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35800
35971
  };
35801
35972
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
35802
- 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);
35973
+ 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);
35803
35974
  function tryResolve(extensions) {
35804
35975
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
35805
35976
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -36052,18 +36223,9 @@ var ts;
36052
36223
  var entrypoints;
36053
36224
  var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
36054
36225
  var features = getDefaultNodeResolutionFeatures(options);
36055
- var requireState = {
36056
- compilerOptions: options,
36057
- host: host,
36058
- traceEnabled: isTraceEnabled(options, host),
36059
- failedLookupLocations: [],
36060
- affectingLocations: [],
36061
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
36062
- conditions: ["node", "require", "types"],
36063
- features: features,
36064
- requestContainingDirectory: packageJsonInfo.packageDirectory,
36065
- reportDiagnostic: ts.noop
36066
- };
36226
+ var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
36227
+ requireState.conditions = ["node", "require", "types"];
36228
+ requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
36067
36229
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
36068
36230
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
36069
36231
  if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
@@ -36133,19 +36295,22 @@ var ts;
36133
36295
  }
36134
36296
  }
36135
36297
  }
36136
- function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
36137
- var state = {
36298
+ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
36299
+ return {
36138
36300
  host: host,
36139
36301
  compilerOptions: options,
36140
36302
  traceEnabled: isTraceEnabled(options, host),
36141
- failedLookupLocations: [],
36142
- affectingLocations: [],
36303
+ failedLookupLocations: ts.noopPush,
36304
+ affectingLocations: ts.noopPush,
36143
36305
  packageJsonInfoCache: packageJsonInfoCache,
36144
- features: 0,
36145
- conditions: [],
36306
+ features: NodeResolutionFeatures.None,
36307
+ conditions: ts.emptyArray,
36146
36308
  requestContainingDirectory: undefined,
36147
- reportDiagnostic: ts.noop
36309
+ reportResolutionDiagnostic: ts.noop
36148
36310
  };
36311
+ }
36312
+ ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
36313
+ function getPackageScopeForPath(fileName, state) {
36149
36314
  var parts = ts.getPathComponents(fileName);
36150
36315
  parts.pop();
36151
36316
  while (parts.length > 0) {
@@ -36183,12 +36348,13 @@ var ts;
36183
36348
  }
36184
36349
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
36185
36350
  if (directoryExists && host.fileExists(packageJsonPath)) {
36186
- var packageJsonContent = ts.readJson(packageJsonPath, host);
36351
+ var packageJsonText = host.readFile(packageJsonPath);
36352
+ var packageJsonContent = ts.readJsonIgnoringErrorsFromText(packageJsonPath, packageJsonText);
36187
36353
  if (traceEnabled) {
36188
36354
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
36189
36355
  }
36190
36356
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
36191
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36357
+ var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36192
36358
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
36193
36359
  state.affectingLocations.push(packageJsonPath);
36194
36360
  return result;
@@ -36302,7 +36468,7 @@ var ts;
36302
36468
  var _a, _b;
36303
36469
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36304
36470
  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));
36305
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
36471
+ var scope = getPackageScopeForPath(directoryPath, state);
36306
36472
  if (!scope || !scope.packageJsonContent.exports) {
36307
36473
  return undefined;
36308
36474
  }
@@ -36361,7 +36527,7 @@ var ts;
36361
36527
  }
36362
36528
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36363
36529
  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));
36364
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
36530
+ var scope = getPackageScopeForPath(directoryPath, state);
36365
36531
  if (!scope) {
36366
36532
  if (state.traceEnabled) {
36367
36533
  trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
@@ -36560,11 +36726,8 @@ var ts;
36560
36726
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
36561
36727
  }
36562
36728
  }
36563
- if (commonSourceDirGuesses.length > 1) {
36564
- state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
36565
- ? 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
36566
- : 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, packagePath));
36567
- }
36729
+ if (commonSourceDirGuesses.length > 1)
36730
+ state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
36568
36731
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
36569
36732
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
36570
36733
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -36629,10 +36792,10 @@ var ts;
36629
36792
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
36630
36793
  }
36631
36794
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
36632
- var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
36795
+ var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
36633
36796
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
36634
36797
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
36635
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
36798
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36636
36799
  if (resolutionFromCache) {
36637
36800
  return resolutionFromCache;
36638
36801
  }
@@ -36769,8 +36932,8 @@ var ts;
36769
36932
  typesPackageName;
36770
36933
  }
36771
36934
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
36772
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36773
- var result = cache && cache.get(containingDirectory);
36935
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
36936
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
36774
36937
  if (result) {
36775
36938
  if (state.traceEnabled) {
36776
36939
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36795,19 +36958,18 @@ var ts;
36795
36958
  features: NodeResolutionFeatures.None,
36796
36959
  conditions: [],
36797
36960
  requestContainingDirectory: containingDirectory,
36798
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
36961
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36799
36962
  };
36800
36963
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
36801
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36964
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36802
36965
  function tryResolve(extensions) {
36803
36966
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
36804
36967
  if (resolvedUsingSettings) {
36805
36968
  return { value: resolvedUsingSettings };
36806
36969
  }
36807
36970
  if (!ts.isExternalModuleNameRelative(moduleName)) {
36808
- var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, undefined, redirectedReference);
36809
36971
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
36810
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
36972
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, undefined, directory, redirectedReference, state);
36811
36973
  if (resolutionFromCache) {
36812
36974
  return resolutionFromCache;
36813
36975
  }
@@ -36846,10 +37008,10 @@ var ts;
36846
37008
  features: NodeResolutionFeatures.None,
36847
37009
  conditions: [],
36848
37010
  requestContainingDirectory: undefined,
36849
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37011
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36850
37012
  };
36851
37013
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
36852
- return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37014
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36853
37015
  }
36854
37016
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
36855
37017
  function toSearchResult(value) {
@@ -39842,9 +40004,10 @@ var ts;
39842
40004
  host.getSourceFiles().forEach(function (sf) {
39843
40005
  if (!sf.resolvedModules)
39844
40006
  return;
39845
- sf.resolvedModules.forEach(function (r) {
39846
- if (r && r.packageId)
39847
- map.set(r.packageId.name, r.extension === ".d.ts" || !!map.get(r.packageId.name));
40007
+ sf.resolvedModules.forEach(function (_a) {
40008
+ var resolvedModule = _a.resolvedModule;
40009
+ if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
40010
+ map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" || !!map.get(resolvedModule.packageId.name));
39848
40011
  });
39849
40012
  });
39850
40013
  return map;
@@ -49224,7 +49387,7 @@ var ts;
49224
49387
  }
49225
49388
  }
49226
49389
  }
49227
- return getIntersectionType(constraints);
49390
+ return getNormalizedType(getIntersectionType(constraints), false);
49228
49391
  }
49229
49392
  return undefined;
49230
49393
  }
@@ -52077,21 +52240,28 @@ var ts;
52077
52240
  getFlowTypeOfReference(accessExpression, propType) :
52078
52241
  propType;
52079
52242
  }
52080
- if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
52243
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) {
52244
+ var index = +propName;
52081
52245
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) {
52082
52246
  var indexNode = getIndexNodeForAccessExpression(accessNode);
52083
52247
  if (isTupleType(objectType)) {
52248
+ if (index < 0) {
52249
+ error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
52250
+ return undefinedType;
52251
+ }
52084
52252
  error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
52085
52253
  }
52086
52254
  else {
52087
52255
  error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
52088
52256
  }
52089
52257
  }
52090
- errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
52091
- return mapType(objectType, function (t) {
52092
- var restType = getRestTypeOfTupleType(t) || undefinedType;
52093
- return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType;
52094
- });
52258
+ if (index >= 0) {
52259
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
52260
+ return mapType(objectType, function (t) {
52261
+ var restType = getRestTypeOfTupleType(t) || undefinedType;
52262
+ return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType;
52263
+ });
52264
+ }
52095
52265
  }
52096
52266
  }
52097
52267
  if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) {
@@ -56677,42 +56847,28 @@ var ts;
56677
56847
  var commonBaseType;
56678
56848
  for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
56679
56849
  var t = types_13[_i];
56680
- var baseType = getBaseTypeOfLiteralType(t);
56681
- if (!commonBaseType) {
56682
- commonBaseType = baseType;
56683
- }
56684
- if (baseType === t || baseType !== commonBaseType) {
56685
- return false;
56850
+ if (!(t.flags & 131072)) {
56851
+ var baseType = getBaseTypeOfLiteralType(t);
56852
+ commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
56853
+ if (baseType === t || baseType !== commonBaseType) {
56854
+ return false;
56855
+ }
56686
56856
  }
56687
56857
  }
56688
56858
  return true;
56689
56859
  }
56690
- function getSupertypeOrUnion(types) {
56691
- if (types.length === 1) {
56692
- return types[0];
56693
- }
56694
- return literalTypesWithSameBaseType(types) ?
56695
- getUnionType(types) :
56696
- ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(getNonNullableTypeIfNeeded(s), getNonNullableTypeIfNeeded(t)) ? t : s; });
56860
+ function getCombinedTypeFlags(types) {
56861
+ return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
56697
56862
  }
56698
56863
  function getCommonSupertype(types) {
56699
- if (!strictNullChecks) {
56700
- return getSupertypeOrUnion(types);
56701
- }
56702
- var supertypeOrUnion = getSupertypeOrUnion(types);
56703
- var shouldHaveNull = ts.some(types, function (t) { return someHas(t, 65536); });
56704
- var shouldHaveUndefined = ts.some(types, function (t) { return someHas(t, 32768); });
56705
- var missingNullableFlags = 0;
56706
- if (shouldHaveNull && !someHas(supertypeOrUnion, 65536)) {
56707
- missingNullableFlags |= 65536;
56708
- }
56709
- if (shouldHaveUndefined && !someHas(supertypeOrUnion, 32768)) {
56710
- missingNullableFlags |= 32768;
56711
- }
56712
- return getNullableType(supertypeOrUnion, missingNullableFlags);
56713
- function someHas(type, flags) {
56714
- return someType(type, function (t) { return !!(t.flags & flags); });
56864
+ if (types.length === 1) {
56865
+ return types[0];
56715
56866
  }
56867
+ var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304); }); }) : types;
56868
+ var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
56869
+ getUnionType(primaryTypes) :
56870
+ ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
56871
+ return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304);
56716
56872
  }
56717
56873
  function getCommonSubtype(types) {
56718
56874
  return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
@@ -60190,7 +60346,9 @@ var ts;
60190
60346
  var narrowedType = mapType(candidate, function (c) {
60191
60347
  var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
60192
60348
  var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
60193
- var directlyRelated = mapType(matching || type, function (t) { return isRelated(t, c) ? t : isRelated(c, t) ? c : neverType; });
60349
+ var directlyRelated = mapType(matching || type, checkDerived ?
60350
+ function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
60351
+ function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
60194
60352
  return directlyRelated.flags & 131072 ?
60195
60353
  mapType(type, function (t) { return maybeTypeOfKind(t, 465829888) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) :
60196
60354
  directlyRelated;
@@ -66749,7 +66907,11 @@ var ts;
66749
66907
  var operator = operatorToken.kind;
66750
66908
  if (operator === 55 || operator === 56 || operator === 60) {
66751
66909
  if (operator === 55) {
66752
- var parent = ts.walkUpParenthesizedExpressions(node.parent);
66910
+ var parent = node.parent;
66911
+ while (parent.kind === 212
66912
+ || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 || parent.operatorToken.kind === 56)) {
66913
+ parent = parent.parent;
66914
+ }
66753
66915
  checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
66754
66916
  }
66755
66917
  checkTruthinessOfType(leftType, node.left);
@@ -70971,14 +71133,19 @@ var ts;
70971
71133
  }
70972
71134
  var indexInfos = getApplicableIndexInfos(type, propNameType);
70973
71135
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined;
70974
- var localPropDeclaration = declaration && declaration.kind === 221 ||
70975
- name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
71136
+ var propDeclaration = declaration && declaration.kind === 221 ||
71137
+ name && name.kind === 162 ? declaration : undefined;
71138
+ var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
70976
71139
  var _loop_30 = function (info) {
70977
71140
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
70978
71141
  var errorNode = localPropDeclaration || localIndexDeclaration ||
70979
71142
  (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
70980
71143
  if (errorNode && !isTypeAssignableTo(propType, info.type)) {
70981
- error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
71144
+ var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
71145
+ if (propDeclaration && errorNode !== propDeclaration) {
71146
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
71147
+ }
71148
+ diagnostics.add(diagnostic);
70982
71149
  }
70983
71150
  };
70984
71151
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
@@ -74066,11 +74233,12 @@ var ts;
74066
74233
  var fileToDirective;
74067
74234
  if (resolvedTypeReferenceDirectives) {
74068
74235
  fileToDirective = new ts.Map();
74069
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
74070
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
74236
+ resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
74237
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
74238
+ if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
74071
74239
  return;
74072
74240
  }
74073
- var file = host.getSourceFile(resolvedDirective.resolvedFileName);
74241
+ var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
74074
74242
  if (file) {
74075
74243
  addReferencedFilesToTypeDirective(file, key, mode);
74076
74244
  }
@@ -76312,13 +76480,13 @@ var ts;
76312
76480
  return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
76313
76481
  case 200:
76314
76482
  ts.Debug.type(node);
76315
- return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
76483
+ return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
76316
76484
  case 295:
76317
76485
  ts.Debug.type(node);
76318
76486
  return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
76319
76487
  case 197:
76320
76488
  ts.Debug.type(node);
76321
- return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode));
76489
+ return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
76322
76490
  case 191:
76323
76491
  ts.Debug.type(node);
76324
76492
  return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
@@ -76381,7 +76549,7 @@ var ts;
76381
76549
  return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
76382
76550
  case 210:
76383
76551
  ts.Debug.type(node);
76384
- return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
76552
+ return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
76385
76553
  case 211:
76386
76554
  ts.Debug.type(node);
76387
76555
  return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
@@ -91815,7 +91983,7 @@ var ts;
91815
91983
  var sourceMap = sourceMapGenerator.toString();
91816
91984
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
91817
91985
  if (printer.bundleFileInfo)
91818
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
91986
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
91819
91987
  }
91820
91988
  }
91821
91989
  else {
@@ -91824,7 +91992,7 @@ var ts;
91824
91992
  var text = writer.getText();
91825
91993
  ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
91826
91994
  if (printer.bundleFileInfo)
91827
- printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
91995
+ printer.bundleFileInfo.hash = ts.computeSignature(text, host);
91828
91996
  writer.clear();
91829
91997
  }
91830
91998
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -91949,7 +92117,6 @@ var ts;
91949
92117
  });
91950
92118
  }
91951
92119
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
91952
- var createHash = ts.maybeBind(host, host.createHash);
91953
92120
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
91954
92121
  var buildInfo;
91955
92122
  if (host.getBuildInfo) {
@@ -91969,22 +92136,22 @@ var ts;
91969
92136
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
91970
92137
  if (!jsFileText)
91971
92138
  return jsFilePath;
91972
- if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92139
+ if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
91973
92140
  return jsFilePath;
91974
92141
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
91975
92142
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
91976
92143
  return sourceMapFilePath || "inline sourcemap decoding";
91977
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92144
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
91978
92145
  return sourceMapFilePath;
91979
92146
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
91980
92147
  if (declarationFilePath && !declarationText)
91981
92148
  return declarationFilePath;
91982
- if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92149
+ if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
91983
92150
  return declarationFilePath;
91984
92151
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
91985
92152
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
91986
92153
  return declarationMapPath || "inline sourcemap decoding";
91987
- if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92154
+ if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
91988
92155
  return declarationMapPath;
91989
92156
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
91990
92157
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
@@ -92022,7 +92189,7 @@ var ts;
92022
92189
  var newBuildInfo = data.buildInfo;
92023
92190
  newBuildInfo.program = buildInfo.program;
92024
92191
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
92025
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
92192
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
92026
92193
  }
92027
92194
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
92028
92195
  newBuildInfo.bundle.js.sources = js.sources;
@@ -92055,7 +92222,7 @@ var ts;
92055
92222
  getSourceFileFromReference: ts.returnUndefined,
92056
92223
  redirectTargetsMap: ts.createMultiMap(),
92057
92224
  getFileIncludeReasons: ts.notImplemented,
92058
- createHash: createHash,
92225
+ createHash: ts.maybeBind(host, host.createHash),
92059
92226
  };
92060
92227
  emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
92061
92228
  return outputFiles;
@@ -97039,7 +97206,7 @@ var ts;
97039
97206
  var name = names_2[_i];
97040
97207
  var result = void 0;
97041
97208
  var mode = getModeForFileReference(name, containingFileMode);
97042
- var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
97209
+ var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
97043
97210
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
97044
97211
  if (cache.has(cacheKey)) {
97045
97212
  result = cache.get(cacheKey);
@@ -97123,7 +97290,21 @@ var ts;
97123
97290
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97124
97291
  }
97125
97292
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
97126
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
97293
+ var emptyResolution = {
97294
+ resolvedModule: undefined,
97295
+ resolvedTypeReferenceDirective: undefined,
97296
+ failedLookupLocations: [],
97297
+ affectingLocations: [],
97298
+ resolutionDiagnostics: [],
97299
+ };
97300
+ function isResolvedModuleWithFailedLookupLocation(resolved) {
97301
+ return !!resolved && !!resolved.failedLookupLocations;
97302
+ }
97303
+ function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
97304
+ return !!resolved && !!resolved.failedLookupLocations;
97305
+ }
97306
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
97307
+ var _a;
97127
97308
  if (names.length === 0) {
97128
97309
  return [];
97129
97310
  }
@@ -97133,7 +97314,7 @@ var ts;
97133
97314
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
97134
97315
  var name = names_3[_i];
97135
97316
  var result = void 0;
97136
- var mode = getModeForResolutionAtIndex(containingFile, i);
97317
+ var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
97137
97318
  i++;
97138
97319
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
97139
97320
  if (cache.has(cacheKey)) {
@@ -97191,14 +97372,14 @@ var ts;
97191
97372
  ts.isReferenceFileLocation = isReferenceFileLocation;
97192
97373
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97193
97374
  var _a, _b, _c;
97194
- var _d, _e, _f, _g;
97375
+ var _d, _e, _f, _g, _h, _j;
97195
97376
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
97196
97377
  var kind = ref.kind, index = ref.index;
97197
97378
  var pos, end, packageId, resolutionMode;
97198
97379
  switch (kind) {
97199
97380
  case ts.FileIncludeKind.Import:
97200
97381
  var importLiteral = getModuleNameStringLiteralAt(file, index);
97201
- 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;
97382
+ 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;
97202
97383
  if (importLiteral.pos === -1)
97203
97384
  return { file: file, packageId: packageId, text: importLiteral.text };
97204
97385
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -97209,7 +97390,7 @@ var ts;
97209
97390
  break;
97210
97391
  case ts.FileIncludeKind.TypeReferenceDirective:
97211
97392
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
97212
- 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;
97393
+ 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;
97213
97394
  break;
97214
97395
  case ts.FileIncludeKind.LibReferenceDirective:
97215
97396
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -97288,7 +97469,7 @@ var ts;
97288
97469
  return undefined;
97289
97470
  }
97290
97471
  function lookupFromPackageJson() {
97291
- var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
97472
+ var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
97292
97473
  return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97293
97474
  }
97294
97475
  }
@@ -97401,10 +97582,10 @@ var ts;
97401
97582
  };
97402
97583
  }
97403
97584
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97404
- var _a, _b, _c, _d;
97585
+ var _a, _b, _c, _d, _e;
97405
97586
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97406
97587
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
97407
- var oldProgram = createProgramOptions.oldProgram;
97588
+ var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
97408
97589
  var processingDefaultLibFiles;
97409
97590
  var processingOtherFiles;
97410
97591
  var files;
@@ -97418,6 +97599,8 @@ var ts;
97418
97599
  var cachedDeclarationDiagnosticsForFile = {};
97419
97600
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
97420
97601
  var fileProcessingDiagnostics;
97602
+ var automaticTypeDirectiveNames;
97603
+ var automaticTypeDirectiveResolutions;
97421
97604
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97422
97605
  var currentNodeModulesDepth = 0;
97423
97606
  var modulesWithElidedImports = new ts.Map();
@@ -97440,29 +97623,69 @@ var ts;
97440
97623
  var actualResolveModuleNamesWorker;
97441
97624
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
97442
97625
  if (host.resolveModuleNames) {
97443
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
97444
- if (!resolved || resolved.extension !== undefined) {
97445
- return resolved;
97446
- }
97447
- var withExtension = ts.clone(resolved);
97448
- withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
97449
- return withExtension;
97450
- }); };
97626
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97627
+ var _a;
97628
+ 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) {
97629
+ var name = _a.name;
97630
+ return name;
97631
+ }), redirectedReference, options, containingFile, partialResolutionInfo);
97632
+ return result.some(isResolvedModuleWithFailedLookupLocation) ?
97633
+ result :
97634
+ result.map(function (resolved) { return resolved ?
97635
+ resolved.extension !== undefined ?
97636
+ { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97637
+ { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
97638
+ emptyResolution; });
97639
+ };
97451
97640
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
97452
97641
  }
97453
97642
  else {
97454
97643
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
97455
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
97456
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
97644
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
97645
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97646
+ return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
97647
+ };
97457
97648
  }
97458
97649
  var actualResolveTypeReferenceDirectiveNamesWorker;
97459
97650
  if (host.resolveTypeReferenceDirectives) {
97460
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
97651
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
97652
+ var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
97653
+ return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
97654
+ result :
97655
+ result.map(function (resolved) { return resolved ?
97656
+ { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97657
+ emptyResolution; });
97658
+ };
97659
+ typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
97461
97660
  }
97462
97661
  else {
97463
97662
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97464
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
97465
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
97663
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
97664
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
97665
+ return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
97666
+ };
97667
+ }
97668
+ var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
97669
+ var oldBuildInfoProgram;
97670
+ if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
97671
+ var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
97672
+ oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
97673
+ fileExists: function (fileName) { return host.fileExists(fileName); },
97674
+ createHash: ts.maybeBind(host, host.createHash),
97675
+ getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), false, state_11); },
97676
+ });
97677
+ if (oldBuildInfoProgram) {
97678
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
97679
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97680
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
97681
+ }
97682
+ });
97683
+ typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
97684
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97685
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
97686
+ }
97687
+ });
97688
+ }
97466
97689
  }
97467
97690
  var packageIdToSourceFile = new ts.Map();
97468
97691
  var sourceFileToPackageName = new ts.Map();
@@ -97475,9 +97698,9 @@ var ts;
97475
97698
  var projectReferenceRedirects;
97476
97699
  var mapFromFileToProjectReferenceRedirects;
97477
97700
  var mapFromToProjectReferenceRedirectSource;
97478
- var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
97701
+ var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
97479
97702
  !options.disableSourceOfProjectReferenceRedirect;
97480
- var _e = updateHostForUseSourceOfProjectReferenceRedirect({
97703
+ var _f = updateHostForUseSourceOfProjectReferenceRedirect({
97481
97704
  compilerHost: host,
97482
97705
  getSymlinkCache: getSymlinkCache,
97483
97706
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -97485,7 +97708,7 @@ var ts;
97485
97708
  getResolvedProjectReferences: getResolvedProjectReferences,
97486
97709
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
97487
97710
  forEachResolvedProjectReference: forEachResolvedProjectReference
97488
- }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
97711
+ }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
97489
97712
  var readFile = host.readFile.bind(host);
97490
97713
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97491
97714
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -97494,7 +97717,7 @@ var ts;
97494
97717
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
97495
97718
  structureIsReused = tryReuseStructureFromOldProgram();
97496
97719
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97497
- if (structureIsReused !== 2) {
97720
+ if (structureIsReused !== 3) {
97498
97721
  processingDefaultLibFiles = [];
97499
97722
  processingOtherFiles = [];
97500
97723
  if (projectReferences) {
@@ -97534,14 +97757,14 @@ var ts;
97534
97757
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
97535
97758
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
97536
97759
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97537
- var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
97538
- if (typeReferences.length) {
97539
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
97540
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97541
- var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97542
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
97543
- for (var i = 0; i < typeReferences.length; i++) {
97544
- processTypeReferenceDirective(typeReferences[i], undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
97760
+ automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
97761
+ automaticTypeDirectiveResolutions = ts.createModeAwareCache();
97762
+ if (automaticTypeDirectiveNames.length) {
97763
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: automaticTypeDirectiveNames.length });
97764
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
97765
+ for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
97766
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], undefined, resolutions[i]);
97767
+ processTypeReferenceDirective(automaticTypeDirectiveNames[i], undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: automaticTypeDirectiveNames[i], packageId: (_d = resolutions[i].resolvedTypeReferenceDirective) === null || _d === void 0 ? void 0 : _d.packageId });
97545
97768
  }
97546
97769
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97547
97770
  }
@@ -97572,13 +97795,13 @@ var ts;
97572
97795
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
97573
97796
  if (shouldCreateNewSourceFile || !newFile ||
97574
97797
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
97575
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
97798
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
97576
97799
  }
97577
97800
  }
97578
97801
  if (!host.getParsedCommandLine) {
97579
97802
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
97580
97803
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
97581
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
97804
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
97582
97805
  }
97583
97806
  });
97584
97807
  }
@@ -97594,6 +97817,8 @@ var ts;
97594
97817
  }
97595
97818
  typeReferenceDirectiveResolutionCache = undefined;
97596
97819
  oldProgram = undefined;
97820
+ oldBuildInfoProgram = undefined;
97821
+ oldProgramOrOldBuildInfoProgramConstructor = undefined;
97597
97822
  var program = {
97598
97823
  getRootFileNames: function () { return rootNames; },
97599
97824
  getSourceFile: getSourceFile,
@@ -97601,6 +97826,7 @@ var ts;
97601
97826
  getSourceFiles: function () { return files; },
97602
97827
  getMissingFilePaths: function () { return missingFilePaths; },
97603
97828
  getModuleResolutionCache: function () { return moduleResolutionCache; },
97829
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
97604
97830
  getFilesByNameMap: function () { return filesByName; },
97605
97831
  getCompilerOptions: function () { return options; },
97606
97832
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -97625,6 +97851,9 @@ var ts;
97625
97851
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
97626
97852
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
97627
97853
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
97854
+ getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
97855
+ getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
97856
+ getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
97628
97857
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
97629
97858
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
97630
97859
  getSourceFileFromReference: getSourceFileFromReference,
@@ -97634,12 +97863,12 @@ var ts;
97634
97863
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
97635
97864
  isEmittedFile: isEmittedFile,
97636
97865
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
97637
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
97638
97866
  getProjectReferences: getProjectReferences,
97639
97867
  getResolvedProjectReferences: getResolvedProjectReferences,
97640
97868
  getProjectReferenceRedirect: getProjectReferenceRedirect,
97641
97869
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
97642
97870
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
97871
+ getRedirectReferenceForResolution: getRedirectReferenceForResolution,
97643
97872
  forEachResolvedProjectReference: forEachResolvedProjectReference,
97644
97873
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
97645
97874
  emitBuildInfo: emitBuildInfo,
@@ -97647,7 +97876,7 @@ var ts;
97647
97876
  readFile: readFile,
97648
97877
  directoryExists: directoryExists,
97649
97878
  getSymlinkCache: getSymlinkCache,
97650
- realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
97879
+ realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
97651
97880
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
97652
97881
  getFileIncludeReasons: function () { return fileReasons; },
97653
97882
  structureIsReused: structureIsReused,
@@ -97661,6 +97890,8 @@ var ts;
97661
97890
  case 0:
97662
97891
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
97663
97892
  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)));
97893
+ case 2:
97894
+ return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
97664
97895
  default:
97665
97896
  ts.Debug.assertNever(diagnostic);
97666
97897
  }
@@ -97670,57 +97901,44 @@ var ts;
97670
97901
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
97671
97902
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97672
97903
  return program;
97673
- function addResolutionDiagnostics(list) {
97674
- if (!list)
97675
- return;
97676
- for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
97677
- var elem = list_3[_i];
97678
- programDiagnostics.add(elem);
97679
- }
97904
+ function getAutomaticTypeDirectiveContainingFile() {
97905
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97906
+ return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97680
97907
  }
97681
- function pullDiagnosticsFromCache(names, containingFile) {
97682
- var _a;
97683
- if (!moduleResolutionCache)
97908
+ function addResolutionDiagnostics(resolution) {
97909
+ if (!resolution.resolutionDiagnostics)
97684
97910
  return;
97685
- var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97686
- var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97687
- var containingDir = ts.getDirectoryPath(containingFileName);
97688
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
97689
- var i = 0;
97690
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
97691
- var n = names_4[_i];
97692
- var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
97693
- var name = typeof n === "string" ? n : n.fileName;
97694
- i++;
97695
- if (ts.isExternalModuleNameRelative(name))
97696
- continue;
97697
- var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
97698
- addResolutionDiagnostics(diags);
97699
- }
97911
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
97912
+ kind: 2,
97913
+ diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
97914
+ ? 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
97915
+ : 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, d.packagePath); })
97916
+ });
97700
97917
  }
97701
- function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
97918
+ function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
97702
97919
  if (!moduleNames.length)
97703
97920
  return ts.emptyArray;
97704
97921
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97705
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
97922
+ if (redirectedReference === undefined)
97923
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97706
97924
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
97707
97925
  ts.performance.mark("beforeResolveModule");
97708
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
97926
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
97709
97927
  ts.performance.mark("afterResolveModule");
97710
97928
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
97711
97929
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97712
- pullDiagnosticsFromCache(moduleNames, containingFile);
97713
97930
  return result;
97714
97931
  }
97715
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
97932
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
97716
97933
  if (!typeDirectiveNames.length)
97717
97934
  return [];
97718
97935
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
97719
- var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
97936
+ if (redirectedReference === undefined && !ts.isString(containingFile))
97937
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97720
97938
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97721
97939
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
97722
97940
  ts.performance.mark("beforeResolveTypeReference");
97723
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
97941
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
97724
97942
  ts.performance.mark("afterResolveTypeReference");
97725
97943
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
97726
97944
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -97766,9 +97984,6 @@ var ts;
97766
97984
  }
97767
97985
  return ts.libs.length + 2;
97768
97986
  }
97769
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
97770
- return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
97771
- }
97772
97987
  function toPath(fileName) {
97773
97988
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
97774
97989
  }
@@ -97792,8 +98007,9 @@ var ts;
97792
98007
  return classifiableNames;
97793
98008
  }
97794
98009
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98010
+ var _a;
97795
98011
  if (structureIsReused === 0 && !file.ambientModuleNames.length) {
97796
- return resolveModuleNamesWorker(moduleNames, file, undefined);
98012
+ return resolveModuleNamesWorker(moduleNames, file, undefined, undefined);
97797
98013
  }
97798
98014
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
97799
98015
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -97808,21 +98024,34 @@ var ts;
97808
98024
  return result_14;
97809
98025
  }
97810
98026
  var unknownModuleNames;
97811
- var result;
98027
+ var unknownModuleNamesIndex;
97812
98028
  var reusedNames;
97813
- var predictedToResolveToAmbientModuleMarker = {};
98029
+ var result;
98030
+ var predictedToResolveToAmbientModuleMarker = true;
98031
+ var redirectedReference;
97814
98032
  for (var i = 0; i < moduleNames.length; i++) {
97815
98033
  var moduleName = moduleNames[i];
97816
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
97817
- var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
97818
- if (oldResolvedModule) {
98034
+ if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98035
+ var mode = getModeForResolutionAtIndex(file, i);
98036
+ var oldResolution = !oldBuildInfoProgram ?
98037
+ (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
98038
+ oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
98039
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
97819
98040
  if (ts.isTraceEnabled(options, host)) {
97820
- ts.trace(host, oldResolvedModule.packageId ?
97821
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
97822
- 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));
98041
+ var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
98042
+ if (!oldBuildInfoProgram) {
98043
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98044
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98045
+ 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));
98046
+ }
98047
+ else {
98048
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98049
+ 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 :
98050
+ 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));
98051
+ }
97823
98052
  }
97824
- (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
97825
- (reusedNames || (reusedNames = [])).push(moduleName);
98053
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
98054
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
97826
98055
  continue;
97827
98056
  }
97828
98057
  }
@@ -97837,14 +98066,15 @@ var ts;
97837
98066
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
97838
98067
  }
97839
98068
  if (resolvesToAmbientModuleInNonModifiedFile) {
97840
- (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98069
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
97841
98070
  }
97842
98071
  else {
97843
- (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
98072
+ (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
98073
+ (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
97844
98074
  }
97845
98075
  }
97846
98076
  var resolutions = unknownModuleNames && unknownModuleNames.length
97847
- ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
98077
+ ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
97848
98078
  : ts.emptyArray;
97849
98079
  if (!result) {
97850
98080
  ts.Debug.assert(resolutions.length === moduleNames.length);
@@ -97854,7 +98084,7 @@ var ts;
97854
98084
  for (var i = 0; i < result.length; i++) {
97855
98085
  if (result[i]) {
97856
98086
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
97857
- result[i] = undefined;
98087
+ result[i] = emptyResolution;
97858
98088
  }
97859
98089
  }
97860
98090
  else {
@@ -97882,6 +98112,78 @@ var ts;
97882
98112
  return true;
97883
98113
  }
97884
98114
  }
98115
+ function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98116
+ var _a;
98117
+ if (structureIsReused === 0) {
98118
+ return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, undefined, undefined);
98119
+ }
98120
+ var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
98121
+ var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
98122
+ var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
98123
+ if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
98124
+ var result_15 = [];
98125
+ for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
98126
+ var typeDirectiveName = _b[_i];
98127
+ var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
98128
+ result_15.push(resolvedTypeReferenceDirective);
98129
+ }
98130
+ return result_15;
98131
+ }
98132
+ var unknownTypeReferenceDirectiveNames;
98133
+ var unknownTypeReferenceDirectiveNamesIndex;
98134
+ var result;
98135
+ var reusedNames;
98136
+ var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
98137
+ containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
98138
+ !hasInvalidatedResolution(toPath(inferredTypeFile)));
98139
+ var redirectedReference;
98140
+ for (var i = 0; i < typeDirectiveNames.length; i++) {
98141
+ var entry = typeDirectiveNames[i];
98142
+ if (canReuseResolutions) {
98143
+ var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
98144
+ var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
98145
+ var oldResolution = !oldBuildInfoProgram ?
98146
+ (_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) :
98147
+ oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
98148
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98149
+ if (ts.isTraceEnabled(options, host)) {
98150
+ var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
98151
+ if (!oldBuildInfoProgram) {
98152
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98153
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98154
+ 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));
98155
+ }
98156
+ else {
98157
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98158
+ 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 :
98159
+ 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));
98160
+ }
98161
+ }
98162
+ (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
98163
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
98164
+ continue;
98165
+ }
98166
+ }
98167
+ (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
98168
+ (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
98169
+ }
98170
+ if (!unknownTypeReferenceDirectiveNames)
98171
+ return result || ts.emptyArray;
98172
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
98173
+ if (!result) {
98174
+ ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
98175
+ return resolutions;
98176
+ }
98177
+ var j = 0;
98178
+ for (var i = 0; i < result.length; i++) {
98179
+ if (!result[i]) {
98180
+ result[i] = resolutions[j];
98181
+ j++;
98182
+ }
98183
+ }
98184
+ ts.Debug.assert(j === resolutions.length);
98185
+ return result;
98186
+ }
97885
98187
  function canReuseProjectReferences() {
97886
98188
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
97887
98189
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -97900,12 +98202,17 @@ var ts;
97900
98202
  });
97901
98203
  }
97902
98204
  function tryReuseStructureFromOldProgram() {
97903
- var _a;
97904
- if (!oldProgram) {
98205
+ var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
98206
+ if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
97905
98207
  return 0;
97906
98208
  }
97907
- var oldOptions = oldProgram.getCompilerOptions();
97908
- if (ts.changesAffectModuleResolution(oldOptions, options)) {
98209
+ var result = tryReuseStructureFromOldProgramWorker();
98210
+ return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 ?
98211
+ 1 :
98212
+ result;
98213
+ }
98214
+ function tryReuseStructureFromOldProgramWorker() {
98215
+ if (!oldProgram) {
97909
98216
  return 0;
97910
98217
  }
97911
98218
  var oldRootNames = oldProgram.getRootFileNames();
@@ -97920,7 +98227,7 @@ var ts;
97920
98227
  }
97921
98228
  var newSourceFiles = [];
97922
98229
  var modifiedSourceFiles = [];
97923
- structureIsReused = 2;
98230
+ structureIsReused = 3;
97924
98231
  if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
97925
98232
  return 0;
97926
98233
  }
@@ -97967,81 +98274,90 @@ var ts;
97967
98274
  }
97968
98275
  if (fileChanged) {
97969
98276
  if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
97970
- structureIsReused = 1;
98277
+ structureIsReused = 2;
97971
98278
  }
97972
98279
  if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
97973
- structureIsReused = 1;
98280
+ structureIsReused = 2;
97974
98281
  }
97975
98282
  if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
97976
- structureIsReused = 1;
98283
+ structureIsReused = 2;
97977
98284
  }
97978
98285
  collectExternalModuleReferences(newSourceFile);
97979
98286
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
97980
- structureIsReused = 1;
98287
+ structureIsReused = 2;
97981
98288
  }
97982
98289
  if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
97983
- structureIsReused = 1;
98290
+ structureIsReused = 2;
97984
98291
  }
97985
98292
  if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
97986
- structureIsReused = 1;
98293
+ structureIsReused = 2;
97987
98294
  }
97988
98295
  if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
97989
- structureIsReused = 1;
98296
+ structureIsReused = 2;
97990
98297
  }
97991
98298
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
97992
98299
  }
97993
98300
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
97994
- structureIsReused = 1;
98301
+ structureIsReused = 2;
97995
98302
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
97996
98303
  }
97997
98304
  newSourceFiles.push(newSourceFile);
97998
98305
  }
97999
- if (structureIsReused !== 2) {
98306
+ if (structureIsReused !== 3) {
98000
98307
  return structureIsReused;
98001
98308
  }
98002
98309
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98003
- for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
98004
- var oldFile = oldSourceFiles_3[_b];
98310
+ for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
98311
+ var oldFile = oldSourceFiles_3[_a];
98005
98312
  if (!ts.contains(modifiedFiles, oldFile)) {
98006
- for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
98007
- var moduleName = _d[_c];
98313
+ for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
98314
+ var moduleName = _c[_b];
98008
98315
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98009
98316
  }
98010
98317
  }
98011
98318
  }
98012
- for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
98013
- var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
98319
+ for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
98320
+ var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
98014
98321
  var moduleNames = getModuleNames(newSourceFile);
98015
98322
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98016
98323
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
98017
98324
  if (resolutionsChanged) {
98018
- structureIsReused = 1;
98325
+ structureIsReused = 2;
98019
98326
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98020
98327
  }
98021
98328
  else {
98022
98329
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98023
98330
  }
98024
98331
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98025
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
98332
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98026
98333
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
98027
98334
  if (typeReferenceResolutionsChanged) {
98028
- structureIsReused = 1;
98335
+ structureIsReused = 2;
98029
98336
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98030
98337
  }
98031
98338
  else {
98032
98339
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98033
98340
  }
98034
98341
  }
98035
- if (structureIsReused !== 2) {
98342
+ if (structureIsReused !== 3) {
98036
98343
  return structureIsReused;
98037
98344
  }
98038
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
98039
- return 1;
98345
+ if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
98346
+ return 2;
98347
+ }
98348
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
98349
+ if (host.hasChangedAutomaticTypeDirectiveNames())
98350
+ return 2;
98351
+ }
98352
+ else {
98353
+ automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
98354
+ if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98355
+ return 2;
98040
98356
  }
98041
98357
  missingFilePaths = oldProgram.getMissingFilePaths();
98042
98358
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98043
- for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
98044
- var newSourceFile = newSourceFiles_1[_g];
98359
+ for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
98360
+ var newSourceFile = newSourceFiles_1[_f];
98045
98361
  filesByName.set(newSourceFile.path, newSourceFile);
98046
98362
  }
98047
98363
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98062,10 +98378,12 @@ var ts;
98062
98378
  fileReasons = oldProgram.getFileIncludeReasons();
98063
98379
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98064
98380
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98381
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98382
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98065
98383
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98066
98384
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98067
98385
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
98068
- return 2;
98386
+ return 3;
98069
98387
  }
98070
98388
  function getEmitHost(writeFileCallback) {
98071
98389
  return {
@@ -98989,33 +99307,40 @@ var ts;
98989
99307
  }
98990
99308
  function processTypeReferenceDirectives(file) {
98991
99309
  var typeDirectives = file.typeReferenceDirectives;
98992
- if (!typeDirectives) {
99310
+ if (!typeDirectives.length) {
99311
+ file.resolvedTypeReferenceDirectiveNames = undefined;
98993
99312
  return;
98994
99313
  }
98995
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
99314
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
98996
99315
  for (var index = 0; index < typeDirectives.length; index++) {
98997
99316
  var ref = file.typeReferenceDirectives[index];
98998
99317
  var resolvedTypeReferenceDirective = resolutions[index];
98999
99318
  var fileName = ts.toFileNameLowerCase(ref.fileName);
99000
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
99319
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99001
99320
  var mode = ref.resolutionMode || file.impliedNodeFormat;
99002
99321
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
99003
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99322
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99323
+ kind: 2,
99324
+ diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
99325
+ });
99004
99326
  }
99005
99327
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
99006
99328
  }
99007
99329
  }
99008
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99009
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
99010
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99330
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99331
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
99332
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99011
99333
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99012
99334
  }
99013
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99014
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99335
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99336
+ var _a;
99337
+ addResolutionDiagnostics(resolution);
99338
+ var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
99015
99339
  if (previousResolution && previousResolution.primary) {
99016
99340
  return;
99017
99341
  }
99018
99342
  var saveResolution = true;
99343
+ var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
99019
99344
  if (resolvedTypeReferenceDirective) {
99020
99345
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99021
99346
  currentNodeModulesDepth++;
@@ -99044,7 +99369,7 @@ var ts;
99044
99369
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99045
99370
  }
99046
99371
  if (saveResolution) {
99047
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99372
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99048
99373
  }
99049
99374
  }
99050
99375
  function pathForLibFile(libFileName) {
@@ -99073,7 +99398,7 @@ var ts;
99073
99398
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
99074
99399
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
99075
99400
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
99076
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99401
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99077
99402
  kind: 0,
99078
99403
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
99079
99404
  diagnostic: diagnostic,
@@ -99096,19 +99421,20 @@ var ts;
99096
99421
  for (var index = 0; index < moduleNames.length; index++) {
99097
99422
  var resolution = resolutions[index];
99098
99423
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
99099
- if (!resolution) {
99424
+ addResolutionDiagnostics(resolution);
99425
+ if (!resolution.resolvedModule) {
99100
99426
  continue;
99101
99427
  }
99102
- var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
99103
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
99428
+ var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
99429
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
99104
99430
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
99105
- var resolvedFileName = resolution.resolvedFileName;
99431
+ var resolvedFileName = resolution.resolvedModule.resolvedFileName;
99106
99432
  if (isFromNodeModulesSearch) {
99107
99433
  currentNodeModulesDepth++;
99108
99434
  }
99109
99435
  var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
99110
99436
  var shouldAddFile = resolvedFileName
99111
- && !getResolutionDiagnostic(optionsForFile, resolution)
99437
+ && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
99112
99438
  && !optionsForFile.noResolve
99113
99439
  && index < file.imports.length
99114
99440
  && !elideImport
@@ -99118,7 +99444,7 @@ var ts;
99118
99444
  modulesWithElidedImports.set(file.path, true);
99119
99445
  }
99120
99446
  else if (shouldAddFile) {
99121
- findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
99447
+ findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
99122
99448
  }
99123
99449
  if (isFromNodeModulesSearch) {
99124
99450
  currentNodeModulesDepth--;
@@ -99219,6 +99545,9 @@ var ts;
99219
99545
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
99220
99546
  }
99221
99547
  }
99548
+ if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
99549
+ createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
99550
+ }
99222
99551
  var outputFile = ts.outFile(options);
99223
99552
  if (options.tsBuildInfoFile) {
99224
99553
  if (!ts.isIncrementalCompilation(options)) {
@@ -99468,7 +99797,7 @@ var ts;
99468
99797
  }
99469
99798
  }
99470
99799
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
99471
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99800
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99472
99801
  kind: 1,
99473
99802
  file: file && file.path,
99474
99803
  fileProcessingReason: fileProcessingReason,
@@ -99729,8 +100058,8 @@ var ts;
99729
100058
  if (!symlinks) {
99730
100059
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
99731
100060
  }
99732
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
99733
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100061
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100062
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
99734
100063
  }
99735
100064
  return symlinks;
99736
100065
  }
@@ -100089,7 +100418,8 @@ var ts;
100089
100418
  }
100090
100419
  }
100091
100420
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100092
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
100421
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
100422
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
100093
100423
  if (!resolvedTypeReferenceDirective) {
100094
100424
  return;
100095
100425
  }
@@ -100138,12 +100468,13 @@ var ts;
100138
100468
  return oldState && !oldState.referencedMap === !newReferencedMap;
100139
100469
  }
100140
100470
  BuilderState.canReuseOldState = canReuseOldState;
100141
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100471
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100142
100472
  var _a, _b, _c;
100143
100473
  var fileInfos = new ts.Map();
100144
100474
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
100145
100475
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
100146
100476
  var useOldState = canReuseOldState(referencedMap, oldState);
100477
+ var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100147
100478
  newProgram.getTypeChecker();
100148
100479
  for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
100149
100480
  var sourceFile = _d[_i];
@@ -100187,23 +100518,23 @@ var ts;
100187
100518
  state.allFileNames = undefined;
100188
100519
  }
100189
100520
  BuilderState.releaseCache = releaseCache;
100190
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100521
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100191
100522
  var _a, _b;
100192
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
100523
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
100193
100524
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
100194
100525
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
100195
100526
  return result;
100196
100527
  }
100197
100528
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
100198
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100529
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100199
100530
  var sourceFile = programOfThisState.getSourceFileByPath(path);
100200
100531
  if (!sourceFile) {
100201
100532
  return ts.emptyArray;
100202
100533
  }
100203
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100534
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100204
100535
  return [sourceFile];
100205
100536
  }
100206
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100537
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100207
100538
  }
100208
100539
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100209
100540
  function updateSignatureOfFile(state, signature, path) {
@@ -100211,7 +100542,7 @@ var ts;
100211
100542
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
100212
100543
  }
100213
100544
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
100214
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
100545
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
100215
100546
  var _a;
100216
100547
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
100217
100548
  if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
@@ -100222,7 +100553,7 @@ var ts;
100222
100553
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
100223
100554
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
100224
100555
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
100225
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
100556
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
100226
100557
  if (latestSignature !== prevSignature) {
100227
100558
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100228
100559
  }
@@ -100356,7 +100687,7 @@ var ts;
100356
100687
  }
100357
100688
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100358
100689
  }
100359
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
100690
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100360
100691
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100361
100692
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100362
100693
  }
@@ -100372,7 +100703,7 @@ var ts;
100372
100703
  if (!seenFileNamesMap.has(currentPath)) {
100373
100704
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100374
100705
  seenFileNamesMap.set(currentPath, currentSourceFile);
100375
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100706
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100376
100707
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
100377
100708
  }
100378
100709
  }
@@ -100386,9 +100717,9 @@ var ts;
100386
100717
  function hasSameKeys(map1, map2) {
100387
100718
  return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
100388
100719
  }
100389
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100720
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100390
100721
  var _a, _b;
100391
- var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
100722
+ var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100392
100723
  state.program = newProgram;
100393
100724
  var compilerOptions = newProgram.getCompilerOptions();
100394
100725
  state.compilerOptions = compilerOptions;
@@ -100441,7 +100772,7 @@ var ts;
100441
100772
  return;
100442
100773
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100443
100774
  if (diagnostics) {
100444
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
100775
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100445
100776
  if (!state.semanticDiagnosticsFromOldState) {
100446
100777
  state.semanticDiagnosticsFromOldState = new ts.Set();
100447
100778
  }
@@ -100463,13 +100794,16 @@ var ts;
100463
100794
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
100464
100795
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
100465
100796
  }
100466
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
100797
+ state.buildInfoEmitPending = !useOldState ||
100798
+ state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
100799
+ state.fileInfos.size !== oldState.fileInfos.size;
100467
100800
  return state;
100468
100801
  }
100469
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100802
+ function convertToDiagnostics(diagnostics, newProgram) {
100470
100803
  if (!diagnostics.length)
100471
100804
  return ts.emptyArray;
100472
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
100805
+ var buildInfoDirectory;
100806
+ var getCanonicalFileName;
100473
100807
  return diagnostics.map(function (diagnostic) {
100474
100808
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
100475
100809
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100485,7 +100819,8 @@ var ts;
100485
100819
  return result;
100486
100820
  });
100487
100821
  function toPath(path) {
100488
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
100822
+ buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
100823
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
100489
100824
  }
100490
100825
  }
100491
100826
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -100494,6 +100829,8 @@ var ts;
100494
100829
  }
100495
100830
  function releaseCache(state) {
100496
100831
  ts.BuilderState.releaseCache(state);
100832
+ if (!state.resuableCacheResolutions)
100833
+ getCacheResolutions(state);
100497
100834
  state.program = undefined;
100498
100835
  }
100499
100836
  function backupBuilderProgramEmitState(state) {
@@ -100528,7 +100865,7 @@ var ts;
100528
100865
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100529
100866
  ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100530
100867
  }
100531
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
100868
+ function getNextAffectedFile(state, cancellationToken, host) {
100532
100869
  var _a, _b;
100533
100870
  while (true) {
100534
100871
  var affectedFiles = state.affectedFiles;
@@ -100539,7 +100876,7 @@ var ts;
100539
100876
  var affectedFile = affectedFiles[affectedFilesIndex];
100540
100877
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
100541
100878
  state.affectedFilesIndex = affectedFilesIndex;
100542
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
100879
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
100543
100880
  return affectedFile;
100544
100881
  }
100545
100882
  affectedFilesIndex++;
@@ -100560,7 +100897,7 @@ var ts;
100560
100897
  ts.Debug.assert(!state.semanticDiagnosticsPerFile);
100561
100898
  return program;
100562
100899
  }
100563
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
100900
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
100564
100901
  state.currentChangedFilePath = nextKey.value;
100565
100902
  state.affectedFilesIndex = 0;
100566
100903
  if (!state.seenAffectedFiles)
@@ -100603,24 +100940,24 @@ var ts;
100603
100940
  });
100604
100941
  }
100605
100942
  }
100606
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100943
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
100607
100944
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
100608
100945
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
100609
100946
  removeDiagnosticsOfLibraryFiles(state);
100610
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
100947
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
100611
100948
  return;
100612
100949
  }
100613
100950
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
100614
100951
  return;
100615
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
100952
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
100616
100953
  }
100617
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
100954
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
100618
100955
  removeSemanticDiagnosticsOf(state, path);
100619
100956
  if (!state.changedFilesSet.has(path)) {
100620
100957
  var program = ts.Debug.checkDefined(state.program);
100621
100958
  var sourceFile = program.getSourceFileByPath(path);
100622
100959
  if (sourceFile) {
100623
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
100960
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
100624
100961
  if (ts.getEmitDeclarations(state.compilerOptions)) {
100625
100962
  addToAffectedFilesPendingEmit(state, path, 0);
100626
100963
  }
@@ -100640,16 +100977,16 @@ var ts;
100640
100977
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
100641
100978
  return newSignature !== oldSignature;
100642
100979
  }
100643
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
100980
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
100644
100981
  var _a;
100645
100982
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
100646
100983
  return false;
100647
100984
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
100648
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
100985
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
100649
100986
  removeDiagnosticsOfLibraryFiles(state);
100650
100987
  return true;
100651
100988
  }
100652
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100989
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
100653
100990
  var _a;
100654
100991
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
100655
100992
  return;
@@ -100663,9 +101000,9 @@ var ts;
100663
101000
  var currentPath = queue.pop();
100664
101001
  if (!seenFileNamesMap.has(currentPath)) {
100665
101002
  seenFileNamesMap.set(currentPath, true);
100666
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101003
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
100667
101004
  return;
100668
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101005
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
100669
101006
  if (isChangedSignature(state, currentPath)) {
100670
101007
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
100671
101008
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -100675,27 +101012,27 @@ var ts;
100675
101012
  }
100676
101013
  var seenFileAndExportsOfFile = new ts.Set();
100677
101014
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100678
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101015
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
100679
101016
  return true;
100680
101017
  var references = state.referencedMap.getKeys(exportedFromPath);
100681
101018
  return references && ts.forEachKey(references, function (filePath) {
100682
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101019
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
100683
101020
  });
100684
101021
  });
100685
101022
  }
100686
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101023
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
100687
101024
  var _a, _b;
100688
101025
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
100689
101026
  return undefined;
100690
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101027
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
100691
101028
  return true;
100692
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101029
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
100693
101030
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100694
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101031
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
100695
101032
  });
100696
101033
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
100697
101034
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
100698
- handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
101035
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, host);
100699
101036
  });
100700
101037
  return undefined;
100701
101038
  }
@@ -100750,34 +101087,45 @@ var ts;
100750
101087
  return !!ts.outFile(info.options || {});
100751
101088
  }
100752
101089
  ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
100753
- function getProgramBuildInfo(state, getCanonicalFileName) {
101090
+ function getProgramBuildInfo(state, host) {
100754
101091
  var outFilePath = ts.outFile(state.compilerOptions);
100755
- if (outFilePath && !state.compilerOptions.composite)
101092
+ if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
100756
101093
  return;
100757
101094
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
100758
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101095
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101096
+ var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
101097
+ var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
100759
101098
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
101099
+ var fileNames = [];
101100
+ var fileNameToFileId = new ts.Map();
101101
+ var resolutions;
101102
+ var names;
101103
+ var resolutionNameToResolutionNameId;
101104
+ var resolutionEntries;
101105
+ var resolutionEntryToResolutionEntryId;
101106
+ var affectedFilesHash;
100760
101107
  if (outFilePath) {
100761
- var fileNames_1 = [];
100762
- var fileInfos_1 = [];
100763
- state.program.getRootFileNames().forEach(function (f) {
100764
- var sourceFile = state.program.getSourceFile(f);
100765
- if (!sourceFile)
100766
- return;
100767
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
100768
- fileInfos_1.push(sourceFile.version);
100769
- });
100770
- var result_15 = {
100771
- fileNames: fileNames_1,
101108
+ var fileInfos_1;
101109
+ if (state.compilerOptions.composite) {
101110
+ state.program.getRootFileNames().forEach(function (f) {
101111
+ var sourceFile = state.program.getSourceFile(f);
101112
+ if (!sourceFile)
101113
+ return;
101114
+ var fileId = toFileId(sourceFile.resolvedPath);
101115
+ (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
101116
+ });
101117
+ }
101118
+ var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
101119
+ var result_16 = {
101120
+ fileNames: fileNames,
100772
101121
  fileInfos: fileInfos_1,
100773
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
101122
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
100774
101123
  outSignature: state.outSignature,
100775
101124
  latestChangedDtsFile: latestChangedDtsFile,
101125
+ cacheResolutions: cacheResolutions_1,
100776
101126
  };
100777
- return result_15;
101127
+ return result_16;
100778
101128
  }
100779
- var fileNames = [];
100780
- var fileNameToFileId = new ts.Map();
100781
101129
  var fileIdsList;
100782
101130
  var fileNamesToFileIdListId;
100783
101131
  var emitSignatures;
@@ -100834,7 +101182,7 @@ var ts;
100834
101182
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
100835
101183
  [
100836
101184
  toFileId(key),
100837
- convertToReusableDiagnostics(value, relativeToBuildInfo)
101185
+ value.map(toReusableDiagnostic)
100838
101186
  ] :
100839
101187
  toFileId(key));
100840
101188
  }
@@ -100856,10 +101204,11 @@ var ts;
100856
101204
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
100857
101205
  }
100858
101206
  }
101207
+ var cacheResolutions = toProgramBuildInfoCacheResolutions();
100859
101208
  var result = {
100860
101209
  fileNames: fileNames,
100861
101210
  fileInfos: fileInfos,
100862
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
101211
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
100863
101212
  fileIdsList: fileIdsList,
100864
101213
  referencedMap: referencedMap,
100865
101214
  exportedModulesMap: exportedModulesMap,
@@ -100868,6 +101217,7 @@ var ts;
100868
101217
  changeFileSet: changeFileSet,
100869
101218
  emitSignatures: emitSignatures,
100870
101219
  latestChangedDtsFile: latestChangedDtsFile,
101220
+ cacheResolutions: cacheResolutions,
100871
101221
  };
100872
101222
  return result;
100873
101223
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -100876,7 +101226,7 @@ var ts;
100876
101226
  function relativeToBuildInfo(path) {
100877
101227
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
100878
101228
  }
100879
- function toFileId(path) {
101229
+ function toFileAndAbsoluteFileId(path) {
100880
101230
  var fileId = fileNameToFileId.get(path);
100881
101231
  if (fileId === undefined) {
100882
101232
  fileNames.push(relativeToBuildInfo(path));
@@ -100884,6 +101234,12 @@ var ts;
100884
101234
  }
100885
101235
  return fileId;
100886
101236
  }
101237
+ function toFileId(path) {
101238
+ return toFileAndAbsoluteFileId(path);
101239
+ }
101240
+ function toAbsoluteFileId(path) {
101241
+ return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
101242
+ }
100887
101243
  function toFileIdListId(set) {
100888
101244
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
100889
101245
  var key = fileIds.join();
@@ -100894,53 +101250,236 @@ var ts;
100894
101250
  }
100895
101251
  return fileIdListId;
100896
101252
  }
100897
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
101253
+ function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
100898
101254
  var result;
100899
101255
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
100900
101256
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
100901
101257
  var name = _a[_i];
100902
101258
  var optionInfo = optionsNameMap.get(name.toLowerCase());
100903
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
100904
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
101259
+ if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
101260
+ (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
101261
+ }
101262
+ else if (affectsModuleResolution && name === "pathsBasePath") {
101263
+ (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
101264
+ continue;
100905
101265
  }
100906
101266
  }
100907
101267
  return result;
100908
101268
  }
100909
- }
100910
- function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
100911
- if (option) {
100912
- if (option.type === "list") {
100913
- var values = value;
100914
- if (option.element.isFilePath && values.length) {
100915
- return values.map(relativeToBuildInfo);
101269
+ function toReusableCompilerOptionValue(option, value) {
101270
+ if (option) {
101271
+ if (option.type === "list") {
101272
+ var values = value;
101273
+ if (option.element.isFilePath && values.length) {
101274
+ return values.map(relativeToBuildInfoEnsuringAbsolutePath);
101275
+ }
101276
+ }
101277
+ else if (option.isFilePath) {
101278
+ return relativeToBuildInfoEnsuringAbsolutePath(value);
100916
101279
  }
100917
101280
  }
100918
- else if (option.isFilePath) {
100919
- return relativeToBuildInfo(value);
100920
- }
101281
+ return value;
100921
101282
  }
100922
- return value;
100923
- }
100924
- function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
100925
- ts.Debug.assert(!!diagnostics.length);
100926
- return diagnostics.map(function (diagnostic) {
100927
- var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
101283
+ function toReadonlyArrayOrUndefined(array, map) {
101284
+ return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
101285
+ }
101286
+ function toReusableDiagnostic(diagnostic) {
101287
+ var result = toReusableDiagnosticRelatedInformation(diagnostic);
100928
101288
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
100929
101289
  result.reportDeprecated = diagnostic.reportsDeprecated;
100930
101290
  result.source = diagnostic.source;
100931
101291
  result.skippedOn = diagnostic.skippedOn;
100932
101292
  var relatedInformation = diagnostic.relatedInformation;
100933
- result.relatedInformation = relatedInformation ?
100934
- relatedInformation.length ?
100935
- relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
100936
- [] :
100937
- undefined;
101293
+ result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
101294
+ return result;
101295
+ }
101296
+ function toReusableDiagnosticRelatedInformation(diagnostic) {
101297
+ var file = diagnostic.file;
101298
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101299
+ }
101300
+ function toProgramBuildInfoCacheResolutions() {
101301
+ var cacheResolutions = getCacheResolutions(state);
101302
+ var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
101303
+ var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
101304
+ if (!resolutions)
101305
+ return;
101306
+ ts.Debug.assertIsDefined(names);
101307
+ ts.Debug.assertIsDefined(resolutionEntries);
101308
+ state.resuableCacheResolutions = {
101309
+ cache: {
101310
+ resolutions: resolutions.map(toProgramBuildInfoResolution),
101311
+ names: names,
101312
+ hash: toProgramBuildInfoHashes(),
101313
+ resolutionEntries: resolutionEntries,
101314
+ modules: modules,
101315
+ typeRefs: typeRefs,
101316
+ },
101317
+ getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
101318
+ };
101319
+ return state.resuableCacheResolutions.cache;
101320
+ }
101321
+ function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
101322
+ if (!cache)
101323
+ return undefined;
101324
+ var ownMap = cache.getOwnMap();
101325
+ var own = toProgramBuildInfoResolutionCache(ownMap);
101326
+ var redirects;
101327
+ cache.redirectsKeyToCache.forEach(function (_a) {
101328
+ var map = _a.map, options = _a.options;
101329
+ if (map === ownMap)
101330
+ return;
101331
+ var redirectCache = toProgramBuildInfoResolutionCache(map);
101332
+ if (redirectCache) {
101333
+ (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
101334
+ options: toProgramBuildInfoCompilerOptions(options, undefined, true),
101335
+ cache: redirectCache
101336
+ });
101337
+ }
101338
+ });
101339
+ return !redirects ? own : { own: own, redirects: redirects };
101340
+ }
101341
+ function toProgramBuildInfoResolutionCache(cache) {
101342
+ var result;
101343
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
101344
+ (result !== null && result !== void 0 ? result : (result = [])).push([
101345
+ toFileId(dirPath),
101346
+ ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
101347
+ ]) :
101348
+ undefined; });
100938
101349
  return result;
101350
+ }
101351
+ function toProgramBuildInfoResolutionEntryId(_a) {
101352
+ var name = _a[0], mode = _a[1], resolution = _a[2];
101353
+ var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
101354
+ var resolutionId = toProgramBuildInfoResolutionId(resolution);
101355
+ var key = resolutionNameId + "," + mode + "," + resolutionId;
101356
+ var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
101357
+ if (resolutionEntryId === undefined) {
101358
+ (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
101359
+ (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
101360
+ }
101361
+ return resolutionEntryId;
101362
+ }
101363
+ function toProgramBuildInfoResolutionNameId(name) {
101364
+ var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
101365
+ if (resolutionNameId === undefined) {
101366
+ (names !== null && names !== void 0 ? names : (names = [])).push(name);
101367
+ (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
101368
+ }
101369
+ return resolutionNameId;
101370
+ }
101371
+ function toProgramBuildInfoResolutionId(resolution) {
101372
+ if (resolution.serializationIndex === undefined) {
101373
+ (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
101374
+ resolution.serializationIndex = resolutions.length;
101375
+ }
101376
+ return resolution.serializationIndex;
101377
+ }
101378
+ function toProgramBuildInfoResolution(resolution) {
101379
+ resolution.serializationIndex = undefined;
101380
+ return {
101381
+ resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
101382
+ resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
101383
+ affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
101384
+ resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
101385
+ };
101386
+ }
101387
+ function toProgramBuildInfoHashes() {
101388
+ if (!affectedFilesHash)
101389
+ return undefined;
101390
+ var hashes = [];
101391
+ for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
101392
+ var key = _a[_i];
101393
+ var value = affectedFilesHash.get(key);
101394
+ hashes.push(value ? [key, value] : key);
101395
+ }
101396
+ return hashes;
101397
+ }
101398
+ function toAffectedFileId(file) {
101399
+ var _a;
101400
+ var fileId = toAbsoluteFileId(file);
101401
+ if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
101402
+ var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
101403
+ var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101404
+ (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
101405
+ }
101406
+ return fileId;
101407
+ }
101408
+ function toProgramBuildInfoResolved(resolved) {
101409
+ 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;
101410
+ }
101411
+ function toProgramBuildInfoResolutionDiagnostic(d) {
101412
+ return {
101413
+ isImports: d.isImports || undefined,
101414
+ entry: d.entry || undefined,
101415
+ packagePath: toAbsoluteFileId(d.packagePath),
101416
+ };
101417
+ }
101418
+ }
101419
+ function getCacheResolutions(state) {
101420
+ var _a;
101421
+ if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
101422
+ return state.cacheResolutions;
101423
+ var modules;
101424
+ var typeRefs;
101425
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
101426
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101427
+ state.program.getSourceFiles().forEach(function (f) {
101428
+ modules = toPerDirectoryCache(state, getCanonicalFileName, modules, f, f.resolvedModules, moduleNameToDirectoryMap);
101429
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, f, f.resolvedTypeReferenceDirectiveNames);
100939
101430
  });
101431
+ var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
101432
+ if (automaticTypeDirectiveNames.length) {
101433
+ var currentDirectory = state.program.getCurrentDirectory();
101434
+ var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
101435
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
101436
+ }
101437
+ return state.cacheResolutions = {
101438
+ modules: modules,
101439
+ typeRefs: typeRefs,
101440
+ moduleNameToDirectoryMap: moduleNameToDirectoryMap,
101441
+ packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
101442
+ };
100940
101443
  }
100941
- function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
100942
- var file = diagnostic.file;
100943
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101444
+ function toPerDirectoryCache(state, getCanonicalFileName, cacheWithRedirects, fOrPath, cache, moduleNameToDirectoryMap) {
101445
+ if (!(cache === null || cache === void 0 ? void 0 : cache.size()))
101446
+ return cacheWithRedirects;
101447
+ var dirPath, redirectedReference;
101448
+ if (!ts.isString(fOrPath)) {
101449
+ redirectedReference = state.program.getRedirectReferenceForResolution(fOrPath);
101450
+ dirPath = ts.getDirectoryPath(fOrPath.path);
101451
+ }
101452
+ else {
101453
+ dirPath = ts.getDirectoryPath(fOrPath);
101454
+ }
101455
+ var perDirResolutionCache = cacheWithRedirects === null || cacheWithRedirects === void 0 ? void 0 : cacheWithRedirects.getMapOfCacheRedirects(redirectedReference);
101456
+ var dirCache = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
101457
+ cache.forEach(function (resolution, name, mode) {
101458
+ var _a, _b, _c, _d;
101459
+ if (!((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) && !((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.resolvedFileName))
101460
+ return;
101461
+ if (dirCache === null || dirCache === void 0 ? void 0 : dirCache.has(name, mode))
101462
+ return;
101463
+ if (moduleNameToDirectoryMap &&
101464
+ !ts.isExternalModuleNameRelative(name) &&
101465
+ ((_d = (_c = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath))) {
101466
+ return;
101467
+ }
101468
+ if (!dirCache) {
101469
+ perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (cacheWithRedirects !== null && cacheWithRedirects !== void 0 ? cacheWithRedirects : (cacheWithRedirects = ts.createCacheWithRedirects(state.compilerOptions))).getOrCreateMapOfCacheRedirects(redirectedReference));
101470
+ perDirResolutionCache.set(dirPath, dirCache = ts.createModeAwareCache());
101471
+ }
101472
+ dirCache.set(name, mode, resolution);
101473
+ if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
101474
+ return;
101475
+ var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(redirectedReference);
101476
+ var key = ts.getModeAwareCacheKey(name, mode);
101477
+ var directoryPathMap = actualModuleNameToDirectoryMap.get(key);
101478
+ if (!directoryPathMap)
101479
+ actualModuleNameToDirectoryMap.set(key, directoryPathMap = new ts.Map());
101480
+ ts.moduleNameToDirectorySet(directoryPathMap, dirPath, resolution, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
101481
+ });
101482
+ return cacheWithRedirects;
100944
101483
  }
100945
101484
  var BuilderProgramKind;
100946
101485
  (function (BuilderProgramKind) {
@@ -100964,7 +101503,7 @@ var ts;
100964
101503
  rootNames: newProgramOrRootNames,
100965
101504
  options: hostOrOptions,
100966
101505
  host: oldProgramOrHost,
100967
- oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
101506
+ oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
100968
101507
  configFileParsingDiagnostics: configFileParsingDiagnostics,
100969
101508
  projectReferences: projectReferences
100970
101509
  });
@@ -100982,8 +101521,8 @@ var ts;
100982
101521
  function getTextHandlingSourceMapForSignature(text, data) {
100983
101522
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
100984
101523
  }
100985
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
100986
- var _a;
101524
+ function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
101525
+ var _a, _b;
100987
101526
  text = getTextHandlingSourceMapForSignature(text, data);
100988
101527
  var sourceFileDirectory;
100989
101528
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -100991,7 +101530,7 @@ var ts;
100991
101530
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
100992
101531
  }).join("\n");
100993
101532
  }
100994
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
101533
+ return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
100995
101534
  function flattenDiagnosticMessageText(diagnostic) {
100996
101535
  return ts.isString(diagnostic) ?
100997
101536
  diagnostic :
@@ -101010,8 +101549,9 @@ var ts;
101010
101549
  }
101011
101550
  }
101012
101551
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
101013
- function computeSignature(text, computeHash, data) {
101014
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101552
+ function computeSignature(text, host, data) {
101553
+ var _a;
101554
+ return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101015
101555
  }
101016
101556
  ts.computeSignature = computeSignature;
101017
101557
  function createBuilderProgram(kind, _a) {
@@ -101022,10 +101562,8 @@ var ts;
101022
101562
  oldState = undefined;
101023
101563
  return oldProgram;
101024
101564
  }
101025
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101026
- var computeHash = ts.maybeBind(host, host.createHash);
101027
- var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101028
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
101565
+ var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101566
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
101029
101567
  newProgram = undefined;
101030
101568
  oldProgram = undefined;
101031
101569
  oldState = undefined;
@@ -101039,6 +101577,7 @@ var ts;
101039
101577
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
101040
101578
  builderProgram.emit = emit;
101041
101579
  builderProgram.releaseProgram = function () { return releaseCache(state); };
101580
+ builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
101042
101581
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
101043
101582
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
101044
101583
  }
@@ -101060,7 +101599,7 @@ var ts;
101060
101599
  return ts.emitSkippedWithNoDiagnostics;
101061
101600
  }
101062
101601
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101063
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101602
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101064
101603
  var emitKind = 1;
101065
101604
  var isPendingEmitFile = false;
101066
101605
  if (!affected) {
@@ -101098,7 +101637,7 @@ var ts;
101098
101637
  var file = sourceFiles[0];
101099
101638
  var info = state.fileInfos.get(file.resolvedPath);
101100
101639
  if (info.signature === file.version) {
101101
- var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
101640
+ var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
101102
101641
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
101103
101642
  emitSignature = signature;
101104
101643
  if (signature !== file.version) {
@@ -101122,7 +101661,7 @@ var ts;
101122
101661
  if (state.compilerOptions.composite) {
101123
101662
  var filePath = sourceFiles[0].resolvedPath;
101124
101663
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
101125
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
101664
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
101126
101665
  if (emitSignature === oldSignature)
101127
101666
  return;
101128
101667
  ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
@@ -101131,7 +101670,7 @@ var ts;
101131
101670
  }
101132
101671
  }
101133
101672
  else if (state.compilerOptions.composite) {
101134
- var newSignature = computeSignature(text, computeHash, data);
101673
+ var newSignature = computeSignature(text, host, data);
101135
101674
  if (newSignature === state.outSignature)
101136
101675
  return;
101137
101676
  state.outSignature = newSignature;
@@ -101192,7 +101731,7 @@ var ts;
101192
101731
  }
101193
101732
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101194
101733
  while (true) {
101195
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101734
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101196
101735
  if (!affected) {
101197
101736
  return undefined;
101198
101737
  }
@@ -101250,12 +101789,32 @@ var ts;
101250
101789
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
101251
101790
  }
101252
101791
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
101253
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
101254
- var _a, _b, _c, _d;
101255
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101256
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101257
- var state;
101792
+ function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
101793
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
101258
101794
  var filePaths;
101795
+ var fileAbsolutePaths;
101796
+ return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
101797
+ function toPath(path) {
101798
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101799
+ }
101800
+ function toAbsolutePath(path) {
101801
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101802
+ }
101803
+ function toFilePath(fileId) {
101804
+ var _a;
101805
+ 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]));
101806
+ }
101807
+ function toFileAbsolutePath(fileId) {
101808
+ var _a;
101809
+ 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]));
101810
+ }
101811
+ }
101812
+ ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
101813
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
101814
+ var _a, _b, _c;
101815
+ var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
101816
+ var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
101817
+ var state;
101259
101818
  var filePathsSetList;
101260
101819
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
101261
101820
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -101264,13 +101823,13 @@ var ts;
101264
101823
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
101265
101824
  latestChangedDtsFile: latestChangedDtsFile,
101266
101825
  outSignature: program.outSignature,
101826
+ resuableCacheResolutions: toResuableCacheResolutions(),
101267
101827
  };
101268
101828
  }
101269
101829
  else {
101270
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
101271
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101830
+ filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101272
101831
  var fileInfos_2 = new ts.Map();
101273
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101832
+ var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101274
101833
  program.fileInfos.forEach(function (fileInfo, index) {
101275
101834
  var path = toFilePath(index + 1);
101276
101835
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -101278,7 +101837,7 @@ var ts;
101278
101837
  if (emitSignatures_1 && stateFileInfo.signature)
101279
101838
  emitSignatures_1.set(path, stateFileInfo.signature);
101280
101839
  });
101281
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
101840
+ (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
101282
101841
  if (ts.isNumber(value))
101283
101842
  emitSignatures_1.delete(toFilePath(value));
101284
101843
  else
@@ -101297,14 +101856,17 @@ var ts;
101297
101856
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
101298
101857
  latestChangedDtsFile: latestChangedDtsFile,
101299
101858
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
101859
+ resuableCacheResolutions: toResuableCacheResolutions(),
101300
101860
  };
101301
101861
  }
101862
+ state.compilerOptions.configFilePath = configFilePath;
101302
101863
  return {
101303
101864
  getState: function () { return state; },
101304
101865
  saveEmitState: ts.noop,
101305
101866
  restoreEmitState: ts.noop,
101306
101867
  getProgram: ts.notImplemented,
101307
101868
  getProgramOrUndefined: ts.returnUndefined,
101869
+ getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
101308
101870
  releaseProgram: ts.noop,
101309
101871
  getCompilerOptions: function () { return state.compilerOptions; },
101310
101872
  getSourceFile: ts.notImplemented,
@@ -101324,15 +101886,6 @@ var ts;
101324
101886
  close: ts.noop,
101325
101887
  hasChangedEmitSignature: ts.returnFalse,
101326
101888
  };
101327
- function toPath(path) {
101328
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101329
- }
101330
- function toAbsolutePath(path) {
101331
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101332
- }
101333
- function toFilePath(fileId) {
101334
- return filePaths[fileId - 1];
101335
- }
101336
101889
  function toFilePathsSet(fileIdsListId) {
101337
101890
  return filePathsSetList[fileIdsListId - 1];
101338
101891
  }
@@ -101347,8 +101900,186 @@ var ts;
101347
101900
  });
101348
101901
  return map;
101349
101902
  }
101903
+ function toResuableCacheResolutions() {
101904
+ return program.cacheResolutions && {
101905
+ cache: program.cacheResolutions,
101906
+ getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
101907
+ };
101908
+ }
101350
101909
  }
101351
101910
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
101911
+ function createGetProgramOrOldBuildInfoProgramUndefined(state) {
101912
+ return function () {
101913
+ var _a;
101914
+ return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
101915
+ (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions, !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
101916
+ undefined);
101917
+ };
101918
+ }
101919
+ function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
101920
+ if (!cacheResolutions && !resuableCacheResolutions)
101921
+ return undefined;
101922
+ var fileExistsMap = new ts.Map();
101923
+ var affectingLoationsSameMap = new ts.Map();
101924
+ var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
101925
+ var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
101926
+ var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
101927
+ var decodedHashes;
101928
+ var resolutions;
101929
+ var originalPathOrResolvedFileNames;
101930
+ var resolutionEntries;
101931
+ return {
101932
+ getCompilerOptions: function () { return compilerOptions; },
101933
+ 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); },
101934
+ 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, undefined, undefined); },
101935
+ };
101936
+ function fileExists(fileName) {
101937
+ var result = fileExistsMap.get(fileName);
101938
+ if (result === undefined)
101939
+ fileExistsMap.set(fileName, result = host.fileExists(fileName));
101940
+ return result;
101941
+ }
101942
+ function affectingLocationsSame(fileName, expected) {
101943
+ var _a;
101944
+ var result = affectingLoationsSameMap.get(fileName);
101945
+ if (result !== undefined)
101946
+ return result;
101947
+ var packageJsonInfo = host.getPackageJsonInfo(fileName);
101948
+ var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101949
+ if (ts.isString(expected)) {
101950
+ result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
101951
+ }
101952
+ else {
101953
+ var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
101954
+ result = currentText === expectedText;
101955
+ }
101956
+ affectingLoationsSameMap.set(fileName, result);
101957
+ return result;
101958
+ }
101959
+ function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
101960
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
101961
+ 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)) ||
101962
+ ((_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));
101963
+ if (fromCache) {
101964
+ return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
101965
+ 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;
101966
+ }
101967
+ if (!reusableCache)
101968
+ return undefined;
101969
+ if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
101970
+ if (ts.isArray(reusableCache)) {
101971
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache, decodedModuleNameToDirectoryMap);
101972
+ }
101973
+ else {
101974
+ if (reusableCache.own)
101975
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
101976
+ reusableCache.redirects.forEach(function (_a) {
101977
+ var options = _a.options, cache = _a.cache;
101978
+ var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
101979
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
101980
+ });
101981
+ }
101982
+ decodedReusableCache.clearRedirectsMap();
101983
+ decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
101984
+ }
101985
+ 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)) ||
101986
+ ((_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));
101987
+ return resolutionId ? toResolution(resolutionId) : undefined;
101988
+ }
101989
+ function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
101990
+ var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
101991
+ reusableCache.forEach(function (_a) {
101992
+ var dirId = _a[0], entryId = _a[1];
101993
+ var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
101994
+ map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
101995
+ });
101996
+ }
101997
+ function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
101998
+ var modeAwareCache = ts.createModeAwareCache();
101999
+ entries.forEach(function (entryId) {
102000
+ var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
102001
+ modeAwareCache.set(name, mode, resolutionId);
102002
+ if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102003
+ return;
102004
+ var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
102005
+ var key = ts.getModeAwareCacheKey(name, mode);
102006
+ var moduleNameMap = mapForOptions.get(key);
102007
+ ;
102008
+ if (!moduleNameMap)
102009
+ mapForOptions.set(key, moduleNameMap = new ts.Map());
102010
+ ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
102011
+ });
102012
+ return modeAwareCache;
102013
+ }
102014
+ function toResolutionEntry(entryId) {
102015
+ var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
102016
+ if (existing)
102017
+ return existing;
102018
+ resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
102019
+ var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
102020
+ return resolutionEntries[entryId - 1] = [
102021
+ toName(nameId),
102022
+ resolutionId,
102023
+ mode
102024
+ ];
102025
+ }
102026
+ function toName(nameId) {
102027
+ return resuableCacheResolutions.cache.names[nameId - 1];
102028
+ }
102029
+ function toOriginalPathOrResolvedFileName(resolutionId) {
102030
+ var _a;
102031
+ 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 ||
102032
+ resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
102033
+ }
102034
+ function toAffectingFileLocation(fileId) {
102035
+ if (!decodedHashes && resuableCacheResolutions.cache.hash) {
102036
+ decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
102037
+ }
102038
+ var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
102039
+ var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
102040
+ return affectingLocationsSame(file, hash) ? file : undefined;
102041
+ }
102042
+ function toResolution(resolutionId) {
102043
+ var _a, _b;
102044
+ var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
102045
+ if (existing !== undefined)
102046
+ return existing || undefined;
102047
+ resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
102048
+ var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
102049
+ var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
102050
+ var affectingLocations;
102051
+ if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
102052
+ var file = toAffectingFileLocation(fileId);
102053
+ if (file)
102054
+ (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
102055
+ return !!file;
102056
+ })) {
102057
+ var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
102058
+ return resolutions[resolutionId - 1] = {
102059
+ resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
102060
+ resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
102061
+ failedLookupLocations: ts.emptyArray,
102062
+ affectingLocations: affectingLocations,
102063
+ resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
102064
+ };
102065
+ }
102066
+ resolutions[resolutionId - 1] = false;
102067
+ return undefined;
102068
+ }
102069
+ function toResolved(resolved, resolvedFileName, extension) {
102070
+ if (!resolved)
102071
+ return undefined;
102072
+ return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
102073
+ }
102074
+ function toResolutionDiagnostic(d) {
102075
+ return {
102076
+ isImports: !!d.isImports,
102077
+ entry: d.entry || "",
102078
+ packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
102079
+ };
102080
+ }
102081
+ }
102082
+ ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
101352
102083
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
101353
102084
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101354
102085
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -101368,6 +102099,7 @@ var ts;
101368
102099
  restoreEmitState: ts.noop,
101369
102100
  getProgram: getProgram,
101370
102101
  getProgramOrUndefined: function () { return getState().program; },
102102
+ getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
101371
102103
  releaseProgram: function () { return getState().program = undefined; },
101372
102104
  getCompilerOptions: function () { return getState().compilerOptions; },
101373
102105
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -101453,11 +102185,10 @@ var ts;
101453
102185
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
101454
102186
  var filesWithChangedSetOfUnresolvedImports;
101455
102187
  var filesWithInvalidatedResolutions;
101456
- var filesWithInvalidatedNonRelativeUnresolvedImports;
101457
- var nonRelativeExternalModuleResolutions = ts.createMultiMap();
101458
102188
  var resolutionsWithFailedLookups = [];
101459
102189
  var resolutionsWithOnlyAffectingLocations = [];
101460
102190
  var resolvedFileToResolution = ts.createMultiMap();
102191
+ var resolutionsToCloseWatcherOn;
101461
102192
  var hasChangedAutomaticTypeDirectiveNames = false;
101462
102193
  var affectingPathChecks;
101463
102194
  var failedLookupChecks;
@@ -101465,13 +102196,11 @@ var ts;
101465
102196
  var isInDirectoryChecks;
101466
102197
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
101467
102198
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
102199
+ var oldModuleAndTypeRefCache;
101468
102200
  var resolvedModuleNames = new ts.Map();
101469
- var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
101470
- var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
101471
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
102201
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
101472
102202
  var resolvedTypeReferenceDirectives = new ts.Map();
101473
- var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
101474
- var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
102203
+ var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache());
101475
102204
  var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
101476
102205
  var customFailedLookupPaths = new ts.Map();
101477
102206
  var directoryWatchesOfFailedLookups = new ts.Map();
@@ -101481,24 +102210,21 @@ var ts;
101481
102210
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
101482
102211
  var typeRootsWatches = new ts.Map();
101483
102212
  return {
102213
+ resolvedModuleNames: resolvedModuleNames,
102214
+ resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
101484
102215
  getModuleResolutionCache: function () { return moduleResolutionCache; },
102216
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
101485
102217
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
101486
102218
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
101487
- startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
102219
+ startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
101488
102220
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
101489
102221
  resolveModuleNames: resolveModuleNames,
101490
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
101491
102222
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
101492
- removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
101493
- removeResolutionsOfFile: removeResolutionsOfFile,
101494
102223
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
101495
102224
  invalidateResolutionOfFile: invalidateResolutionOfFile,
101496
102225
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
101497
102226
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
101498
102227
  createHasInvalidatedResolution: createHasInvalidatedResolution,
101499
- isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
101500
- updateTypeRootsWatch: updateTypeRootsWatch,
101501
- closeTypeRootsWatch: closeTypeRootsWatch,
101502
102228
  clear: clear
101503
102229
  };
101504
102230
  function getResolvedModule(resolution) {
@@ -101517,7 +102243,6 @@ var ts;
101517
102243
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
101518
102244
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
101519
102245
  customFailedLookupPaths.clear();
101520
- nonRelativeExternalModuleResolutions.clear();
101521
102246
  closeTypeRootsWatch();
101522
102247
  resolvedModuleNames.clear();
101523
102248
  resolvedTypeReferenceDirectives.clear();
@@ -101528,7 +102253,10 @@ var ts;
101528
102253
  startsWithPathChecks = undefined;
101529
102254
  isInDirectoryChecks = undefined;
101530
102255
  affectingPathChecks = undefined;
101531
- clearPerDirectoryResolutions();
102256
+ resolutionsToCloseWatcherOn = undefined;
102257
+ moduleResolutionCache.clear();
102258
+ typeReferenceDirectiveResolutionCache.clear();
102259
+ oldModuleAndTypeRefCache = undefined;
101532
102260
  hasChangedAutomaticTypeDirectiveNames = false;
101533
102261
  }
101534
102262
  function startRecordingFilesWithChangedResolutions() {
@@ -101539,13 +102267,6 @@ var ts;
101539
102267
  filesWithChangedSetOfUnresolvedImports = undefined;
101540
102268
  return collected;
101541
102269
  }
101542
- function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
101543
- if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
101544
- return false;
101545
- }
101546
- var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
101547
- return !!value && !!value.length;
101548
- }
101549
102270
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
101550
102271
  invalidateResolutionsOfFailedLookupLocations();
101551
102272
  if (forceAllFilesAsInvalidated) {
@@ -101554,46 +102275,162 @@ var ts;
101554
102275
  }
101555
102276
  var collected = filesWithInvalidatedResolutions;
101556
102277
  filesWithInvalidatedResolutions = undefined;
101557
- return function (path) { return (!!collected && collected.has(path)) ||
101558
- isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
102278
+ return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
101559
102279
  }
101560
- function clearPerDirectoryResolutions() {
102280
+ function startCachingPerDirectoryResolution() {
101561
102281
  moduleResolutionCache.clear();
101562
102282
  typeReferenceDirectiveResolutionCache.clear();
101563
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101564
- nonRelativeExternalModuleResolutions.clear();
102283
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
102284
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
102285
+ if (oldModuleAndTypeRefCache) {
102286
+ oldModuleAndTypeRefCache.clearRedirectsMap();
102287
+ moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
102288
+ typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
102289
+ }
101565
102290
  }
101566
- function finishCachingPerDirectoryResolution() {
101567
- filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
101568
- clearPerDirectoryResolutions();
101569
- directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
101570
- if (watcher.refCount === 0) {
101571
- directoryWatchesOfFailedLookups.delete(path);
101572
- watcher.watcher.close();
102291
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
102292
+ hasChangedAutomaticTypeDirectiveNames = false;
102293
+ if (!newProgram) {
102294
+ clear();
102295
+ return;
102296
+ }
102297
+ if (newProgram === oldProgram || newProgram.structureIsReused === 3)
102298
+ return;
102299
+ var modules;
102300
+ var typeRefs;
102301
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
102302
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
102303
+ var f = _a[_i];
102304
+ modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, f.resolvedModules, f, getResolvedModule, modules, moduleNameToDirectoryMap);
102305
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, f.resolvedTypeReferenceDirectiveNames, f, getResolvedTypeReferenceDirective, typeRefs, undefined);
102306
+ }
102307
+ var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
102308
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirective, typeRefs, undefined);
102309
+ if (!modules && !typeRefs) {
102310
+ oldModuleAndTypeRefCache = undefined;
102311
+ }
102312
+ else {
102313
+ oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
102314
+ }
102315
+ if (oldProgram) {
102316
+ for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
102317
+ var f = _c[_b];
102318
+ if (!newProgram.getSourceFileByPath(f.path))
102319
+ removeResolutionsOfFile(f.path);
101573
102320
  }
101574
- });
101575
- fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
101576
- if (watcher.refCount === 0) {
101577
- fileWatchesOfAffectingLocations.delete(path);
101578
- watcher.watcher.close();
101579
- watcher.watcher = ts.noopFileWatcher;
102321
+ var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
102322
+ if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
102323
+ removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
101580
102324
  }
101581
- });
101582
- hasChangedAutomaticTypeDirectiveNames = false;
102325
+ }
102326
+ if (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions())
102327
+ updateTypeRootsWatch();
102328
+ resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
102329
+ resolutionsToCloseWatcherOn = undefined;
102330
+ fileWatchesOfAffectingLocations.forEach(closeAffectingFileWatcher);
102331
+ }
102332
+ function closeAffectingFileWatcher(watcher, path) {
102333
+ if (watcher.refCount === 0) {
102334
+ fileWatchesOfAffectingLocations.delete(path);
102335
+ watcher.watcher.close();
102336
+ watcher.watcher = ts.noopFileWatcher;
102337
+ }
102338
+ }
102339
+ function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
102340
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102341
+ var resolutionsInFile = perFileCache.get(path);
102342
+ var seenNamesInFile = ts.createModeAwareCache();
102343
+ if (fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()) {
102344
+ var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
102345
+ var options_3 = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
102346
+ var key_2 = ts.getRedirectsCacheKey(options_3);
102347
+ if (resolutionsInFile && resolutionsInFile.key !== key_2) {
102348
+ resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102349
+ resolutionsInFile = undefined;
102350
+ }
102351
+ var dirPath_1 = ts.getDirectoryPath(path);
102352
+ var perDirResolutionCache_1 = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
102353
+ var cacheForDir_1 = perDirResolutionCache_1 === null || perDirResolutionCache_1 === void 0 ? void 0 : perDirResolutionCache_1.get(dirPath_1);
102354
+ fileCacheFromProgram.forEach(function (r, name, mode) {
102355
+ seenNamesInFile.set(name, mode, true);
102356
+ var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
102357
+ if (existing && r !== existing)
102358
+ stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
102359
+ watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
102360
+ if (!resolutionsInFile)
102361
+ perFileCache.set(path, resolutionsInFile = { key: key_2, cache: ts.createModeAwareCache() });
102362
+ resolutionsInFile.cache.set(name, mode, r);
102363
+ if (cacheForDir_1 === null || cacheForDir_1 === void 0 ? void 0 : cacheForDir_1.has(name, mode))
102364
+ return;
102365
+ if (!cacheForDir_1) {
102366
+ perDirResolutionCache_1 !== null && perDirResolutionCache_1 !== void 0 ? perDirResolutionCache_1 : (perDirResolutionCache_1 = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options_3, key_2));
102367
+ perDirResolutionCache_1.set(dirPath_1, cacheForDir_1 = ts.createModeAwareCache());
102368
+ }
102369
+ cacheForDir_1.set(name, mode, r);
102370
+ if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102371
+ return;
102372
+ var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options_3, key_2);
102373
+ var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
102374
+ var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
102375
+ if (!directoryPathMap)
102376
+ actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
102377
+ ts.moduleNameToDirectorySet(directoryPathMap, dirPath_1, r, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102378
+ });
102379
+ }
102380
+ if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
102381
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102382
+ if (!seenNamesInFile.has(name, mode)) {
102383
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102384
+ resolutionsInFile.cache.delete(name, mode);
102385
+ }
102386
+ });
102387
+ if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
102388
+ perFileCache.delete(path);
102389
+ }
102390
+ return perDirCache;
102391
+ }
102392
+ function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
102393
+ if (!modules && !typeRefs)
102394
+ return undefined;
102395
+ return {
102396
+ modules: {
102397
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
102398
+ },
102399
+ typeRefs: {
102400
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, undefined); }
102401
+ },
102402
+ clearRedirectsMap: function () {
102403
+ modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
102404
+ typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
102405
+ moduleNameToDirectoryMap.clearRedirectsMap();
102406
+ },
102407
+ };
102408
+ }
102409
+ function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
102410
+ var _a, _b, _c, _d;
102411
+ if (!perDirCache)
102412
+ return undefined;
102413
+ 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)) ||
102414
+ ((_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));
102415
+ return result && !result.isInvalidated ? result : undefined;
101583
102416
  }
101584
102417
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
101585
- var _a, _b;
102418
+ var _a;
101586
102419
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
101587
102420
  if (!resolutionHost.getGlobalCache) {
101588
102421
  return primaryResult;
101589
102422
  }
101590
102423
  var globalCache = resolutionHost.getGlobalCache();
101591
102424
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
101592
- 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;
102425
+ 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;
101593
102426
  if (resolvedModule) {
101594
102427
  primaryResult.resolvedModule = resolvedModule;
101595
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
101596
- (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
102428
+ if (!compilerOptions.cacheResolutions)
102429
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
102430
+ else
102431
+ primaryResult.failedLookupLocations.length = 0;
102432
+ primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102433
+ primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
101597
102434
  return primaryResult;
101598
102435
  }
101599
102436
  }
@@ -101603,68 +102440,35 @@ var ts;
101603
102440
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
101604
102441
  }
101605
102442
  function resolveNamesWithLocalCache(_a) {
101606
- var _b, _c, _d;
101607
- 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;
102443
+ var _b, _c, _d, _e;
102444
+ 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;
101608
102445
  var path = resolutionHost.toPath(containingFile);
101609
- var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
101610
- var dirPath = ts.getDirectoryPath(path);
101611
- var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
101612
- var perDirectoryResolution = perDirectoryCache.get(dirPath);
101613
- if (!perDirectoryResolution) {
101614
- perDirectoryResolution = ts.createModeAwareCache();
101615
- perDirectoryCache.set(dirPath, perDirectoryResolution);
102446
+ var resolutionsInFile = perFileCache.get(path);
102447
+ var compilerOptions = resolutionHost.getCompilationSettings();
102448
+ var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
102449
+ if (!resolutionsInFile || resolutionsInFile.key !== key) {
102450
+ resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102451
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
101616
102452
  }
101617
102453
  var resolvedModules = [];
101618
- var compilerOptions = resolutionHost.getCompilationSettings();
101619
- var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
101620
- var program = resolutionHost.getCurrentProgram();
101621
- var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
101622
- var unmatchedRedirects = oldRedirect ?
101623
- !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
101624
- !!redirectedReference;
101625
102454
  var seenNamesInFile = ts.createModeAwareCache();
101626
102455
  var i = 0;
101627
- for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
101628
- var entry = names_5[_i];
101629
- var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
102456
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
102457
+ var entry = names_4[_i];
102458
+ var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
101630
102459
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
101631
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
102460
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
101632
102461
  i++;
101633
- var resolution = resolutionsInFile.get(name, mode);
101634
- if (!seenNamesInFile.has(name, mode) &&
101635
- unmatchedRedirects || !resolution || resolution.isInvalidated ||
101636
- (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
102462
+ var resolution = resolutionsInFile.cache.get(name, mode);
102463
+ if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
101637
102464
  var existingResolution = resolution;
101638
- var resolutionInDirectory = perDirectoryResolution.get(name, mode);
101639
- if (resolutionInDirectory) {
101640
- resolution = resolutionInDirectory;
101641
- var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
101642
- if (ts.isTraceEnabled(compilerOptions, host)) {
101643
- var resolved = getResolutionWithResolvedFileName(resolution);
101644
- ts.trace(host, loader === resolveModuleName ?
101645
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101646
- resolved.packagetId ?
101647
- 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 :
101648
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101649
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
101650
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101651
- resolved.packagetId ?
101652
- 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 :
101653
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101654
- 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));
101655
- }
101656
- }
101657
- else {
101658
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
101659
- perDirectoryResolution.set(name, mode, resolution);
101660
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
101661
- resolutionHost.onDiscoveredSymlink();
101662
- }
102465
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102466
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102467
+ resolutionHost.onDiscoveredSymlink();
101663
102468
  }
101664
- resolutionsInFile.set(name, mode, resolution);
101665
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
102469
+ resolutionsInFile.cache.set(name, mode, resolution);
101666
102470
  if (existingResolution) {
101667
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
102471
+ stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
101668
102472
  }
101669
102473
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
101670
102474
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -101677,27 +102481,33 @@ var ts;
101677
102481
  var resolved = getResolutionWithResolvedFileName(resolution);
101678
102482
  ts.trace(host, loader === resolveModuleName ?
101679
102483
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101680
- resolved.packagetId ?
102484
+ resolved.packageId ?
101681
102485
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101682
102486
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101683
102487
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
101684
102488
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101685
- resolved.packagetId ?
102489
+ resolved.packageId ?
101686
102490
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101687
102491
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101688
- 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));
102492
+ 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));
101689
102493
  }
101690
102494
  }
101691
102495
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
101692
102496
  seenNamesInFile.set(name, mode, true);
101693
- resolvedModules.push(getResolutionWithResolvedFileName(resolution));
102497
+ resolvedModules.push(resolution);
101694
102498
  }
101695
- resolutionsInFile.forEach(function (resolution, name, mode) {
101696
- if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
101697
- stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
101698
- resolutionsInFile.delete(name, mode);
101699
- }
102499
+ (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
102500
+ var name = _a.name, mode = _a.mode;
102501
+ return seenNamesInFile.set(name, mode, true);
101700
102502
  });
102503
+ if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
102504
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102505
+ if (!seenNamesInFile.has(name, mode)) {
102506
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102507
+ resolutionsInFile.cache.delete(name, mode);
102508
+ }
102509
+ });
102510
+ }
101701
102511
  return resolvedModules;
101702
102512
  function resolutionIsEqualTo(oldResolution, newResolution) {
101703
102513
  if (oldResolution === newResolution) {
@@ -101717,40 +102527,31 @@ var ts;
101717
102527
  return oldResult.resolvedFileName === newResult.resolvedFileName;
101718
102528
  }
101719
102529
  }
101720
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
102530
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
101721
102531
  return resolveNamesWithLocalCache({
101722
102532
  names: typeDirectiveNames,
101723
102533
  containingFile: containingFile,
101724
102534
  redirectedReference: redirectedReference,
101725
- cache: resolvedTypeReferenceDirectives,
101726
- perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
102535
+ perFileCache: resolvedTypeReferenceDirectives,
101727
102536
  loader: resolveTypeReferenceDirective,
101728
102537
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
101729
- shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
101730
- containingSourceFileMode: containingFileMode
102538
+ containingSourceFileMode: containingFileMode,
102539
+ partialResolutionInfo: partialResolutionInfo,
101731
102540
  });
101732
102541
  }
101733
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
102542
+ function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
101734
102543
  return resolveNamesWithLocalCache({
101735
102544
  names: moduleNames,
101736
102545
  containingFile: containingFile,
101737
102546
  redirectedReference: redirectedReference,
101738
- cache: resolvedModuleNames,
101739
- perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
102547
+ perFileCache: resolvedModuleNames,
101740
102548
  loader: resolveModuleName,
101741
102549
  getResolutionWithResolvedFileName: getResolvedModule,
101742
- shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
101743
- reusedNames: reusedNames,
102550
+ partialResolutionInfo: partialResolutionInfo,
101744
102551
  logChanges: logChangesWhenResolvingModule,
101745
102552
  containingSourceFile: containingSourceFile,
101746
102553
  });
101747
102554
  }
101748
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
101749
- var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
101750
- if (!cache)
101751
- return undefined;
101752
- return cache.get(moduleName, resolutionMode);
101753
- }
101754
102555
  function isNodeModulesAtTypesDirectory(dirPath) {
101755
102556
  return ts.endsWith(dirPath, "/node_modules/@types");
101756
102557
  }
@@ -101804,37 +102605,41 @@ var ts;
101804
102605
  function isPathWithDefaultFailedLookupExtension(path) {
101805
102606
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
101806
102607
  }
101807
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
101808
- if (resolution.refCount) {
101809
- resolution.refCount++;
101810
- ts.Debug.assertIsDefined(resolution.files);
102608
+ function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
102609
+ if (resolution.files) {
102610
+ resolution.files.add(filePath);
102611
+ if (resolution.watchedFailed !== false)
102612
+ watchFailedLookupLocationOfResolution(resolution);
102613
+ watchAffectingLocationsOfResolution(resolution);
102614
+ return;
102615
+ }
102616
+ resolution.files = new ts.Set();
102617
+ resolution.files.add(filePath);
102618
+ var resolved = getResolutionWithResolvedFileName(resolution);
102619
+ if (resolved && resolved.resolvedFileName) {
102620
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102621
+ }
102622
+ if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
102623
+ watchFailedLookupLocationOfResolution(resolution);
102624
+ watchAffectingLocationsOfResolution(resolution);
101811
102625
  }
101812
102626
  else {
101813
- resolution.refCount = 1;
101814
- ts.Debug.assert(ts.length(resolution.files) === 0);
101815
- if (ts.isExternalModuleNameRelative(name)) {
101816
- watchFailedLookupLocationOfResolution(resolution);
101817
- }
101818
- else {
101819
- nonRelativeExternalModuleResolutions.add(name, resolution);
101820
- }
101821
- var resolved = getResolutionWithResolvedFileName(resolution);
101822
- if (resolved && resolved.resolvedFileName) {
101823
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
101824
- }
102627
+ resolution.watchedFailed = false;
102628
+ watchAffectingLocationsOfResolution(resolution);
101825
102629
  }
101826
- (resolution.files || (resolution.files = [])).push(filePath);
101827
102630
  }
101828
102631
  function watchFailedLookupLocationOfResolution(resolution) {
101829
- ts.Debug.assert(!!resolution.refCount);
101830
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
101831
- if (!failedLookupLocations.length && !affectingLocations.length)
102632
+ var failedLookupLocations = resolution.failedLookupLocations;
102633
+ if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
101832
102634
  return;
101833
- if (failedLookupLocations.length)
102635
+ if (!resolution.watchedFailed) {
101834
102636
  resolutionsWithFailedLookups.push(resolution);
101835
- var setAtRoot = false;
101836
- for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
101837
- var failedLookupLocation = failedLookupLocations_1[_i];
102637
+ if (resolution.watchedAffected)
102638
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102639
+ }
102640
+ var setAtRoot = !!resolution.setAtRoot;
102641
+ for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
102642
+ var failedLookupLocation = failedLookupLocations[i];
101838
102643
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
101839
102644
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
101840
102645
  if (toWatch) {
@@ -101852,22 +102657,22 @@ var ts;
101852
102657
  }
101853
102658
  }
101854
102659
  }
101855
- if (setAtRoot) {
102660
+ if (setAtRoot && !resolution.setAtRoot) {
101856
102661
  setDirectoryWatcher(rootDir, rootPath, true);
101857
102662
  }
101858
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
102663
+ resolution.setAtRoot = setAtRoot;
102664
+ resolution.watchedFailed = failedLookupLocations.length;
101859
102665
  }
101860
- function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
101861
- ts.Debug.assert(!!resolution.refCount);
102666
+ function watchAffectingLocationsOfResolution(resolution) {
101862
102667
  var affectingLocations = resolution.affectingLocations;
101863
- if (!affectingLocations.length)
102668
+ if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
101864
102669
  return;
101865
- if (addToResolutionsWithOnlyAffectingLocations)
102670
+ if (!resolution.watchedFailed && !resolution.watchedAffected)
101866
102671
  resolutionsWithOnlyAffectingLocations.push(resolution);
101867
- for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
101868
- var affectingLocation = affectingLocations_1[_i];
101869
- createFileWatcherOfAffectingLocation(affectingLocation);
102672
+ for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
102673
+ createFileWatcherOfAffectingLocation(affectingLocations[i]);
101870
102674
  }
102675
+ resolution.watchedAffected = affectingLocations.length;
101871
102676
  }
101872
102677
  function createFileWatcherOfAffectingLocation(affectingLocation) {
101873
102678
  var path = resolutionHost.toPath(affectingLocation);
@@ -101908,15 +102713,6 @@ var ts;
101908
102713
  paths.add(path);
101909
102714
  }
101910
102715
  }
101911
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
101912
- var program = resolutionHost.getCurrentProgram();
101913
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
101914
- resolutions.forEach(watchFailedLookupLocationOfResolution);
101915
- }
101916
- else {
101917
- resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); });
101918
- }
101919
- }
101920
102716
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
101921
102717
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
101922
102718
  if (dirWatcher) {
@@ -101927,21 +102723,27 @@ var ts;
101927
102723
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
101928
102724
  }
101929
102725
  }
101930
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
101931
- ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
101932
- resolution.refCount--;
101933
- if (resolution.refCount) {
102726
+ function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102727
+ var _a, _b;
102728
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
102729
+ if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
102730
+ (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
102731
+ }
102732
+ function closeWatchersOfResolution(_a) {
102733
+ var _b;
102734
+ var resolution = _a.resolution, getResolved = _a.getResolved;
102735
+ if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
101934
102736
  return;
101935
- }
101936
- var resolved = getResolutionWithResolvedFileName(resolution);
102737
+ resolution.files = undefined;
102738
+ var resolved = getResolved(resolution);
101937
102739
  if (resolved && resolved.resolvedFileName) {
101938
102740
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
101939
102741
  }
101940
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
101941
- if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
102742
+ if (resolution.watchedFailed) {
102743
+ ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
101942
102744
  var removeAtRoot = false;
101943
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
101944
- var failedLookupLocation = failedLookupLocations_2[_i];
102745
+ for (var i = 0; i < resolution.watchedFailed; i++) {
102746
+ var failedLookupLocation = resolution.failedLookupLocations[i];
101945
102747
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
101946
102748
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
101947
102749
  if (toWatch) {
@@ -101964,22 +102766,31 @@ var ts;
101964
102766
  }
101965
102767
  }
101966
102768
  }
102769
+ ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
101967
102770
  if (removeAtRoot) {
101968
102771
  removeDirectoryWatcher(rootPath);
101969
102772
  }
101970
102773
  }
101971
- else if (affectingLocations.length) {
102774
+ else if (resolution.watchedAffected) {
101972
102775
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
101973
102776
  }
101974
- for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
101975
- var affectingLocation = affectingLocations_2[_a];
101976
- var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
101977
- watcher.refCount--;
102777
+ if (resolution.watchedAffected) {
102778
+ for (var i = 0; i < resolution.watchedAffected; i++) {
102779
+ var affectingLocation = resolution.affectingLocations[i];
102780
+ var path = resolutionHost.toPath(affectingLocation);
102781
+ var watcher = fileWatchesOfAffectingLocations.get(path);
102782
+ watcher.refCount--;
102783
+ closeAffectingFileWatcher(watcher, path);
102784
+ }
101978
102785
  }
101979
102786
  }
101980
102787
  function removeDirectoryWatcher(dirPath) {
101981
102788
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
101982
102789
  dirWatcher.refCount--;
102790
+ if (dirWatcher.refCount === 0) {
102791
+ directoryWatchesOfFailedLookups.delete(dirPath);
102792
+ dirWatcher.watcher.close();
102793
+ }
101983
102794
  }
101984
102795
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
101985
102796
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -101993,26 +102804,16 @@ var ts;
101993
102804
  function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
101994
102805
  var resolutions = cache.get(filePath);
101995
102806
  if (resolutions) {
101996
- resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
102807
+ resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
101997
102808
  cache.delete(filePath);
101998
102809
  }
101999
102810
  }
102000
- function removeResolutionsFromProjectReferenceRedirects(filePath) {
102001
- if (!ts.fileExtensionIs(filePath, ".json"))
102002
- return;
102003
- var program = resolutionHost.getCurrentProgram();
102004
- if (!program)
102005
- return;
102006
- var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
102007
- if (!resolvedProjectReference)
102008
- return;
102009
- resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
102010
- }
102011
102811
  function removeResolutionsOfFile(filePath) {
102012
102812
  removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
102013
102813
  removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
102014
102814
  }
102015
102815
  function invalidateResolutions(resolutions, canInvalidate) {
102816
+ var _a;
102016
102817
  if (!resolutions)
102017
102818
  return false;
102018
102819
  var invalidated = false;
@@ -102021,16 +102822,14 @@ var ts;
102021
102822
  if (resolution.isInvalidated || !canInvalidate(resolution))
102022
102823
  continue;
102023
102824
  resolution.isInvalidated = invalidated = true;
102024
- for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102025
- var containingFilePath = _b[_a];
102825
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
102026
102826
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102027
102827
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
102028
- }
102828
+ });
102029
102829
  }
102030
102830
  return invalidated;
102031
102831
  }
102032
102832
  function invalidateResolutionOfFile(filePath) {
102033
- removeResolutionsOfFile(filePath);
102034
102833
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
102035
102834
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
102036
102835
  hasChangedAutomaticTypeDirectiveNames &&
@@ -102039,8 +102838,28 @@ var ts;
102039
102838
  }
102040
102839
  }
102041
102840
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
102042
- ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
102043
- filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
102841
+ filesMap.forEach(function (_a, filePath) {
102842
+ var imports = _a.imports;
102843
+ if (!imports.length)
102844
+ return;
102845
+ var resolvedModules = resolvedModuleNames.get(filePath);
102846
+ var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
102847
+ if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
102848
+ return;
102849
+ imports.forEach(function (_a) {
102850
+ var name = _a.name, mode = _a.mode;
102851
+ var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
102852
+ if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
102853
+ resolvedModule.isInvalidated = true;
102854
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
102855
+ }
102856
+ var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
102857
+ if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
102858
+ resolvedTypeRef.isInvalidated = true;
102859
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
102860
+ }
102861
+ });
102862
+ });
102044
102863
  }
102045
102864
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
102046
102865
  if (isCreatingWatchedDirectory) {
@@ -102100,9 +102919,10 @@ var ts;
102100
102919
  });
102101
102920
  }
102102
102921
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102103
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
102922
+ var _a;
102923
+ return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) {
102104
102924
  return affectingPathChecks.has(resolutionHost.toPath(location));
102105
- });
102925
+ }));
102106
102926
  }
102107
102927
  function closeTypeRootsWatch() {
102108
102928
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -102404,9 +103224,9 @@ var ts;
102404
103224
  var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
102405
103225
  var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
102406
103226
  if (!preferSymlinks) {
102407
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
102408
- if (result_16)
102409
- return result_16;
103227
+ var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
103228
+ if (result_17)
103229
+ return result_17;
102410
103230
  }
102411
103231
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
102412
103232
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -102425,10 +103245,10 @@ var ts;
102425
103245
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
102426
103246
  var symlinkDirectory = symlinkDirectories_1[_i];
102427
103247
  var option = ts.resolvePath(symlinkDirectory, relative);
102428
- var result_17 = cb(option, target === referenceRedirect);
103248
+ var result_18 = cb(option, target === referenceRedirect);
102429
103249
  shouldFilterIgnoredPaths = true;
102430
- if (result_17)
102431
- return result_17;
103250
+ if (result_18)
103251
+ return result_18;
102432
103252
  }
102433
103253
  });
102434
103254
  });
@@ -102487,9 +103307,9 @@ var ts;
102487
103307
  };
102488
103308
  var out_directory_1;
102489
103309
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
102490
- var state_11 = _loop_35(directory);
103310
+ var state_12 = _loop_35(directory);
102491
103311
  directory = out_directory_1;
102492
- if (state_11 === "break")
103312
+ if (state_12 === "break")
102493
103313
  break;
102494
103314
  }
102495
103315
  if (allFileNames.size) {
@@ -103369,7 +104189,7 @@ var ts;
103369
104189
  })(ts || (ts = {}));
103370
104190
  var ts;
103371
104191
  (function (ts) {
103372
- function readBuilderProgram(compilerOptions, host) {
104192
+ function readBuildInfoForProgram(compilerOptions, host) {
103373
104193
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
103374
104194
  if (!buildInfoPath)
103375
104195
  return undefined;
@@ -103389,7 +104209,12 @@ var ts;
103389
104209
  return undefined;
103390
104210
  if (!buildInfo.program)
103391
104211
  return undefined;
103392
- return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
104212
+ return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
104213
+ }
104214
+ ts.readBuildInfoForProgram = readBuildInfoForProgram;
104215
+ function readBuilderProgram(compilerOptions, host) {
104216
+ var result = readBuildInfoForProgram(compilerOptions, host);
104217
+ return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
103393
104218
  }
103394
104219
  ts.readBuilderProgram = readBuilderProgram;
103395
104220
  function createIncrementalCompilerHost(options, system) {
@@ -103522,7 +104347,7 @@ var ts;
103522
104347
  }
103523
104348
  return host.resolveModuleNames.apply(host, args);
103524
104349
  }) :
103525
- (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
104350
+ (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
103526
104351
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
103527
104352
  (function () {
103528
104353
  var args = [];
@@ -103531,7 +104356,13 @@ var ts;
103531
104356
  }
103532
104357
  return host.resolveTypeReferenceDirectives.apply(host, args);
103533
104358
  }) :
103534
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
104359
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
104360
+ compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
104361
+ ts.maybeBind(host, host.getModuleResolutionCache) :
104362
+ (function () { return resolutionCache.getModuleResolutionCache(); });
104363
+ compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
104364
+ ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
104365
+ (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
103535
104366
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103536
104367
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
103537
104368
  synchronizeProgram();
@@ -103597,7 +104428,8 @@ var ts;
103597
104428
  }
103598
104429
  }
103599
104430
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
103600
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
104431
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
104432
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103601
104433
  if (hasChangedConfigFileParsingErrors) {
103602
104434
  if (reportFileChangeDetectedOnCreateProgram) {
103603
104435
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -103616,6 +104448,11 @@ var ts;
103616
104448
  if (host.afterProgramCreate && program !== builderProgram) {
103617
104449
  host.afterProgramCreate(builderProgram);
103618
104450
  }
104451
+ compilerHost.readFile = originalReadFile;
104452
+ compilerHost.fileExists = originalFileExists;
104453
+ compilerHost.directoryExists = originalDirectoryExists;
104454
+ compilerHost.createDirectory = originalCreateDirectory;
104455
+ compilerHost.writeFile = originalWriteFile;
103619
104456
  return builderProgram;
103620
104457
  }
103621
104458
  function createNewProgram(hasInvalidatedResolution) {
@@ -103624,18 +104461,15 @@ var ts;
103624
104461
  writeLog(" options: " + JSON.stringify(compilerOptions));
103625
104462
  if (projectReferences)
103626
104463
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
103627
- var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
103628
104464
  hasChangedCompilerOptions = false;
103629
104465
  hasChangedConfigFileParsingErrors = false;
103630
104466
  resolutionCache.startCachingPerDirectoryResolution();
103631
104467
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
103632
104468
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
104469
+ var oldProgram = getCurrentProgram();
103633
104470
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
103634
- resolutionCache.finishCachingPerDirectoryResolution();
104471
+ resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
103635
104472
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
103636
- if (needsUpdateInTypeRootWatch) {
103637
- resolutionCache.updateTypeRootsWatch();
103638
- }
103639
104473
  if (missingFilePathsRequestedForRelease) {
103640
104474
  for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
103641
104475
  var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
@@ -103701,9 +104535,6 @@ var ts;
103701
104535
  sourceFilesCache.set(path, false);
103702
104536
  }
103703
104537
  }
103704
- if (sourceFile) {
103705
- sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
103706
- }
103707
104538
  return sourceFile;
103708
104539
  }
103709
104540
  return hostSourceFile.sourceFile;
@@ -103723,7 +104554,7 @@ var ts;
103723
104554
  var hostSourceFile = sourceFilesCache.get(path);
103724
104555
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
103725
104556
  }
103726
- function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
104557
+ function onReleaseOldSourceFile(oldSourceFile) {
103727
104558
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
103728
104559
  if (hostSourceFileInfo !== undefined) {
103729
104560
  if (isFileMissingOnHost(hostSourceFileInfo)) {
@@ -103734,9 +104565,6 @@ var ts;
103734
104565
  hostSourceFileInfo.fileWatcher.close();
103735
104566
  }
103736
104567
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
103737
- if (!hasSourceFileByPath) {
103738
- resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
103739
- }
103740
104568
  }
103741
104569
  }
103742
104570
  }
@@ -103971,7 +104799,6 @@ var ts;
103971
104799
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
103972
104800
  if (config)
103973
104801
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
103974
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
103975
104802
  }
103976
104803
  scheduleProgramUpdate();
103977
104804
  });
@@ -103984,7 +104811,6 @@ var ts;
103984
104811
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
103985
104812
  if (config)
103986
104813
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
103987
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
103988
104814
  scheduleProgramUpdate();
103989
104815
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
103990
104816
  if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) {
@@ -104156,20 +104982,23 @@ var ts;
104156
104982
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
104157
104983
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
104158
104984
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
104985
+ compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
104986
+ compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
104159
104987
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
104160
104988
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
104161
104989
  if (!compilerHost.resolveModuleNames) {
104162
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
104163
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
104164
- return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
104990
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
104991
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
104992
+ return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
104165
104993
  };
104166
104994
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
104167
104995
  }
104168
104996
  if (!compilerHost.resolveTypeReferenceDirectives) {
104169
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
104997
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
104170
104998
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
104171
- return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
104999
+ return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
104172
105000
  };
105001
+ compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
104173
105002
  }
104174
105003
  compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), undefined); };
104175
105004
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -105113,7 +105942,7 @@ var ts;
105113
105942
  if (buildInfoTime && buildInfoTime < inputTime) {
105114
105943
  var version_3 = void 0;
105115
105944
  var currentVersion = void 0;
105116
- if (buildInfoProgram) {
105945
+ if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
105117
105946
  if (!buildInfoVersionMap)
105118
105947
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
105119
105948
  version_3 = buildInfoVersionMap.get(toPath(state, inputFile));