@typescript-deploys/pr-build 4.9.0-pr-50248-2 → 4.9.0-pr-50247-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
@@ -6645,6 +6645,8 @@ var ts;
6645
6645
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
6646
6646
  Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, ts.DiagnosticCategory.Message, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
6647
6647
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
6648
+ Directory_0_resolves_to_1_scope_according_to_cache: diag(6263, ts.DiagnosticCategory.Message, "Directory_0_resolves_to_1_scope_according_to_cache_6263", "Directory '{0}' resolves to '{1}' scope according to cache."),
6649
+ Directory_0_has_no_containing_package_json_scope_according_to_cache: diag(6264, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_according_to_cache_6264", "Directory '{0}' has no containing package.json scope according to cache."),
6648
6650
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
6649
6651
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
6650
6652
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, ts.DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -6828,6 +6830,7 @@ var ts;
6828
6830
  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."),
6829
6831
  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."),
6830
6832
  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."),
6833
+ 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."),
6831
6834
  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'."),
6832
6835
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
6833
6836
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -10965,7 +10968,8 @@ var ts;
10965
10968
  }
10966
10969
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
10967
10970
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
10968
- return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10971
+ return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
10972
+ optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10969
10973
  }
10970
10974
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
10971
10975
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -11037,21 +11041,20 @@ var ts;
11037
11041
  }
11038
11042
  ts.getFullWidth = getFullWidth;
11039
11043
  function getResolvedModule(sourceFile, moduleNameText, mode) {
11040
- return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
11044
+ var _a, _b;
11045
+ 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;
11041
11046
  }
11042
11047
  ts.getResolvedModule = getResolvedModule;
11043
11048
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
11044
- if (!sourceFile.resolvedModules) {
11045
- sourceFile.resolvedModules = ts.createModeAwareCache();
11046
- }
11049
+ var _a;
11050
+ (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
11047
11051
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
11048
11052
  }
11049
11053
  ts.setResolvedModule = setResolvedModule;
11050
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
11051
- if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
11052
- sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
11053
- }
11054
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, undefined, resolvedTypeReferenceDirective);
11054
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
11055
+ var _a;
11056
+ (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
11057
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
11055
11058
  }
11056
11059
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
11057
11060
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -11061,11 +11064,15 @@ var ts;
11061
11064
  }
11062
11065
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
11063
11066
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
11064
- return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
11065
- oldResolution.extension === newResolution.extension &&
11066
- oldResolution.resolvedFileName === newResolution.resolvedFileName &&
11067
- oldResolution.originalPath === newResolution.originalPath &&
11068
- packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
11067
+ return oldResolution === newResolution ||
11068
+ oldResolution.resolvedModule === newResolution.resolvedModule ||
11069
+ !!oldResolution.resolvedModule &&
11070
+ !!newResolution.resolvedModule &&
11071
+ oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
11072
+ oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
11073
+ oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
11074
+ oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
11075
+ packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
11069
11076
  }
11070
11077
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
11071
11078
  function packageIdIsEqual(a, b) {
@@ -11081,9 +11088,13 @@ var ts;
11081
11088
  }
11082
11089
  ts.packageIdToString = packageIdToString;
11083
11090
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
11084
- return oldResolution.resolvedFileName === newResolution.resolvedFileName
11085
- && oldResolution.primary === newResolution.primary
11086
- && oldResolution.originalPath === newResolution.originalPath;
11091
+ return oldResolution === newResolution ||
11092
+ oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
11093
+ !!oldResolution.resolvedTypeReferenceDirective &&
11094
+ !!newResolution.resolvedTypeReferenceDirective &&
11095
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
11096
+ !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
11097
+ oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
11087
11098
  }
11088
11099
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
11089
11100
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -15282,22 +15293,20 @@ var ts;
15282
15293
  return getStringFromExpandedCharCodes(expandedCharCodes);
15283
15294
  }
15284
15295
  ts.base64decode = base64decode;
15285
- function readJson(path, host) {
15286
- try {
15287
- var jsonText = host.readFile(path);
15288
- if (!jsonText)
15289
- return {};
15290
- var result = ts.parseConfigFileTextToJson(path, jsonText);
15291
- if (result.error) {
15292
- return {};
15293
- }
15294
- return result.config;
15295
- }
15296
- catch (e) {
15296
+ function readJsonIgnoringErrors(path, host) {
15297
+ return readJsonIgnoringErrorsFromText(path, host.readFile(path));
15298
+ }
15299
+ ts.readJsonIgnoringErrors = readJsonIgnoringErrors;
15300
+ function readJsonIgnoringErrorsFromText(path, jsonText) {
15301
+ if (!jsonText)
15302
+ return {};
15303
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
15304
+ if (result.error) {
15297
15305
  return {};
15298
15306
  }
15307
+ return result.config;
15299
15308
  }
15300
- ts.readJson = readJson;
15309
+ ts.readJsonIgnoringErrorsFromText = readJsonIgnoringErrorsFromText;
15301
15310
  function directoryProbablyExists(directoryName, host) {
15302
15311
  return !host.directoryExists || host.directoryExists(directoryName);
15303
15312
  }
@@ -16275,14 +16284,15 @@ var ts;
16275
16284
  },
16276
16285
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
16277
16286
  var _this = this;
16278
- var _a;
16287
+ var _a, _b;
16279
16288
  ts.Debug.assert(!hasProcessedResolutions);
16280
16289
  hasProcessedResolutions = true;
16281
16290
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
16282
16291
  var file = files_1[_i];
16283
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
16292
+ (_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); });
16293
+ (_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); });
16284
16294
  }
16285
- typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
16295
+ typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
16286
16296
  },
16287
16297
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
16288
16298
  };
@@ -32193,6 +32203,17 @@ var ts;
32193
32203
  transpileOptionValue: undefined,
32194
32204
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
32195
32205
  },
32206
+ {
32207
+ name: "cacheResolutions",
32208
+ type: "boolean",
32209
+ category: ts.Diagnostics.Projects,
32210
+ description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
32211
+ affectsModuleResolution: true,
32212
+ affectsMultiFileEmitBuildInfo: true,
32213
+ affectsBundleEmitBuildInfo: true,
32214
+ transpileOptionValue: undefined,
32215
+ defaultValueDescription: false,
32216
+ },
32196
32217
  {
32197
32218
  name: "assumeChangesOnlyAffectDirectDependencies",
32198
32219
  type: "boolean",
@@ -34149,6 +34170,9 @@ var ts;
34149
34170
  if (result.configFilePath) {
34150
34171
  result.configFilePath = toAbsolutePath(result.configFilePath);
34151
34172
  }
34173
+ if (result.pathsBasePath) {
34174
+ result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
34175
+ }
34152
34176
  return result;
34153
34177
  }
34154
34178
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -34974,20 +34998,35 @@ var ts;
34974
34998
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
34975
34999
  return { fileName: resolved.path, packageId: resolved.packageId };
34976
35000
  }
34977
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
34978
- var _a, _b;
35001
+ function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
35002
+ var _a;
35003
+ var _b;
34979
35004
  if (resultFromCache) {
34980
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
34981
- (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
35005
+ if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
35006
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
35007
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
35008
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
34982
35009
  return resultFromCache;
34983
35010
  }
34984
35011
  return {
34985
35012
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
34986
- failedLookupLocations: failedLookupLocations,
34987
- affectingLocations: affectingLocations,
34988
- resolutionDiagnostics: diagnostics,
35013
+ failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
35014
+ affectingLocations: initializeResolutionField(affectingLocations),
35015
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
34989
35016
  };
34990
35017
  }
35018
+ function initializeResolutionField(value) {
35019
+ return value.length ? value : undefined;
35020
+ }
35021
+ function updateResolutionField(to, value) {
35022
+ if (!(value === null || value === void 0 ? void 0 : value.length))
35023
+ return to;
35024
+ if (!(to === null || to === void 0 ? void 0 : to.length))
35025
+ return value;
35026
+ to.push.apply(to, value);
35027
+ return to;
35028
+ }
35029
+ ts.updateResolutionField = updateResolutionField;
34991
35030
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
34992
35031
  if (!ts.hasProperty(jsonContent, fieldName)) {
34993
35032
  if (state.traceEnabled) {
@@ -35126,8 +35165,7 @@ var ts;
35126
35165
  options = redirectedReference.commandLine.options;
35127
35166
  }
35128
35167
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
35129
- var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
35130
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35168
+ var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, resolutionMode, redirectedReference) : undefined;
35131
35169
  if (result) {
35132
35170
  if (traceEnabled) {
35133
35171
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35178,7 +35216,7 @@ var ts;
35178
35216
  features: features,
35179
35217
  conditions: conditions,
35180
35218
  requestContainingDirectory: containingDirectory,
35181
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35219
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35182
35220
  };
35183
35221
  var resolved = primaryLookup();
35184
35222
  var primary = true;
@@ -35198,8 +35236,15 @@ var ts;
35198
35236
  isExternalLibraryImport: pathContainsNodeModules(fileName),
35199
35237
  };
35200
35238
  }
35201
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
35202
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35239
+ result = {
35240
+ resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
35241
+ failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
35242
+ affectingLocations: initializeResolutionField(affectingLocations),
35243
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
35244
+ };
35245
+ if (containingDirectory && cache) {
35246
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35247
+ }
35203
35248
  if (traceEnabled)
35204
35249
  traceResult(result);
35205
35250
  return result;
@@ -35209,10 +35254,10 @@ var ts;
35209
35254
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
35210
35255
  }
35211
35256
  else if (result.resolvedTypeReferenceDirective.packageId) {
35212
- 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);
35257
+ 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);
35213
35258
  }
35214
35259
  else {
35215
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
35260
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
35216
35261
  }
35217
35262
  }
35218
35263
  function primaryLookup() {
@@ -35292,7 +35337,7 @@ var ts;
35292
35337
  var typeDirectivePath = _b[_a];
35293
35338
  var normalized = ts.normalizePath(typeDirectivePath);
35294
35339
  var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
35295
- var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
35340
+ var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJsonIgnoringErrors(packageJsonPath, host).typings === null;
35296
35341
  if (!isNotNeededPackage) {
35297
35342
  var baseFileName = ts.getBaseFileName(normalized);
35298
35343
  if (baseFileName.charCodeAt(0) !== 46) {
@@ -35307,62 +35352,181 @@ var ts;
35307
35352
  return result;
35308
35353
  }
35309
35354
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
35310
- function createCacheWithRedirects(options) {
35311
- var ownMap = new ts.Map();
35355
+ function getPackageJsconLocationFromScope(scope) {
35356
+ return ts.lastOrUndefined(scope.affectingLocations);
35357
+ }
35358
+ ts.getPackageJsconLocationFromScope = getPackageJsconLocationFromScope;
35359
+ function compilerOptionValueToString(value) {
35360
+ var _a;
35361
+ if (value === null || typeof value !== "object") {
35362
+ return "" + value;
35363
+ }
35364
+ if (ts.isArray(value)) {
35365
+ return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
35366
+ }
35367
+ var str = "{";
35368
+ for (var key in value) {
35369
+ if (ts.hasProperty(value, key)) {
35370
+ str += key + ": " + compilerOptionValueToString(value[key]);
35371
+ }
35372
+ }
35373
+ return str + "}";
35374
+ }
35375
+ function getKeyForCompilationSettings(settings, options) {
35376
+ return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
35377
+ }
35378
+ ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
35379
+ function getRedirectsCacheKey(options) {
35380
+ return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
35381
+ }
35382
+ ts.getRedirectsCacheKey = getRedirectsCacheKey;
35383
+ function createCacheWithRedirects(ownOptions) {
35384
+ var ownMap;
35385
+ var ownKey;
35386
+ var redirectsKeyToCache = new ts.Map();
35312
35387
  var redirectsMap = new ts.Map();
35313
35388
  return {
35314
35389
  getOwnMap: getOwnMap,
35315
- redirectsMap: redirectsMap,
35390
+ redirectsKeyToCache: redirectsKeyToCache,
35391
+ createMapForCompilerOptions: createMapForCompilerOptions,
35392
+ getMapOfCacheRedirects: getMapOfCacheRedirects,
35316
35393
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
35317
35394
  clear: clear,
35318
- setOwnOptions: setOwnOptions,
35319
- setOwnMap: setOwnMap
35395
+ update: update,
35396
+ clearRedirectsMap: function () { return redirectsMap.clear(); },
35320
35397
  };
35321
- function getOwnMap() {
35322
- return ownMap;
35398
+ function ensureOwnKeyCached() {
35399
+ ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
35400
+ if (ownKey && !redirectsKeyToCache.has(ownKey))
35401
+ redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
35323
35402
  }
35324
- function setOwnOptions(newOptions) {
35325
- options = newOptions;
35403
+ function createMapForCompilerOptions(options, optionsKey) {
35404
+ if (options === ownOptions)
35405
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35406
+ return getOrCreateRedirectMapAndKey(options, undefined, optionsKey);
35326
35407
  }
35327
- function setOwnMap(newOwnMap) {
35328
- ownMap = newOwnMap;
35408
+ function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
35409
+ var _a;
35410
+ if (path || options.configFile) {
35411
+ var redirects = redirectsMap.get(path || options.configFile.path);
35412
+ if (redirects)
35413
+ return redirects;
35414
+ }
35415
+ var key = optionsKey || getRedirectsCacheKey(options);
35416
+ var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
35417
+ if (!map) {
35418
+ ensureOwnKeyCached();
35419
+ if (ownKey === key) {
35420
+ map = ownMap;
35421
+ }
35422
+ else {
35423
+ redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
35424
+ }
35425
+ }
35426
+ if (path || options.configFile)
35427
+ redirectsMap.set(path || options.configFile.path, map);
35428
+ return map;
35329
35429
  }
35330
- function getOrCreateMapOfCacheRedirects(redirectedReference) {
35331
- if (!redirectedReference) {
35332
- return ownMap;
35430
+ function getOwnMap() {
35431
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35432
+ }
35433
+ function update(newOwnOptions) {
35434
+ if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
35435
+ ensureOwnKeyCached();
35436
+ if (!redirectsMap.has(ownOptions.configFile.path)) {
35437
+ redirectsMap.set(ownOptions.configFile.path, ownMap);
35438
+ }
35333
35439
  }
35334
- var path = redirectedReference.sourceFile.path;
35335
- var redirects = redirectsMap.get(path);
35336
- if (!redirects) {
35337
- redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
35338
- redirectsMap.set(path, redirects);
35440
+ if (newOwnOptions.configFile) {
35441
+ var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
35442
+ if (existing_1) {
35443
+ ownMap = existing_1;
35444
+ ownOptions = newOwnOptions;
35445
+ return;
35446
+ }
35339
35447
  }
35340
- return redirects;
35448
+ var key = getRedirectsCacheKey(newOwnOptions);
35449
+ var existing = redirectsKeyToCache.get(key);
35450
+ ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
35451
+ ownKey = key;
35452
+ ownOptions = newOwnOptions;
35453
+ if (newOwnOptions.configFile)
35454
+ redirectsMap.set(newOwnOptions.configFile.path, ownMap);
35455
+ }
35456
+ function getMapOfCacheRedirects(redirectedReference) {
35457
+ if (!redirectedReference)
35458
+ return ownMap;
35459
+ var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
35460
+ if (directResult)
35461
+ return directResult;
35462
+ var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
35463
+ var fromKey = redirectsKeyToCache.get(key);
35464
+ if (fromKey) {
35465
+ redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
35466
+ return fromKey.map;
35467
+ }
35468
+ if (ownMap)
35469
+ ensureOwnKeyCached();
35470
+ if (ownKey === key) {
35471
+ redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
35472
+ return ownMap;
35473
+ }
35474
+ return undefined;
35475
+ }
35476
+ function getOrCreateMapOfCacheRedirects(redirectedReference) {
35477
+ return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
35478
+ getOwnMap() :
35479
+ getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, undefined);
35341
35480
  }
35342
35481
  function clear() {
35343
- ownMap.clear();
35482
+ ownKey = undefined;
35483
+ ownMap = undefined;
35344
35484
  redirectsMap.clear();
35485
+ redirectsKeyToCache.clear();
35345
35486
  }
35346
35487
  }
35347
35488
  ts.createCacheWithRedirects = createCacheWithRedirects;
35348
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35349
- var cache;
35350
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
35489
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
35490
+ var dirToPackageJsonScope = new ts.Map();
35491
+ var oldPackageJsonInfoCache;
35492
+ return {
35493
+ getPackageJsonInfo: getPackageJsonInfo,
35494
+ setPackageJsonInfo: setPackageJsonInfo,
35495
+ clear: clear,
35496
+ entries: entries,
35497
+ getInternalMap: function () { return cache; },
35498
+ setInternalMap: function (value) { return cache = value; },
35499
+ clone: clone,
35500
+ getPackageJsonScope: getPackageJsonScope,
35501
+ setPackageJsonScope: setPackageJsonScope,
35502
+ setOldPackageJsonScopeCache: function (cache) { return oldPackageJsonInfoCache = cache; },
35503
+ };
35351
35504
  function getPackageJsonInfo(packageJsonPath) {
35352
- return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35505
+ return cache === null || cache === void 0 ? void 0 : cache.get(toPath(packageJsonPath));
35353
35506
  }
35354
35507
  function setPackageJsonInfo(packageJsonPath, info) {
35355
- (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info);
35508
+ (cache || (cache = new ts.Map())).set(toPath(packageJsonPath), info);
35356
35509
  }
35357
35510
  function clear() {
35511
+ oldPackageJsonInfoCache = undefined;
35358
35512
  cache = undefined;
35513
+ dirToPackageJsonScope.clear();
35359
35514
  }
35360
35515
  function entries() {
35361
35516
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35362
35517
  return iter ? ts.arrayFrom(iter) : [];
35363
35518
  }
35364
- function getInternalMap() {
35365
- return cache;
35519
+ function clone() {
35520
+ return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
35521
+ }
35522
+ function getPackageJsonScope(dir) {
35523
+ return dirToPackageJsonScope.get(dir) || (oldPackageJsonInfoCache === null || oldPackageJsonInfoCache === void 0 ? void 0 : oldPackageJsonInfoCache.getPackageJsonScope(dir));
35524
+ }
35525
+ function setPackageJsonScope(dir, scope) {
35526
+ moduleNameToDirectorySet(dirToPackageJsonScope, dir, scope, getPackageJsconLocationFromScope, toPath, ts.noop);
35527
+ }
35528
+ function toPath(file) {
35529
+ return ts.toPath(file, currentDirectory, getCanonicalFileName);
35366
35530
  }
35367
35531
  }
35368
35532
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
@@ -35374,45 +35538,43 @@ var ts;
35374
35538
  }
35375
35539
  return result;
35376
35540
  }
35377
- function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35378
- if (!options.configFile)
35379
- return;
35380
- if (directoryToModuleNameMap.redirectsMap.size === 0) {
35381
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35382
- ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35383
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35384
- directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35385
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35386
- }
35387
- else {
35388
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35389
- var ref = {
35390
- sourceFile: options.configFile,
35391
- commandLine: { options: options }
35392
- };
35393
- directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35394
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35395
- }
35396
- directoryToModuleNameMap.setOwnOptions(options);
35397
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35398
- }
35399
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35541
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
35542
+ var directoryToModuleNameMap = createCacheWithRedirects(options);
35543
+ var oldResolutionCache;
35400
35544
  return {
35545
+ getFromCache: getFromCache,
35401
35546
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
35402
35547
  clear: clear,
35403
35548
  update: update,
35549
+ setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
35404
35550
  };
35405
35551
  function clear() {
35552
+ oldResolutionCache = undefined;
35406
35553
  directoryToModuleNameMap.clear();
35407
35554
  }
35408
35555
  function update(options) {
35409
- updateRedirectsMap(options, directoryToModuleNameMap);
35556
+ directoryToModuleNameMap.update(options);
35410
35557
  }
35411
35558
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35412
35559
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35413
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
35560
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
35561
+ }
35562
+ function getFromCache(directoryName, name, mode, redirectedReference) {
35563
+ var _a, _b;
35564
+ var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35565
+ 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);
35566
+ if (result)
35567
+ return result;
35568
+ var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
35569
+ if (resultFromOld)
35570
+ getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
35571
+ return resultFromOld;
35414
35572
  }
35415
35573
  }
35574
+ function getModeAwareCacheKey(specifier, mode) {
35575
+ return (mode === undefined ? specifier : mode + "|" + specifier);
35576
+ }
35577
+ ts.getModeAwareCacheKey = getModeAwareCacheKey;
35416
35578
  function createModeAwareCache() {
35417
35579
  var underlying = new ts.Map();
35418
35580
  var memoizedReverseKeys = new ts.Map();
@@ -35437,13 +35599,22 @@ var ts;
35437
35599
  return cb(elem, specifier, mode);
35438
35600
  });
35439
35601
  },
35602
+ entries: function () {
35603
+ var keys = underlying.entries();
35604
+ return {
35605
+ next: function () {
35606
+ var next = keys.next();
35607
+ return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
35608
+ },
35609
+ };
35610
+ },
35440
35611
  size: function () {
35441
35612
  return underlying.size;
35442
- }
35613
+ },
35443
35614
  };
35444
35615
  return cache;
35445
35616
  function getUnderlyingCacheKey(specifier, mode) {
35446
- var result = mode === undefined ? specifier : mode + "|" + specifier;
35617
+ var result = getModeAwareCacheKey(specifier, mode);
35447
35618
  memoizedReverseKeys.set(result, [specifier, mode]);
35448
35619
  return result;
35449
35620
  }
@@ -35454,100 +35625,122 @@ var ts;
35454
35625
  var map = createModeAwareCache();
35455
35626
  for (var i = 0; i < keys.length; ++i) {
35456
35627
  var entry = keys[i];
35457
- var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
35628
+ var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
35458
35629
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
35459
35630
  map.set(name, mode, values[i]);
35460
35631
  }
35461
35632
  return map;
35462
35633
  }
35463
35634
  ts.zipToModeAwareCache = zipToModeAwareCache;
35464
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35465
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35466
- moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35635
+ function getCommonPrefix(directory, resolution, toPath) {
35636
+ var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
35637
+ var i = 0;
35638
+ var limit = Math.min(directory.length, resolutionDirectory.length);
35639
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35640
+ i++;
35641
+ }
35642
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35643
+ return directory;
35644
+ }
35645
+ var rootLength = ts.getRootLength(directory);
35646
+ if (i < rootLength) {
35647
+ return undefined;
35648
+ }
35649
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35650
+ if (sep === -1) {
35651
+ return undefined;
35652
+ }
35653
+ return directory.substr(0, Math.max(sep, rootLength));
35654
+ }
35655
+ function getResolvedFileNameForModuleNameToDirectorySet(result) {
35656
+ return result.resolvedModule &&
35657
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35658
+ }
35659
+ ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
35660
+ function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
35661
+ if (directoryPathMap.has(directory))
35662
+ return;
35663
+ directoryPathMap.set(directory, result);
35664
+ var resolvedFileName = getResolvedFileName(result);
35665
+ var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
35666
+ var current = directory;
35667
+ while (current !== commonPrefix) {
35668
+ var parent = ts.getDirectoryPath(current);
35669
+ if (parent === current)
35670
+ break;
35671
+ if (directoryPathMap.has(parent)) {
35672
+ ancestoryWorker(parent);
35673
+ break;
35674
+ }
35675
+ directoryPathMap.set(parent, result);
35676
+ ancestoryWorker(parent);
35677
+ current = parent;
35678
+ }
35679
+ }
35680
+ ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
35681
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35682
+ var moduleNameToDirectoryMap = createCacheWithRedirects(options);
35683
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35467
35684
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35468
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35685
+ var oldResolutionCache;
35686
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
35469
35687
  function clear() {
35470
- clearAllExceptPackageJsonInfoCache();
35471
- packageJsonInfoCache.clear();
35472
- }
35473
- function clearAllExceptPackageJsonInfoCache() {
35688
+ oldResolutionCache = undefined;
35474
35689
  perDirectoryResolutionCache.clear();
35475
35690
  moduleNameToDirectoryMap.clear();
35691
+ packageJsonInfoCache.clear();
35476
35692
  }
35477
35693
  function update(options) {
35478
- updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35694
+ perDirectoryResolutionCache.update(options);
35695
+ moduleNameToDirectoryMap.update(options);
35696
+ }
35697
+ function setOldResolutionCache(cache) {
35698
+ oldResolutionCache = cache;
35699
+ perDirectoryResolutionCache.setOldResolutionCache(cache);
35700
+ }
35701
+ function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
35702
+ var _a, _b;
35703
+ ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35704
+ 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);
35705
+ if (result)
35706
+ return result;
35707
+ var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
35708
+ if (fromOld)
35709
+ getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
35710
+ return fromOld;
35479
35711
  }
35480
35712
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35481
35713
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35482
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
35714
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35483
35715
  }
35484
35716
  function createPerModuleNameCache() {
35485
35717
  var directoryPathMap = new ts.Map();
35486
35718
  return { get: get, set: set };
35487
35719
  function get(directory) {
35488
- return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
35720
+ return directoryPathMap.get(toPath(directory));
35489
35721
  }
35490
35722
  function set(directory, result) {
35491
- var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
35492
- if (directoryPathMap.has(path)) {
35493
- return;
35494
- }
35495
- directoryPathMap.set(path, result);
35496
- var resolvedFileName = result.resolvedModule &&
35497
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35498
- var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35499
- var current = path;
35500
- while (current !== commonPrefix) {
35501
- var parent = ts.getDirectoryPath(current);
35502
- if (parent === current || directoryPathMap.has(parent)) {
35503
- break;
35504
- }
35505
- directoryPathMap.set(parent, result);
35506
- current = parent;
35507
- }
35508
- }
35509
- function getCommonPrefix(directory, resolution) {
35510
- var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
35511
- var i = 0;
35512
- var limit = Math.min(directory.length, resolutionDirectory.length);
35513
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35514
- i++;
35515
- }
35516
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35517
- return directory;
35518
- }
35519
- var rootLength = ts.getRootLength(directory);
35520
- if (i < rootLength) {
35521
- return undefined;
35522
- }
35523
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35524
- if (sep === -1) {
35525
- return undefined;
35526
- }
35527
- return directory.substr(0, Math.max(sep, rootLength));
35723
+ return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
35528
35724
  }
35529
35725
  }
35726
+ function toPath(fileName) {
35727
+ return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
35728
+ }
35530
35729
  }
35531
35730
  ts.createModuleResolutionCache = createModuleResolutionCache;
35532
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35533
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35731
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35732
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35534
35733
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35535
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35734
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear });
35536
35735
  function clear() {
35537
- clearAllExceptPackageJsonInfoCache();
35538
- packageJsonInfoCache.clear();
35539
- }
35540
- function clearAllExceptPackageJsonInfoCache() {
35541
35736
  perDirectoryResolutionCache.clear();
35737
+ packageJsonInfoCache.clear();
35542
35738
  }
35543
35739
  }
35544
35740
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35545
35741
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35546
35742
  var containingDirectory = ts.getDirectoryPath(containingFile);
35547
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35548
- if (!perFolderCache)
35549
- return undefined;
35550
- return perFolderCache.get(moduleName, mode);
35743
+ return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
35551
35744
  }
35552
35745
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
35553
35746
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -35562,8 +35755,7 @@ var ts;
35562
35755
  }
35563
35756
  }
35564
35757
  var containingDirectory = ts.getDirectoryPath(containingFile);
35565
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35566
- var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35758
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
35567
35759
  if (result) {
35568
35760
  if (traceEnabled) {
35569
35761
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -35615,8 +35807,8 @@ var ts;
35615
35807
  if (result && result.resolvedModule)
35616
35808
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
35617
35809
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
35618
- if (perFolderCache) {
35619
- perFolderCache.set(moduleName, resolutionMode, result);
35810
+ if (cache) {
35811
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35620
35812
  if (!ts.isExternalModuleNameRelative(moduleName)) {
35621
35813
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35622
35814
  }
@@ -35820,10 +36012,10 @@ var ts;
35820
36012
  features: features,
35821
36013
  conditions: conditions,
35822
36014
  requestContainingDirectory: containingDirectory,
35823
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
36015
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35824
36016
  };
35825
36017
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
35826
- 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);
36018
+ 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);
35827
36019
  function tryResolve(extensions) {
35828
36020
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
35829
36021
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -36159,21 +36351,42 @@ var ts;
36159
36351
  features: NodeResolutionFeatures.None,
36160
36352
  conditions: ts.emptyArray,
36161
36353
  requestContainingDirectory: undefined,
36162
- reportDiagnostic: ts.noop
36354
+ reportResolutionDiagnostic: ts.noop
36163
36355
  };
36164
36356
  }
36165
36357
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
36166
- function getPackageScopeForPath(fileName, state) {
36167
- var parts = ts.getPathComponents(fileName);
36168
- parts.pop();
36169
- while (parts.length > 0) {
36170
- var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), false, state);
36171
- if (pkg) {
36172
- return pkg;
36173
- }
36174
- parts.pop();
36175
- }
36176
- return undefined;
36358
+ function getPackageScope(dir, packageJsonInfoCache, host, options) {
36359
+ var state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
36360
+ var failedLookupLocations = [];
36361
+ var affectingLocations = [];
36362
+ state.failedLookupLocations = failedLookupLocations;
36363
+ state.affectingLocations = affectingLocations;
36364
+ var result = ts.forEachAncestorDirectory(dir, function (directory) {
36365
+ var _a;
36366
+ var fromCache = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonScope(directory);
36367
+ if (fromCache) {
36368
+ var host_1 = state.host, traceEnabled = state.traceEnabled;
36369
+ if (traceEnabled) {
36370
+ trace(host_1, fromCache.info ?
36371
+ ts.Diagnostics.Directory_0_resolves_to_1_scope_according_to_cache :
36372
+ ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_according_to_cache, directory, getPackageJsconLocationFromScope(fromCache));
36373
+ }
36374
+ return fromCache;
36375
+ }
36376
+ var info = getPackageJsonInfo(directory, false, state);
36377
+ if (info)
36378
+ return { info: info };
36379
+ }) || { info: undefined };
36380
+ result.failedLookupLocations = updateResolutionField(result.failedLookupLocations, !options.cacheResolutions || !result.info ? failedLookupLocations : undefined);
36381
+ result.affectingLocations = updateResolutionField(result.affectingLocations, affectingLocations);
36382
+ packageJsonInfoCache === null || packageJsonInfoCache === void 0 ? void 0 : packageJsonInfoCache.setPackageJsonScope(dir, result);
36383
+ return result;
36384
+ }
36385
+ ts.getPackageScope = getPackageScope;
36386
+ function getPackageScopeForPath(dir, state) {
36387
+ return ts.forEachAncestorDirectory(dir, function (directory) {
36388
+ return getPackageJsonInfo(directory, false, state);
36389
+ });
36177
36390
  }
36178
36391
  ts.getPackageScopeForPath = getPackageScopeForPath;
36179
36392
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
@@ -36201,12 +36414,13 @@ var ts;
36201
36414
  }
36202
36415
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
36203
36416
  if (directoryExists && host.fileExists(packageJsonPath)) {
36204
- var packageJsonContent = ts.readJson(packageJsonPath, host);
36417
+ var packageJsonText = host.readFile(packageJsonPath);
36418
+ var packageJsonContent = ts.readJsonIgnoringErrorsFromText(packageJsonPath, packageJsonText);
36205
36419
  if (traceEnabled) {
36206
36420
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
36207
36421
  }
36208
36422
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
36209
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36423
+ var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36210
36424
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
36211
36425
  state.affectingLocations.push(packageJsonPath);
36212
36426
  return result;
@@ -36319,7 +36533,7 @@ var ts;
36319
36533
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
36320
36534
  var _a, _b;
36321
36535
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36322
- 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));
36536
+ var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
36323
36537
  var scope = getPackageScopeForPath(directoryPath, state);
36324
36538
  if (!scope || !scope.packageJsonContent.exports) {
36325
36539
  return undefined;
@@ -36378,7 +36592,7 @@ var ts;
36378
36592
  return toSearchResult(undefined);
36379
36593
  }
36380
36594
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36381
- 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));
36595
+ var directoryPath = ts.toPath(directory, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
36382
36596
  var scope = getPackageScopeForPath(directoryPath, state);
36383
36597
  if (!scope) {
36384
36598
  if (state.traceEnabled) {
@@ -36578,11 +36792,8 @@ var ts;
36578
36792
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
36579
36793
  }
36580
36794
  }
36581
- if (commonSourceDirGuesses.length > 1) {
36582
- state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
36583
- ? 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
36584
- : 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));
36585
- }
36795
+ if (commonSourceDirGuesses.length > 1)
36796
+ state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
36586
36797
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
36587
36798
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
36588
36799
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -36647,10 +36858,10 @@ var ts;
36647
36858
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
36648
36859
  }
36649
36860
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
36650
- var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
36861
+ var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
36651
36862
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
36652
36863
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
36653
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
36864
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36654
36865
  if (resolutionFromCache) {
36655
36866
  return resolutionFromCache;
36656
36867
  }
@@ -36787,8 +36998,8 @@ var ts;
36787
36998
  typesPackageName;
36788
36999
  }
36789
37000
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
36790
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36791
- var result = cache && cache.get(containingDirectory);
37001
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
37002
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
36792
37003
  if (result) {
36793
37004
  if (state.traceEnabled) {
36794
37005
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36813,19 +37024,18 @@ var ts;
36813
37024
  features: NodeResolutionFeatures.None,
36814
37025
  conditions: [],
36815
37026
  requestContainingDirectory: containingDirectory,
36816
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37027
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36817
37028
  };
36818
37029
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
36819
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37030
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36820
37031
  function tryResolve(extensions) {
36821
37032
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
36822
37033
  if (resolvedUsingSettings) {
36823
37034
  return { value: resolvedUsingSettings };
36824
37035
  }
36825
37036
  if (!ts.isExternalModuleNameRelative(moduleName)) {
36826
- var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, undefined, redirectedReference);
36827
37037
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
36828
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
37038
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, undefined, directory, redirectedReference, state);
36829
37039
  if (resolutionFromCache) {
36830
37040
  return resolutionFromCache;
36831
37041
  }
@@ -36864,10 +37074,10 @@ var ts;
36864
37074
  features: NodeResolutionFeatures.None,
36865
37075
  conditions: [],
36866
37076
  requestContainingDirectory: undefined,
36867
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37077
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36868
37078
  };
36869
37079
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
36870
- return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37080
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36871
37081
  }
36872
37082
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
36873
37083
  function toSearchResult(value) {
@@ -39880,9 +40090,10 @@ var ts;
39880
40090
  host.getSourceFiles().forEach(function (sf) {
39881
40091
  if (!sf.resolvedModules)
39882
40092
  return;
39883
- sf.resolvedModules.forEach(function (r) {
39884
- if (r && r.packageId)
39885
- map.set(r.packageId.name, r.extension === ".d.ts" || !!map.get(r.packageId.name));
40093
+ sf.resolvedModules.forEach(function (_a) {
40094
+ var resolvedModule = _a.resolvedModule;
40095
+ if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
40096
+ map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" || !!map.get(resolvedModule.packageId.name));
39886
40097
  });
39887
40098
  });
39888
40099
  return map;
@@ -42477,7 +42688,7 @@ var ts;
42477
42688
  : undefined;
42478
42689
  }
42479
42690
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
42480
- var _a, _b, _c, _d, _e, _f, _g, _h;
42691
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
42481
42692
  if (isForAugmentation === void 0) { isForAugmentation = false; }
42482
42693
  if (ts.startsWith(moduleReference, "@types/")) {
42483
42694
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -42523,7 +42734,7 @@ var ts;
42523
42734
  var diagnosticDetails = void 0;
42524
42735
  var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
42525
42736
  if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") {
42526
- var scope = currentSourceFile.packageJsonScope;
42737
+ var scope = (_h = currentSourceFile.packageJsonScope) === null || _h === void 0 ? void 0 : _h.info;
42527
42738
  var targetExt = ext === ".ts" ? ".mts" : ext === ".js" ? ".mjs" : undefined;
42528
42739
  if (scope && !scope.packageJsonContent.type) {
42529
42740
  if (targetExt) {
@@ -42607,10 +42818,10 @@ var ts;
42607
42818
  }
42608
42819
  else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
42609
42820
  var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
42610
- var suggestedExt = (_h = suggestedExtensions.find(function (_a) {
42821
+ var suggestedExt = (_j = suggestedExtensions.find(function (_a) {
42611
42822
  var actualExt = _a[0], _importExt = _a[1];
42612
42823
  return host.fileExists(absoluteRef_1 + actualExt);
42613
- })) === null || _h === void 0 ? void 0 : _h[1];
42824
+ })) === null || _j === void 0 ? void 0 : _j[1];
42614
42825
  if (suggestedExt) {
42615
42826
  error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
42616
42827
  }
@@ -72974,12 +73185,12 @@ var ts;
72974
73185
  var parent = node.parent;
72975
73186
  var paramTag = node.parent.parent;
72976
73187
  if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
72977
- var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
73188
+ var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
72978
73189
  var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent);
72979
- if (host_1 || isCallbackTag) {
73190
+ if (host_2 || isCallbackTag) {
72980
73191
  var lastParamDeclaration = isCallbackTag
72981
73192
  ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters)
72982
- : ts.lastOrUndefined(host_1.parameters);
73193
+ : ts.lastOrUndefined(host_2.parameters);
72983
73194
  var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
72984
73195
  if (!lastParamDeclaration ||
72985
73196
  symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -74214,11 +74425,12 @@ var ts;
74214
74425
  var fileToDirective;
74215
74426
  if (resolvedTypeReferenceDirectives) {
74216
74427
  fileToDirective = new ts.Map();
74217
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
74218
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
74428
+ resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
74429
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
74430
+ if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
74219
74431
  return;
74220
74432
  }
74221
- var file = host.getSourceFile(resolvedDirective.resolvedFileName);
74433
+ var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
74222
74434
  if (file) {
74223
74435
  addReferencedFilesToTypeDirective(file, key, mode);
74224
74436
  }
@@ -75495,9 +75707,9 @@ var ts;
75495
75707
  }
75496
75708
  var parent = ts.walkUpParenthesizedTypes(node.parent);
75497
75709
  if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
75498
- var host_2 = ts.getJSDocHost(parent);
75499
- if (host_2) {
75500
- parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
75710
+ var host_3 = ts.getJSDocHost(parent);
75711
+ if (host_3) {
75712
+ parent = ts.getSingleVariableOfVariableStatement(host_3) || host_3;
75501
75713
  }
75502
75714
  }
75503
75715
  switch (parent.kind) {
@@ -92014,7 +92226,7 @@ var ts;
92014
92226
  var sourceMap = sourceMapGenerator.toString();
92015
92227
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
92016
92228
  if (printer.bundleFileInfo)
92017
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
92229
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
92018
92230
  }
92019
92231
  }
92020
92232
  else {
@@ -92023,7 +92235,7 @@ var ts;
92023
92235
  var text = writer.getText();
92024
92236
  ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
92025
92237
  if (printer.bundleFileInfo)
92026
- printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
92238
+ printer.bundleFileInfo.hash = ts.computeSignature(text, host);
92027
92239
  writer.clear();
92028
92240
  }
92029
92241
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92148,7 +92360,6 @@ var ts;
92148
92360
  });
92149
92361
  }
92150
92362
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
92151
- var createHash = ts.maybeBind(host, host.createHash);
92152
92363
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
92153
92364
  var buildInfo;
92154
92365
  if (host.getBuildInfo) {
@@ -92168,22 +92379,22 @@ var ts;
92168
92379
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
92169
92380
  if (!jsFileText)
92170
92381
  return jsFilePath;
92171
- if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92382
+ if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
92172
92383
  return jsFilePath;
92173
92384
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92174
92385
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
92175
92386
  return sourceMapFilePath || "inline sourcemap decoding";
92176
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92387
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
92177
92388
  return sourceMapFilePath;
92178
92389
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
92179
92390
  if (declarationFilePath && !declarationText)
92180
92391
  return declarationFilePath;
92181
- if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92392
+ if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
92182
92393
  return declarationFilePath;
92183
92394
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92184
92395
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
92185
92396
  return declarationMapPath || "inline sourcemap decoding";
92186
- if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92397
+ if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
92187
92398
  return declarationMapPath;
92188
92399
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92189
92400
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
@@ -92221,7 +92432,7 @@ var ts;
92221
92432
  var newBuildInfo = data.buildInfo;
92222
92433
  newBuildInfo.program = buildInfo.program;
92223
92434
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
92224
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
92435
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
92225
92436
  }
92226
92437
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
92227
92438
  newBuildInfo.bundle.js.sources = js.sources;
@@ -92254,7 +92465,7 @@ var ts;
92254
92465
  getSourceFileFromReference: ts.returnUndefined,
92255
92466
  redirectTargetsMap: ts.createMultiMap(),
92256
92467
  getFileIncludeReasons: ts.notImplemented,
92257
- createHash: createHash,
92468
+ createHash: ts.maybeBind(host, host.createHash),
92258
92469
  };
92259
92470
  emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
92260
92471
  return outputFiles;
@@ -97252,7 +97463,7 @@ var ts;
97252
97463
  var name = names_2[_i];
97253
97464
  var result = void 0;
97254
97465
  var mode = getModeForFileReference(name, containingFileMode);
97255
- var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
97466
+ var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
97256
97467
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
97257
97468
  if (cache.has(cacheKey)) {
97258
97469
  result = cache.get(cacheKey);
@@ -97336,7 +97547,21 @@ var ts;
97336
97547
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97337
97548
  }
97338
97549
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
97339
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
97550
+ var emptyResolution = {
97551
+ resolvedModule: undefined,
97552
+ resolvedTypeReferenceDirective: undefined,
97553
+ failedLookupLocations: [],
97554
+ affectingLocations: [],
97555
+ resolutionDiagnostics: [],
97556
+ };
97557
+ function isResolvedModuleWithFailedLookupLocation(resolved) {
97558
+ return !!resolved && !!resolved.failedLookupLocations;
97559
+ }
97560
+ function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
97561
+ return !!resolved && !!resolved.failedLookupLocations;
97562
+ }
97563
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
97564
+ var _a;
97340
97565
  if (names.length === 0) {
97341
97566
  return [];
97342
97567
  }
@@ -97346,7 +97571,7 @@ var ts;
97346
97571
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
97347
97572
  var name = names_3[_i];
97348
97573
  var result = void 0;
97349
- var mode = getModeForResolutionAtIndex(containingFile, i);
97574
+ var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
97350
97575
  i++;
97351
97576
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
97352
97577
  if (cache.has(cacheKey)) {
@@ -97404,14 +97629,14 @@ var ts;
97404
97629
  ts.isReferenceFileLocation = isReferenceFileLocation;
97405
97630
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97406
97631
  var _a, _b, _c;
97407
- var _d, _e, _f, _g;
97632
+ var _d, _e, _f, _g, _h, _j;
97408
97633
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
97409
97634
  var kind = ref.kind, index = ref.index;
97410
97635
  var pos, end, packageId, resolutionMode;
97411
97636
  switch (kind) {
97412
97637
  case ts.FileIncludeKind.Import:
97413
97638
  var importLiteral = getModuleNameStringLiteralAt(file, index);
97414
- 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;
97639
+ 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;
97415
97640
  if (importLiteral.pos === -1)
97416
97641
  return { file: file, packageId: packageId, text: importLiteral.text };
97417
97642
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -97422,7 +97647,7 @@ var ts;
97422
97647
  break;
97423
97648
  case ts.FileIncludeKind.TypeReferenceDirective:
97424
97649
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
97425
- 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;
97650
+ 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;
97426
97651
  break;
97427
97652
  case ts.FileIncludeKind.LibReferenceDirective:
97428
97653
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -97506,13 +97731,13 @@ var ts;
97506
97731
  return undefined;
97507
97732
  }
97508
97733
  function lookupFromPackageJson() {
97509
- var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
97510
- var packageJsonLocations = [];
97511
- state.failedLookupLocations = packageJsonLocations;
97512
- state.affectingLocations = packageJsonLocations;
97513
- var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
97514
- var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97515
- return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
97734
+ var _a;
97735
+ var packageJsonScope = ts.getPackageScope(ts.getDirectoryPath(fileName), packageJsonInfoCache, host, options);
97736
+ var impliedNodeFormat = ((_a = packageJsonScope.info) === null || _a === void 0 ? void 0 : _a.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97737
+ return {
97738
+ impliedNodeFormat: impliedNodeFormat,
97739
+ packageJsonScope: packageJsonScope,
97740
+ };
97516
97741
  }
97517
97742
  }
97518
97743
  ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
@@ -97624,10 +97849,10 @@ var ts;
97624
97849
  };
97625
97850
  }
97626
97851
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97627
- var _a, _b, _c, _d;
97852
+ var _a, _b, _c, _d, _e;
97628
97853
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97629
97854
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
97630
- var oldProgram = createProgramOptions.oldProgram;
97855
+ var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
97631
97856
  var processingDefaultLibFiles;
97632
97857
  var processingOtherFiles;
97633
97858
  var files;
@@ -97641,6 +97866,8 @@ var ts;
97641
97866
  var cachedDeclarationDiagnosticsForFile = {};
97642
97867
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
97643
97868
  var fileProcessingDiagnostics;
97869
+ var automaticTypeDirectiveNames;
97870
+ var automaticTypeDirectiveResolutions;
97644
97871
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97645
97872
  var currentNodeModulesDepth = 0;
97646
97873
  var modulesWithElidedImports = new ts.Map();
@@ -97663,29 +97890,72 @@ var ts;
97663
97890
  var actualResolveModuleNamesWorker;
97664
97891
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
97665
97892
  if (host.resolveModuleNames) {
97666
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
97667
- if (!resolved || resolved.extension !== undefined) {
97668
- return resolved;
97669
- }
97670
- var withExtension = ts.clone(resolved);
97671
- withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
97672
- return withExtension;
97673
- }); };
97893
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97894
+ var _a;
97895
+ 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) {
97896
+ var name = _a.name;
97897
+ return name;
97898
+ }), redirectedReference, options, containingFile, partialResolutionInfo);
97899
+ return result.some(isResolvedModuleWithFailedLookupLocation) ?
97900
+ result :
97901
+ result.map(function (resolved) { return resolved ?
97902
+ resolved.extension !== undefined ?
97903
+ { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97904
+ { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
97905
+ emptyResolution; });
97906
+ };
97674
97907
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
97675
97908
  }
97676
97909
  else {
97677
97910
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
97678
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
97679
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
97911
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
97912
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97913
+ return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
97914
+ };
97680
97915
  }
97681
97916
  var actualResolveTypeReferenceDirectiveNamesWorker;
97682
97917
  if (host.resolveTypeReferenceDirectives) {
97683
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
97918
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
97919
+ var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
97920
+ return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
97921
+ result :
97922
+ result.map(function (resolved) { return resolved ?
97923
+ { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97924
+ emptyResolution; });
97925
+ };
97926
+ typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
97684
97927
  }
97685
97928
  else {
97686
97929
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97687
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
97688
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
97930
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
97931
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
97932
+ return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
97933
+ };
97934
+ }
97935
+ var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
97936
+ var oldBuildInfoProgram;
97937
+ if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
97938
+ var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
97939
+ oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
97940
+ fileExists: function (fileName) { return host.fileExists(fileName); },
97941
+ createHash: ts.maybeBind(host, host.createHash),
97942
+ getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), false, state_11); },
97943
+ });
97944
+ if (oldBuildInfoProgram) {
97945
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
97946
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97947
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
97948
+ }
97949
+ });
97950
+ typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
97951
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97952
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
97953
+ }
97954
+ });
97955
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache().setOldPackageJsonScopeCache({
97956
+ getPackageJsonScope: function (dirPath) { return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getPackageJsonScope(dirPath); }
97957
+ });
97958
+ }
97689
97959
  }
97690
97960
  var packageIdToSourceFile = new ts.Map();
97691
97961
  var sourceFileToPackageName = new ts.Map();
@@ -97698,9 +97968,9 @@ var ts;
97698
97968
  var projectReferenceRedirects;
97699
97969
  var mapFromFileToProjectReferenceRedirects;
97700
97970
  var mapFromToProjectReferenceRedirectSource;
97701
- var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
97971
+ var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
97702
97972
  !options.disableSourceOfProjectReferenceRedirect;
97703
- var _e = updateHostForUseSourceOfProjectReferenceRedirect({
97973
+ var _f = updateHostForUseSourceOfProjectReferenceRedirect({
97704
97974
  compilerHost: host,
97705
97975
  getSymlinkCache: getSymlinkCache,
97706
97976
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -97708,7 +97978,7 @@ var ts;
97708
97978
  getResolvedProjectReferences: getResolvedProjectReferences,
97709
97979
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
97710
97980
  forEachResolvedProjectReference: forEachResolvedProjectReference
97711
- }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
97981
+ }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
97712
97982
  var readFile = host.readFile.bind(host);
97713
97983
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97714
97984
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -97717,7 +97987,7 @@ var ts;
97717
97987
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
97718
97988
  structureIsReused = tryReuseStructureFromOldProgram();
97719
97989
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97720
- if (structureIsReused !== 2) {
97990
+ if (structureIsReused !== 3) {
97721
97991
  processingDefaultLibFiles = [];
97722
97992
  processingOtherFiles = [];
97723
97993
  if (projectReferences) {
@@ -97757,14 +98027,14 @@ var ts;
97757
98027
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
97758
98028
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
97759
98029
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97760
- var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
97761
- if (typeReferences.length) {
97762
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
97763
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97764
- var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97765
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
97766
- for (var i = 0; i < typeReferences.length; i++) {
97767
- 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 });
98030
+ automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
98031
+ automaticTypeDirectiveResolutions = ts.createModeAwareCache();
98032
+ if (automaticTypeDirectiveNames.length) {
98033
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: automaticTypeDirectiveNames.length });
98034
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
98035
+ for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
98036
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], undefined, resolutions[i]);
98037
+ 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 });
97768
98038
  }
97769
98039
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97770
98040
  }
@@ -97795,13 +98065,13 @@ var ts;
97795
98065
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
97796
98066
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
97797
98067
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
97798
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
98068
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
97799
98069
  }
97800
98070
  }
97801
98071
  if (!host.getParsedCommandLine) {
97802
98072
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
97803
98073
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
97804
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
98074
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
97805
98075
  }
97806
98076
  });
97807
98077
  }
@@ -97817,6 +98087,8 @@ var ts;
97817
98087
  }
97818
98088
  typeReferenceDirectiveResolutionCache = undefined;
97819
98089
  oldProgram = undefined;
98090
+ oldBuildInfoProgram = undefined;
98091
+ oldProgramOrOldBuildInfoProgramConstructor = undefined;
97820
98092
  var program = {
97821
98093
  getRootFileNames: function () { return rootNames; },
97822
98094
  getSourceFile: getSourceFile,
@@ -97824,6 +98096,7 @@ var ts;
97824
98096
  getSourceFiles: function () { return files; },
97825
98097
  getMissingFilePaths: function () { return missingFilePaths; },
97826
98098
  getModuleResolutionCache: function () { return moduleResolutionCache; },
98099
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
97827
98100
  getFilesByNameMap: function () { return filesByName; },
97828
98101
  getCompilerOptions: function () { return options; },
97829
98102
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -97848,6 +98121,9 @@ var ts;
97848
98121
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
97849
98122
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
97850
98123
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
98124
+ getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
98125
+ getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
98126
+ getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
97851
98127
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
97852
98128
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
97853
98129
  getSourceFileFromReference: getSourceFileFromReference,
@@ -97857,12 +98133,12 @@ var ts;
97857
98133
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
97858
98134
  isEmittedFile: isEmittedFile,
97859
98135
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
97860
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
97861
98136
  getProjectReferences: getProjectReferences,
97862
98137
  getResolvedProjectReferences: getResolvedProjectReferences,
97863
98138
  getProjectReferenceRedirect: getProjectReferenceRedirect,
97864
98139
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
97865
98140
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
98141
+ getRedirectReferenceForResolution: getRedirectReferenceForResolution,
97866
98142
  forEachResolvedProjectReference: forEachResolvedProjectReference,
97867
98143
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
97868
98144
  emitBuildInfo: emitBuildInfo,
@@ -97870,7 +98146,7 @@ var ts;
97870
98146
  readFile: readFile,
97871
98147
  directoryExists: directoryExists,
97872
98148
  getSymlinkCache: getSymlinkCache,
97873
- realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
98149
+ realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
97874
98150
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
97875
98151
  getFileIncludeReasons: function () { return fileReasons; },
97876
98152
  structureIsReused: structureIsReused,
@@ -97884,6 +98160,8 @@ var ts;
97884
98160
  case 0:
97885
98161
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
97886
98162
  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)));
98163
+ case 2:
98164
+ return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
97887
98165
  default:
97888
98166
  ts.Debug.assertNever(diagnostic);
97889
98167
  }
@@ -97893,57 +98171,44 @@ var ts;
97893
98171
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
97894
98172
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97895
98173
  return program;
97896
- function addResolutionDiagnostics(list) {
97897
- if (!list)
97898
- return;
97899
- for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
97900
- var elem = list_3[_i];
97901
- programDiagnostics.add(elem);
97902
- }
98174
+ function getAutomaticTypeDirectiveContainingFile() {
98175
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
98176
+ return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97903
98177
  }
97904
- function pullDiagnosticsFromCache(names, containingFile) {
97905
- var _a;
97906
- if (!moduleResolutionCache)
98178
+ function addResolutionDiagnostics(resolution) {
98179
+ if (!resolution.resolutionDiagnostics)
97907
98180
  return;
97908
- var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97909
- var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97910
- var containingDir = ts.getDirectoryPath(containingFileName);
97911
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
97912
- var i = 0;
97913
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
97914
- var n = names_4[_i];
97915
- var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
97916
- var name = typeof n === "string" ? n : n.fileName;
97917
- i++;
97918
- if (ts.isExternalModuleNameRelative(name))
97919
- continue;
97920
- var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
97921
- addResolutionDiagnostics(diags);
97922
- }
98181
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
98182
+ kind: 2,
98183
+ diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
98184
+ ? 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
98185
+ : 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); })
98186
+ });
97923
98187
  }
97924
- function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
98188
+ function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
97925
98189
  if (!moduleNames.length)
97926
98190
  return ts.emptyArray;
97927
98191
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97928
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
98192
+ if (redirectedReference === undefined)
98193
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97929
98194
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
97930
98195
  ts.performance.mark("beforeResolveModule");
97931
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
98196
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
97932
98197
  ts.performance.mark("afterResolveModule");
97933
98198
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
97934
98199
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97935
- pullDiagnosticsFromCache(moduleNames, containingFile);
97936
98200
  return result;
97937
98201
  }
97938
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
98202
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
97939
98203
  if (!typeDirectiveNames.length)
97940
98204
  return [];
97941
98205
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
97942
- var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
98206
+ if (redirectedReference === undefined && !ts.isString(containingFile))
98207
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97943
98208
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97944
98209
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
97945
98210
  ts.performance.mark("beforeResolveTypeReference");
97946
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
98211
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
97947
98212
  ts.performance.mark("afterResolveTypeReference");
97948
98213
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
97949
98214
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -97989,9 +98254,6 @@ var ts;
97989
98254
  }
97990
98255
  return ts.libs.length + 2;
97991
98256
  }
97992
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
97993
- return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
97994
- }
97995
98257
  function toPath(fileName) {
97996
98258
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
97997
98259
  }
@@ -98015,8 +98277,9 @@ var ts;
98015
98277
  return classifiableNames;
98016
98278
  }
98017
98279
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98280
+ var _a;
98018
98281
  if (structureIsReused === 0 && !file.ambientModuleNames.length) {
98019
- return resolveModuleNamesWorker(moduleNames, file, undefined);
98282
+ return resolveModuleNamesWorker(moduleNames, file, undefined, undefined);
98020
98283
  }
98021
98284
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
98022
98285
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -98031,21 +98294,34 @@ var ts;
98031
98294
  return result_14;
98032
98295
  }
98033
98296
  var unknownModuleNames;
98034
- var result;
98297
+ var unknownModuleNamesIndex;
98035
98298
  var reusedNames;
98036
- var predictedToResolveToAmbientModuleMarker = {};
98299
+ var result;
98300
+ var predictedToResolveToAmbientModuleMarker = true;
98301
+ var redirectedReference;
98037
98302
  for (var i = 0; i < moduleNames.length; i++) {
98038
98303
  var moduleName = moduleNames[i];
98039
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98040
- var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
98041
- if (oldResolvedModule) {
98304
+ if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98305
+ var mode = getModeForResolutionAtIndex(file, i);
98306
+ var oldResolution = !oldBuildInfoProgram ?
98307
+ (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
98308
+ oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
98309
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
98042
98310
  if (ts.isTraceEnabled(options, host)) {
98043
- ts.trace(host, oldResolvedModule.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, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId));
98311
+ var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
98312
+ if (!oldBuildInfoProgram) {
98313
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98314
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98315
+ 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));
98316
+ }
98317
+ else {
98318
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98319
+ 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 :
98320
+ 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));
98321
+ }
98046
98322
  }
98047
- (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
98048
- (reusedNames || (reusedNames = [])).push(moduleName);
98323
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
98324
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
98049
98325
  continue;
98050
98326
  }
98051
98327
  }
@@ -98060,14 +98336,15 @@ var ts;
98060
98336
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
98061
98337
  }
98062
98338
  if (resolvesToAmbientModuleInNonModifiedFile) {
98063
- (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98339
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98064
98340
  }
98065
98341
  else {
98066
- (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
98342
+ (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
98343
+ (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
98067
98344
  }
98068
98345
  }
98069
98346
  var resolutions = unknownModuleNames && unknownModuleNames.length
98070
- ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
98347
+ ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
98071
98348
  : ts.emptyArray;
98072
98349
  if (!result) {
98073
98350
  ts.Debug.assert(resolutions.length === moduleNames.length);
@@ -98077,7 +98354,7 @@ var ts;
98077
98354
  for (var i = 0; i < result.length; i++) {
98078
98355
  if (result[i]) {
98079
98356
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
98080
- result[i] = undefined;
98357
+ result[i] = emptyResolution;
98081
98358
  }
98082
98359
  }
98083
98360
  else {
@@ -98105,6 +98382,78 @@ var ts;
98105
98382
  return true;
98106
98383
  }
98107
98384
  }
98385
+ function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98386
+ var _a;
98387
+ if (structureIsReused === 0) {
98388
+ return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, undefined, undefined);
98389
+ }
98390
+ var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
98391
+ var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
98392
+ var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
98393
+ if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
98394
+ var result_15 = [];
98395
+ for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
98396
+ var typeDirectiveName = _b[_i];
98397
+ var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
98398
+ result_15.push(resolvedTypeReferenceDirective);
98399
+ }
98400
+ return result_15;
98401
+ }
98402
+ var unknownTypeReferenceDirectiveNames;
98403
+ var unknownTypeReferenceDirectiveNamesIndex;
98404
+ var result;
98405
+ var reusedNames;
98406
+ var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
98407
+ containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
98408
+ !hasInvalidatedResolution(toPath(inferredTypeFile)));
98409
+ var redirectedReference;
98410
+ for (var i = 0; i < typeDirectiveNames.length; i++) {
98411
+ var entry = typeDirectiveNames[i];
98412
+ if (canReuseResolutions) {
98413
+ var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
98414
+ var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
98415
+ var oldResolution = !oldBuildInfoProgram ?
98416
+ (_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) :
98417
+ oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
98418
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98419
+ if (ts.isTraceEnabled(options, host)) {
98420
+ var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
98421
+ if (!oldBuildInfoProgram) {
98422
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98423
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98424
+ 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));
98425
+ }
98426
+ else {
98427
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98428
+ 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 :
98429
+ 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));
98430
+ }
98431
+ }
98432
+ (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
98433
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
98434
+ continue;
98435
+ }
98436
+ }
98437
+ (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
98438
+ (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
98439
+ }
98440
+ if (!unknownTypeReferenceDirectiveNames)
98441
+ return result || ts.emptyArray;
98442
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
98443
+ if (!result) {
98444
+ ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
98445
+ return resolutions;
98446
+ }
98447
+ var j = 0;
98448
+ for (var i = 0; i < result.length; i++) {
98449
+ if (!result[i]) {
98450
+ result[i] = resolutions[j];
98451
+ j++;
98452
+ }
98453
+ }
98454
+ ts.Debug.assert(j === resolutions.length);
98455
+ return result;
98456
+ }
98108
98457
  function canReuseProjectReferences() {
98109
98458
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
98110
98459
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -98123,12 +98472,17 @@ var ts;
98123
98472
  });
98124
98473
  }
98125
98474
  function tryReuseStructureFromOldProgram() {
98126
- var _a, _b;
98127
- if (!oldProgram) {
98475
+ var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
98476
+ if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
98128
98477
  return 0;
98129
98478
  }
98130
- var oldOptions = oldProgram.getCompilerOptions();
98131
- if (ts.changesAffectModuleResolution(oldOptions, options)) {
98479
+ var result = tryReuseStructureFromOldProgramWorker();
98480
+ return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 ?
98481
+ 1 :
98482
+ result;
98483
+ }
98484
+ function tryReuseStructureFromOldProgramWorker() {
98485
+ if (!oldProgram) {
98132
98486
  return 0;
98133
98487
  }
98134
98488
  var oldRootNames = oldProgram.getRootFileNames();
@@ -98143,7 +98497,7 @@ var ts;
98143
98497
  }
98144
98498
  var newSourceFiles = [];
98145
98499
  var modifiedSourceFiles = [];
98146
- structureIsReused = 2;
98500
+ structureIsReused = 3;
98147
98501
  if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
98148
98502
  return 0;
98149
98503
  }
@@ -98151,14 +98505,13 @@ var ts;
98151
98505
  var seenPackageNames = new ts.Map();
98152
98506
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
98153
98507
  var oldSourceFile = oldSourceFiles_2[_i];
98154
- var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
98508
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
98155
98509
  var newSourceFile = host.getSourceFileByPath
98156
98510
  ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
98157
98511
  : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat);
98158
98512
  if (!newSourceFile) {
98159
98513
  return 0;
98160
98514
  }
98161
- newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
98162
98515
  newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
98163
98516
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
98164
98517
  var fileChanged = void 0;
@@ -98193,86 +98546,95 @@ var ts;
98193
98546
  }
98194
98547
  if (fileChanged) {
98195
98548
  if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
98196
- structureIsReused = 1;
98549
+ structureIsReused = 2;
98197
98550
  }
98198
98551
  else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
98199
- structureIsReused = 1;
98552
+ structureIsReused = 2;
98200
98553
  }
98201
98554
  else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
98202
- structureIsReused = 1;
98555
+ structureIsReused = 2;
98203
98556
  }
98204
98557
  else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
98205
- structureIsReused = 1;
98558
+ structureIsReused = 2;
98206
98559
  }
98207
98560
  else {
98208
98561
  collectExternalModuleReferences(newSourceFile);
98209
98562
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98210
- structureIsReused = 1;
98563
+ structureIsReused = 2;
98211
98564
  }
98212
98565
  else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98213
- structureIsReused = 1;
98566
+ structureIsReused = 2;
98214
98567
  }
98215
98568
  else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98216
- structureIsReused = 1;
98569
+ structureIsReused = 2;
98217
98570
  }
98218
98571
  else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
98219
- structureIsReused = 1;
98572
+ structureIsReused = 2;
98220
98573
  }
98221
98574
  }
98222
98575
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98223
98576
  }
98224
98577
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
98225
- structureIsReused = 1;
98578
+ structureIsReused = 2;
98226
98579
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98227
98580
  }
98228
98581
  newSourceFiles.push(newSourceFile);
98229
98582
  }
98230
- if (structureIsReused !== 2) {
98583
+ if (structureIsReused !== 3) {
98231
98584
  return structureIsReused;
98232
98585
  }
98233
98586
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98234
- for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
98235
- var oldFile = oldSourceFiles_3[_c];
98587
+ for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
98588
+ var oldFile = oldSourceFiles_3[_a];
98236
98589
  if (!ts.contains(modifiedFiles, oldFile)) {
98237
- for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
98238
- var moduleName = _e[_d];
98590
+ for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
98591
+ var moduleName = _c[_b];
98239
98592
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98240
98593
  }
98241
98594
  }
98242
98595
  }
98243
- for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
98244
- var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
98596
+ for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
98597
+ var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
98245
98598
  var moduleNames = getModuleNames(newSourceFile);
98246
98599
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98247
98600
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
98248
98601
  if (resolutionsChanged) {
98249
- structureIsReused = 1;
98602
+ structureIsReused = 2;
98250
98603
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98251
98604
  }
98252
98605
  else {
98253
98606
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98254
98607
  }
98255
98608
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98256
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
98609
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98257
98610
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
98258
98611
  if (typeReferenceResolutionsChanged) {
98259
- structureIsReused = 1;
98612
+ structureIsReused = 2;
98260
98613
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98261
98614
  }
98262
98615
  else {
98263
98616
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98264
98617
  }
98265
98618
  }
98266
- if (structureIsReused !== 2) {
98619
+ if (structureIsReused !== 3) {
98267
98620
  return structureIsReused;
98268
98621
  }
98269
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
98270
- return 1;
98622
+ if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
98623
+ return 2;
98624
+ }
98625
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
98626
+ if (host.hasChangedAutomaticTypeDirectiveNames())
98627
+ return 2;
98628
+ }
98629
+ else {
98630
+ automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
98631
+ if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98632
+ return 2;
98271
98633
  }
98272
98634
  missingFilePaths = oldProgram.getMissingFilePaths();
98273
98635
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98274
- for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
98275
- var newSourceFile = newSourceFiles_1[_h];
98636
+ for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
98637
+ var newSourceFile = newSourceFiles_1[_f];
98276
98638
  filesByName.set(newSourceFile.path, newSourceFile);
98277
98639
  }
98278
98640
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98293,10 +98655,12 @@ var ts;
98293
98655
  fileReasons = oldProgram.getFileIncludeReasons();
98294
98656
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98295
98657
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98658
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98659
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98296
98660
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98297
98661
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98298
98662
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
98299
- return 2;
98663
+ return 3;
98300
98664
  }
98301
98665
  function getEmitHost(writeFileCallback) {
98302
98666
  return {
@@ -98973,14 +99337,12 @@ var ts;
98973
99337
  }
98974
99338
  }
98975
99339
  function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
98976
- var _a;
98977
99340
  var redirect = Object.create(redirectTarget);
98978
99341
  redirect.fileName = fileName;
98979
99342
  redirect.path = path;
98980
99343
  redirect.resolvedPath = resolvedPath;
98981
99344
  redirect.originalFileName = originalFileName;
98982
99345
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
98983
- redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
98984
99346
  redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
98985
99347
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
98986
99348
  Object.defineProperties(redirect, {
@@ -99005,7 +99367,7 @@ var ts;
99005
99367
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99006
99368
  return result;
99007
99369
  }
99008
- function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
99370
+ function getCreateSourceFileOptions(fileName) {
99009
99371
  var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
99010
99372
  var languageVersion = ts.getEmitScriptTarget(options);
99011
99373
  var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
@@ -99013,7 +99375,7 @@ var ts;
99013
99375
  { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
99014
99376
  }
99015
99377
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
99016
- var _a, _b;
99378
+ var _a;
99017
99379
  var path = toPath(fileName);
99018
99380
  if (useSourceOfProjectReferenceRedirect) {
99019
99381
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -99083,7 +99445,7 @@ var ts;
99083
99445
  redirectedPath = toPath(redirect);
99084
99446
  }
99085
99447
  }
99086
- var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
99448
+ var sourceFileOptions = getCreateSourceFileOptions(fileName);
99087
99449
  var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
99088
99450
  if (packageId) {
99089
99451
  var packageIdKey = ts.packageIdToString(packageId);
@@ -99109,7 +99471,6 @@ var ts;
99109
99471
  file.path = path;
99110
99472
  file.resolvedPath = toPath(fileName);
99111
99473
  file.originalFileName = originalFileName;
99112
- file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
99113
99474
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
99114
99475
  addFileIncludeReason(file, reason);
99115
99476
  if (host.useCaseSensitiveFileNames()) {
@@ -99226,33 +99587,40 @@ var ts;
99226
99587
  }
99227
99588
  function processTypeReferenceDirectives(file) {
99228
99589
  var typeDirectives = file.typeReferenceDirectives;
99229
- if (!typeDirectives) {
99590
+ if (!typeDirectives.length) {
99591
+ file.resolvedTypeReferenceDirectiveNames = undefined;
99230
99592
  return;
99231
99593
  }
99232
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
99594
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
99233
99595
  for (var index = 0; index < typeDirectives.length; index++) {
99234
99596
  var ref = file.typeReferenceDirectives[index];
99235
99597
  var resolvedTypeReferenceDirective = resolutions[index];
99236
99598
  var fileName = ts.toFileNameLowerCase(ref.fileName);
99237
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
99599
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99238
99600
  var mode = ref.resolutionMode || file.impliedNodeFormat;
99239
99601
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
99240
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99602
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99603
+ kind: 2,
99604
+ diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
99605
+ });
99241
99606
  }
99242
99607
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
99243
99608
  }
99244
99609
  }
99245
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99246
- 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 });
99247
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99610
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99611
+ 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 });
99612
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99248
99613
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99249
99614
  }
99250
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99251
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99615
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99616
+ var _a;
99617
+ addResolutionDiagnostics(resolution);
99618
+ var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
99252
99619
  if (previousResolution && previousResolution.primary) {
99253
99620
  return;
99254
99621
  }
99255
99622
  var saveResolution = true;
99623
+ var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
99256
99624
  if (resolvedTypeReferenceDirective) {
99257
99625
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99258
99626
  currentNodeModulesDepth++;
@@ -99281,7 +99649,7 @@ var ts;
99281
99649
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99282
99650
  }
99283
99651
  if (saveResolution) {
99284
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99652
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99285
99653
  }
99286
99654
  }
99287
99655
  function pathForLibFile(libFileName) {
@@ -99310,7 +99678,7 @@ var ts;
99310
99678
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
99311
99679
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
99312
99680
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
99313
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99681
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99314
99682
  kind: 0,
99315
99683
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
99316
99684
  diagnostic: diagnostic,
@@ -99333,19 +99701,20 @@ var ts;
99333
99701
  for (var index = 0; index < moduleNames.length; index++) {
99334
99702
  var resolution = resolutions[index];
99335
99703
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
99336
- if (!resolution) {
99704
+ addResolutionDiagnostics(resolution);
99705
+ if (!resolution.resolvedModule) {
99337
99706
  continue;
99338
99707
  }
99339
- var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
99340
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
99708
+ var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
99709
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
99341
99710
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
99342
- var resolvedFileName = resolution.resolvedFileName;
99711
+ var resolvedFileName = resolution.resolvedModule.resolvedFileName;
99343
99712
  if (isFromNodeModulesSearch) {
99344
99713
  currentNodeModulesDepth++;
99345
99714
  }
99346
99715
  var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
99347
99716
  var shouldAddFile = resolvedFileName
99348
- && !getResolutionDiagnostic(optionsForFile, resolution)
99717
+ && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
99349
99718
  && !optionsForFile.noResolve
99350
99719
  && index < file.imports.length
99351
99720
  && !elideImport
@@ -99355,7 +99724,7 @@ var ts;
99355
99724
  modulesWithElidedImports.set(file.path, true);
99356
99725
  }
99357
99726
  else if (shouldAddFile) {
99358
- findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
99727
+ findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
99359
99728
  }
99360
99729
  if (isFromNodeModulesSearch) {
99361
99730
  currentNodeModulesDepth--;
@@ -99456,6 +99825,11 @@ var ts;
99456
99825
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
99457
99826
  }
99458
99827
  }
99828
+ if (ts.isIncrementalCompilation(options))
99829
+ options.cacheResolutions = true;
99830
+ if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
99831
+ createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
99832
+ }
99459
99833
  var outputFile = ts.outFile(options);
99460
99834
  if (options.tsBuildInfoFile) {
99461
99835
  if (!ts.isIncrementalCompilation(options)) {
@@ -99705,7 +100079,7 @@ var ts;
99705
100079
  }
99706
100080
  }
99707
100081
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
99708
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
100082
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99709
100083
  kind: 1,
99710
100084
  file: file && file.path,
99711
100085
  fileProcessingReason: fileProcessingReason,
@@ -99966,8 +100340,8 @@ var ts;
99966
100340
  if (!symlinks) {
99967
100341
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
99968
100342
  }
99969
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
99970
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100343
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100344
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
99971
100345
  }
99972
100346
  return symlinks;
99973
100347
  }
@@ -100326,7 +100700,8 @@ var ts;
100326
100700
  }
100327
100701
  }
100328
100702
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100329
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
100703
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
100704
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
100330
100705
  if (!resolvedTypeReferenceDirective) {
100331
100706
  return;
100332
100707
  }
@@ -100375,12 +100750,13 @@ var ts;
100375
100750
  return oldState && !oldState.referencedMap === !newReferencedMap;
100376
100751
  }
100377
100752
  BuilderState.canReuseOldState = canReuseOldState;
100378
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100753
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100379
100754
  var _a, _b, _c;
100380
100755
  var fileInfos = new ts.Map();
100381
100756
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
100382
100757
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
100383
100758
  var useOldState = canReuseOldState(referencedMap, oldState);
100759
+ var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100384
100760
  newProgram.getTypeChecker();
100385
100761
  for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
100386
100762
  var sourceFile = _d[_i];
@@ -100424,23 +100800,23 @@ var ts;
100424
100800
  state.allFileNames = undefined;
100425
100801
  }
100426
100802
  BuilderState.releaseCache = releaseCache;
100427
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100803
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100428
100804
  var _a, _b;
100429
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
100805
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
100430
100806
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
100431
100807
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
100432
100808
  return result;
100433
100809
  }
100434
100810
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
100435
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100811
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100436
100812
  var sourceFile = programOfThisState.getSourceFileByPath(path);
100437
100813
  if (!sourceFile) {
100438
100814
  return ts.emptyArray;
100439
100815
  }
100440
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100816
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100441
100817
  return [sourceFile];
100442
100818
  }
100443
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100819
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100444
100820
  }
100445
100821
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100446
100822
  function updateSignatureOfFile(state, signature, path) {
@@ -100448,7 +100824,7 @@ var ts;
100448
100824
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
100449
100825
  }
100450
100826
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
100451
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
100827
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
100452
100828
  var _a;
100453
100829
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
100454
100830
  if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
@@ -100459,7 +100835,7 @@ var ts;
100459
100835
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
100460
100836
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
100461
100837
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
100462
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
100838
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
100463
100839
  if (latestSignature !== prevSignature) {
100464
100840
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100465
100841
  }
@@ -100593,7 +100969,7 @@ var ts;
100593
100969
  }
100594
100970
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100595
100971
  }
100596
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
100972
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100597
100973
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100598
100974
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100599
100975
  }
@@ -100609,7 +100985,7 @@ var ts;
100609
100985
  if (!seenFileNamesMap.has(currentPath)) {
100610
100986
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100611
100987
  seenFileNamesMap.set(currentPath, currentSourceFile);
100612
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100988
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100613
100989
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
100614
100990
  }
100615
100991
  }
@@ -100623,9 +100999,9 @@ var ts;
100623
100999
  function hasSameKeys(map1, map2) {
100624
101000
  return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
100625
101001
  }
100626
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
101002
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100627
101003
  var _a, _b;
100628
- var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
101004
+ var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100629
101005
  state.program = newProgram;
100630
101006
  var compilerOptions = newProgram.getCompilerOptions();
100631
101007
  state.compilerOptions = compilerOptions;
@@ -100678,7 +101054,7 @@ var ts;
100678
101054
  return;
100679
101055
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100680
101056
  if (diagnostics) {
100681
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
101057
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100682
101058
  if (!state.semanticDiagnosticsFromOldState) {
100683
101059
  state.semanticDiagnosticsFromOldState = new ts.Set();
100684
101060
  }
@@ -100700,13 +101076,16 @@ var ts;
100700
101076
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
100701
101077
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
100702
101078
  }
100703
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
101079
+ state.buildInfoEmitPending = !useOldState ||
101080
+ state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
101081
+ state.fileInfos.size !== oldState.fileInfos.size;
100704
101082
  return state;
100705
101083
  }
100706
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
101084
+ function convertToDiagnostics(diagnostics, newProgram) {
100707
101085
  if (!diagnostics.length)
100708
101086
  return ts.emptyArray;
100709
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
101087
+ var buildInfoDirectory;
101088
+ var getCanonicalFileName;
100710
101089
  return diagnostics.map(function (diagnostic) {
100711
101090
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
100712
101091
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100722,7 +101101,8 @@ var ts;
100722
101101
  return result;
100723
101102
  });
100724
101103
  function toPath(path) {
100725
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101104
+ buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
101105
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
100726
101106
  }
100727
101107
  }
100728
101108
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -100731,6 +101111,8 @@ var ts;
100731
101111
  }
100732
101112
  function releaseCache(state) {
100733
101113
  ts.BuilderState.releaseCache(state);
101114
+ if (!state.resuableCacheResolutions)
101115
+ getCacheResolutions(state);
100734
101116
  state.program = undefined;
100735
101117
  }
100736
101118
  function backupBuilderProgramEmitState(state) {
@@ -100765,7 +101147,7 @@ var ts;
100765
101147
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100766
101148
  ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100767
101149
  }
100768
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
101150
+ function getNextAffectedFile(state, cancellationToken, host) {
100769
101151
  var _a, _b;
100770
101152
  while (true) {
100771
101153
  var affectedFiles = state.affectedFiles;
@@ -100776,7 +101158,7 @@ var ts;
100776
101158
  var affectedFile = affectedFiles[affectedFilesIndex];
100777
101159
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
100778
101160
  state.affectedFilesIndex = affectedFilesIndex;
100779
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101161
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
100780
101162
  return affectedFile;
100781
101163
  }
100782
101164
  affectedFilesIndex++;
@@ -100797,7 +101179,7 @@ var ts;
100797
101179
  ts.Debug.assert(!state.semanticDiagnosticsPerFile);
100798
101180
  return program;
100799
101181
  }
100800
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
101182
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
100801
101183
  state.currentChangedFilePath = nextKey.value;
100802
101184
  state.affectedFilesIndex = 0;
100803
101185
  if (!state.seenAffectedFiles)
@@ -100840,24 +101222,24 @@ var ts;
100840
101222
  });
100841
101223
  }
100842
101224
  }
100843
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101225
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
100844
101226
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
100845
101227
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
100846
101228
  removeDiagnosticsOfLibraryFiles(state);
100847
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
101229
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
100848
101230
  return;
100849
101231
  }
100850
101232
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
100851
101233
  return;
100852
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101234
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
100853
101235
  }
100854
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
101236
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
100855
101237
  removeSemanticDiagnosticsOf(state, path);
100856
101238
  if (!state.changedFilesSet.has(path)) {
100857
101239
  var program = ts.Debug.checkDefined(state.program);
100858
101240
  var sourceFile = program.getSourceFileByPath(path);
100859
101241
  if (sourceFile) {
100860
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
101242
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
100861
101243
  if (ts.getEmitDeclarations(state.compilerOptions)) {
100862
101244
  addToAffectedFilesPendingEmit(state, path, 0);
100863
101245
  }
@@ -100877,16 +101259,16 @@ var ts;
100877
101259
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
100878
101260
  return newSignature !== oldSignature;
100879
101261
  }
100880
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
101262
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
100881
101263
  var _a;
100882
101264
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
100883
101265
  return false;
100884
101266
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
100885
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
101267
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
100886
101268
  removeDiagnosticsOfLibraryFiles(state);
100887
101269
  return true;
100888
101270
  }
100889
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101271
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
100890
101272
  var _a;
100891
101273
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
100892
101274
  return;
@@ -100900,9 +101282,9 @@ var ts;
100900
101282
  var currentPath = queue.pop();
100901
101283
  if (!seenFileNamesMap.has(currentPath)) {
100902
101284
  seenFileNamesMap.set(currentPath, true);
100903
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101285
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
100904
101286
  return;
100905
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101287
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
100906
101288
  if (isChangedSignature(state, currentPath)) {
100907
101289
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
100908
101290
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -100912,27 +101294,27 @@ var ts;
100912
101294
  }
100913
101295
  var seenFileAndExportsOfFile = new ts.Set();
100914
101296
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100915
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101297
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
100916
101298
  return true;
100917
101299
  var references = state.referencedMap.getKeys(exportedFromPath);
100918
101300
  return references && ts.forEachKey(references, function (filePath) {
100919
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101301
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
100920
101302
  });
100921
101303
  });
100922
101304
  }
100923
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101305
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
100924
101306
  var _a, _b;
100925
101307
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
100926
101308
  return undefined;
100927
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101309
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
100928
101310
  return true;
100929
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101311
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
100930
101312
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100931
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101313
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
100932
101314
  });
100933
101315
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
100934
101316
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
100935
- handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
101317
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, host);
100936
101318
  });
100937
101319
  return undefined;
100938
101320
  }
@@ -100987,34 +101369,45 @@ var ts;
100987
101369
  return !!ts.outFile(info.options || {});
100988
101370
  }
100989
101371
  ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
100990
- function getProgramBuildInfo(state, getCanonicalFileName) {
101372
+ function getProgramBuildInfo(state, host) {
100991
101373
  var outFilePath = ts.outFile(state.compilerOptions);
100992
- if (outFilePath && !state.compilerOptions.composite)
101374
+ if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
100993
101375
  return;
100994
101376
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
100995
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101377
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101378
+ var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
101379
+ var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
100996
101380
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
101381
+ var fileNames = [];
101382
+ var fileNameToFileId = new ts.Map();
101383
+ var resolutions;
101384
+ var names;
101385
+ var resolutionNameToResolutionNameId;
101386
+ var resolutionEntries;
101387
+ var resolutionEntryToResolutionEntryId;
101388
+ var affectedFilesHash;
100997
101389
  if (outFilePath) {
100998
- var fileNames_1 = [];
100999
- var fileInfos_1 = [];
101000
- state.program.getRootFileNames().forEach(function (f) {
101001
- var sourceFile = state.program.getSourceFile(f);
101002
- if (!sourceFile)
101003
- return;
101004
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
101005
- fileInfos_1.push(sourceFile.version);
101006
- });
101007
- var result_15 = {
101008
- fileNames: fileNames_1,
101390
+ var fileInfos_1;
101391
+ if (state.compilerOptions.composite) {
101392
+ state.program.getRootFileNames().forEach(function (f) {
101393
+ var sourceFile = state.program.getSourceFile(f);
101394
+ if (!sourceFile)
101395
+ return;
101396
+ var fileId = toFileId(sourceFile.resolvedPath);
101397
+ (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
101398
+ });
101399
+ }
101400
+ var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
101401
+ var result_16 = {
101402
+ fileNames: fileNames,
101009
101403
  fileInfos: fileInfos_1,
101010
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
101404
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101011
101405
  outSignature: state.outSignature,
101012
101406
  latestChangedDtsFile: latestChangedDtsFile,
101407
+ cacheResolutions: cacheResolutions_1,
101013
101408
  };
101014
- return result_15;
101409
+ return result_16;
101015
101410
  }
101016
- var fileNames = [];
101017
- var fileNameToFileId = new ts.Map();
101018
101411
  var fileIdsList;
101019
101412
  var fileNamesToFileIdListId;
101020
101413
  var emitSignatures;
@@ -101071,7 +101464,7 @@ var ts;
101071
101464
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
101072
101465
  [
101073
101466
  toFileId(key),
101074
- convertToReusableDiagnostics(value, relativeToBuildInfo)
101467
+ value.map(toReusableDiagnostic)
101075
101468
  ] :
101076
101469
  toFileId(key));
101077
101470
  }
@@ -101093,10 +101486,11 @@ var ts;
101093
101486
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
101094
101487
  }
101095
101488
  }
101489
+ var cacheResolutions = toProgramBuildInfoCacheResolutions();
101096
101490
  var result = {
101097
101491
  fileNames: fileNames,
101098
101492
  fileInfos: fileInfos,
101099
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
101493
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101100
101494
  fileIdsList: fileIdsList,
101101
101495
  referencedMap: referencedMap,
101102
101496
  exportedModulesMap: exportedModulesMap,
@@ -101105,6 +101499,7 @@ var ts;
101105
101499
  changeFileSet: changeFileSet,
101106
101500
  emitSignatures: emitSignatures,
101107
101501
  latestChangedDtsFile: latestChangedDtsFile,
101502
+ cacheResolutions: cacheResolutions,
101108
101503
  };
101109
101504
  return result;
101110
101505
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -101113,7 +101508,7 @@ var ts;
101113
101508
  function relativeToBuildInfo(path) {
101114
101509
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
101115
101510
  }
101116
- function toFileId(path) {
101511
+ function toFileAndAbsoluteFileId(path) {
101117
101512
  var fileId = fileNameToFileId.get(path);
101118
101513
  if (fileId === undefined) {
101119
101514
  fileNames.push(relativeToBuildInfo(path));
@@ -101121,6 +101516,12 @@ var ts;
101121
101516
  }
101122
101517
  return fileId;
101123
101518
  }
101519
+ function toFileId(path) {
101520
+ return toFileAndAbsoluteFileId(path);
101521
+ }
101522
+ function toAbsoluteFileId(path) {
101523
+ return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
101524
+ }
101124
101525
  function toFileIdListId(set) {
101125
101526
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
101126
101527
  var key = fileIds.join();
@@ -101131,53 +101532,232 @@ var ts;
101131
101532
  }
101132
101533
  return fileIdListId;
101133
101534
  }
101134
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
101535
+ function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
101135
101536
  var result;
101136
101537
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
101137
101538
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
101138
101539
  var name = _a[_i];
101139
101540
  var optionInfo = optionsNameMap.get(name.toLowerCase());
101140
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
101141
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
101541
+ if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
101542
+ (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
101543
+ }
101544
+ else if (affectsModuleResolution && name === "pathsBasePath") {
101545
+ (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
101546
+ continue;
101142
101547
  }
101143
101548
  }
101144
101549
  return result;
101145
101550
  }
101146
- }
101147
- function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
101148
- if (option) {
101149
- if (option.type === "list") {
101150
- var values = value;
101151
- if (option.element.isFilePath && values.length) {
101152
- return values.map(relativeToBuildInfo);
101551
+ function toReusableCompilerOptionValue(option, value) {
101552
+ if (option) {
101553
+ if (option.type === "list") {
101554
+ var values = value;
101555
+ if (option.element.isFilePath && values.length) {
101556
+ return values.map(relativeToBuildInfoEnsuringAbsolutePath);
101557
+ }
101558
+ }
101559
+ else if (option.isFilePath) {
101560
+ return relativeToBuildInfoEnsuringAbsolutePath(value);
101153
101561
  }
101154
101562
  }
101155
- else if (option.isFilePath) {
101156
- return relativeToBuildInfo(value);
101157
- }
101563
+ return value;
101158
101564
  }
101159
- return value;
101160
- }
101161
- function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
101162
- ts.Debug.assert(!!diagnostics.length);
101163
- return diagnostics.map(function (diagnostic) {
101164
- var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
101565
+ function toReadonlyArrayOrUndefined(array, map) {
101566
+ return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
101567
+ }
101568
+ function toReusableDiagnostic(diagnostic) {
101569
+ var result = toReusableDiagnosticRelatedInformation(diagnostic);
101165
101570
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
101166
101571
  result.reportDeprecated = diagnostic.reportsDeprecated;
101167
101572
  result.source = diagnostic.source;
101168
101573
  result.skippedOn = diagnostic.skippedOn;
101169
101574
  var relatedInformation = diagnostic.relatedInformation;
101170
- result.relatedInformation = relatedInformation ?
101171
- relatedInformation.length ?
101172
- relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
101173
- [] :
101174
- undefined;
101575
+ result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
101175
101576
  return result;
101577
+ }
101578
+ function toReusableDiagnosticRelatedInformation(diagnostic) {
101579
+ var file = diagnostic.file;
101580
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101581
+ }
101582
+ function toProgramBuildInfoCacheResolutions() {
101583
+ var cacheResolutions = getCacheResolutions(state);
101584
+ var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
101585
+ var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
101586
+ var packageJsons = toProgramBuildInfoPackageJsons(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.perDirPackageJsonMap);
101587
+ if (!resolutions)
101588
+ return;
101589
+ ts.Debug.assertIsDefined(names);
101590
+ ts.Debug.assertIsDefined(resolutionEntries);
101591
+ state.resuableCacheResolutions = {
101592
+ cache: {
101593
+ resolutions: resolutions.map(toProgramBuildInfoResolution),
101594
+ names: names,
101595
+ hash: toProgramBuildInfoHashes(),
101596
+ resolutionEntries: resolutionEntries,
101597
+ modules: modules,
101598
+ typeRefs: typeRefs,
101599
+ packageJsons: packageJsons,
101600
+ },
101601
+ getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
101602
+ };
101603
+ return state.resuableCacheResolutions.cache;
101604
+ }
101605
+ function toProgramBuildInfoPackageJsons(cache) {
101606
+ var result;
101607
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (packageJson, dirPath) {
101608
+ var packageJsonDirPath = ts.getDirectoryPath(ts.toPath(packageJson, currentDirectory, getCanonicalFileName));
101609
+ if (packageJsonDirPath !== dirPath) {
101610
+ (result !== null && result !== void 0 ? result : (result = [])).push([
101611
+ toFileId(dirPath),
101612
+ toAbsoluteFileId(packageJson),
101613
+ ]);
101614
+ }
101615
+ });
101616
+ return result;
101617
+ }
101618
+ function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
101619
+ if (!cache)
101620
+ return undefined;
101621
+ var ownMap = cache.getOwnMap();
101622
+ var own = toProgramBuildInfoResolutionCache(ownMap);
101623
+ var redirects;
101624
+ cache.redirectsKeyToCache.forEach(function (_a) {
101625
+ var map = _a.map, options = _a.options;
101626
+ if (map === ownMap)
101627
+ return;
101628
+ var redirectCache = toProgramBuildInfoResolutionCache(map);
101629
+ if (redirectCache) {
101630
+ (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
101631
+ options: toProgramBuildInfoCompilerOptions(options, undefined, true),
101632
+ cache: redirectCache
101633
+ });
101634
+ }
101635
+ });
101636
+ return !redirects ? own : { own: own, redirects: redirects };
101637
+ }
101638
+ function toProgramBuildInfoResolutionCache(cache) {
101639
+ var result;
101640
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
101641
+ (result !== null && result !== void 0 ? result : (result = [])).push([
101642
+ toFileId(dirPath),
101643
+ ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
101644
+ ]) :
101645
+ undefined; });
101646
+ return result;
101647
+ }
101648
+ function toProgramBuildInfoResolutionEntryId(_a) {
101649
+ var name = _a[0], mode = _a[1], resolution = _a[2];
101650
+ var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
101651
+ var resolutionId = toProgramBuildInfoResolutionId(resolution);
101652
+ var key = resolutionNameId + "," + mode + "," + resolutionId;
101653
+ var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
101654
+ if (resolutionEntryId === undefined) {
101655
+ (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
101656
+ (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
101657
+ }
101658
+ return resolutionEntryId;
101659
+ }
101660
+ function toProgramBuildInfoResolutionNameId(name) {
101661
+ var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
101662
+ if (resolutionNameId === undefined) {
101663
+ (names !== null && names !== void 0 ? names : (names = [])).push(name);
101664
+ (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
101665
+ }
101666
+ return resolutionNameId;
101667
+ }
101668
+ function toProgramBuildInfoResolutionId(resolution) {
101669
+ if (resolution.serializationIndex === undefined) {
101670
+ (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
101671
+ resolution.serializationIndex = resolutions.length;
101672
+ }
101673
+ return resolution.serializationIndex;
101674
+ }
101675
+ function toProgramBuildInfoResolution(resolution) {
101676
+ resolution.serializationIndex = undefined;
101677
+ return {
101678
+ resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
101679
+ resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
101680
+ affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
101681
+ resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
101682
+ };
101683
+ }
101684
+ function toProgramBuildInfoHashes() {
101685
+ if (!affectedFilesHash)
101686
+ return undefined;
101687
+ var hashes = [];
101688
+ for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
101689
+ var key = _a[_i];
101690
+ var value = affectedFilesHash.get(key);
101691
+ hashes.push(value ? [key, value] : key);
101692
+ }
101693
+ return hashes;
101694
+ }
101695
+ function toAffectedFileId(file) {
101696
+ var _a;
101697
+ var fileId = toAbsoluteFileId(file);
101698
+ if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
101699
+ var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
101700
+ var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101701
+ (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
101702
+ }
101703
+ return fileId;
101704
+ }
101705
+ function toProgramBuildInfoResolved(resolved) {
101706
+ 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;
101707
+ }
101708
+ function toProgramBuildInfoResolutionDiagnostic(d) {
101709
+ return {
101710
+ isImports: d.isImports || undefined,
101711
+ entry: d.entry || undefined,
101712
+ packagePath: toAbsoluteFileId(d.packagePath),
101713
+ };
101714
+ }
101715
+ }
101716
+ function getCacheResolutions(state) {
101717
+ var _a;
101718
+ if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
101719
+ return state.cacheResolutions;
101720
+ var modules;
101721
+ var typeRefs;
101722
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
101723
+ var dirToPackageJsonScope = new ts.Map();
101724
+ var perDirPackageJsonMap;
101725
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101726
+ state.program.getSourceFiles().forEach(function (f) {
101727
+ var _a;
101728
+ modules = toPerDirectoryCache(state, getCanonicalFileName, modules, ts.getResolvedModuleOfResolution, f, f.resolvedModules, moduleNameToDirectoryMap);
101729
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, f, f.resolvedTypeReferenceDirectiveNames);
101730
+ if ((_a = f.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
101731
+ var dirPath = ts.getDirectoryPath(f.resolvedPath);
101732
+ if (!(dirToPackageJsonScope === null || dirToPackageJsonScope === void 0 ? void 0 : dirToPackageJsonScope.has(dirPath))) {
101733
+ (perDirPackageJsonMap !== null && perDirPackageJsonMap !== void 0 ? perDirPackageJsonMap : (perDirPackageJsonMap = new ts.Map())).set(dirPath, ts.getPackageJsconLocationFromScope(f.packageJsonScope));
101734
+ ts.moduleNameToDirectorySet(dirToPackageJsonScope, dirPath, f.packageJsonScope, ts.getPackageJsconLocationFromScope, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { return perDirPackageJsonMap === null || perDirPackageJsonMap === void 0 ? void 0 : perDirPackageJsonMap.delete(ancestorPath); });
101735
+ }
101736
+ }
101176
101737
  });
101738
+ var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
101739
+ if (automaticTypeDirectiveNames.length) {
101740
+ var currentDirectory = state.program.getCurrentDirectory();
101741
+ var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
101742
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
101743
+ }
101744
+ return state.cacheResolutions = {
101745
+ modules: modules,
101746
+ typeRefs: typeRefs,
101747
+ moduleNameToDirectoryMap: moduleNameToDirectoryMap,
101748
+ dirToPackageJsonScope: dirToPackageJsonScope,
101749
+ perDirPackageJsonMap: perDirPackageJsonMap,
101750
+ packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
101751
+ };
101177
101752
  }
101178
- function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
101179
- var file = diagnostic.file;
101180
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101753
+ function toPerDirectoryCache(state, getCanonicalFileName, perDirCache, getResolutionWithResolvedFileName, sourceFileOrPath, fileCacheFromProgram, moduleNameToDirectoryMap) {
101754
+ return ts.toPerDirectoryResolution(state.program, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, ts.noop, function (r, name, mode, _key, redirectedReference, dirPath) {
101755
+ var _a, _b, _c;
101756
+ return !((_a = getResolutionWithResolvedFileName(r)) === null || _a === void 0 ? void 0 : _a.resolvedFileName) ||
101757
+ (moduleNameToDirectoryMap &&
101758
+ !ts.isExternalModuleNameRelative(name) &&
101759
+ ((_c = (_b = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _b === void 0 ? void 0 : _b.get(ts.getModeAwareCacheKey(name, mode))) === null || _c === void 0 ? void 0 : _c.get(dirPath)));
101760
+ }, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath, name, mode, perDirResolutionCache) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
101181
101761
  }
101182
101762
  var BuilderProgramKind;
101183
101763
  (function (BuilderProgramKind) {
@@ -101201,7 +101781,7 @@ var ts;
101201
101781
  rootNames: newProgramOrRootNames,
101202
101782
  options: hostOrOptions,
101203
101783
  host: oldProgramOrHost,
101204
- oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
101784
+ oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
101205
101785
  configFileParsingDiagnostics: configFileParsingDiagnostics,
101206
101786
  projectReferences: projectReferences
101207
101787
  });
@@ -101219,8 +101799,8 @@ var ts;
101219
101799
  function getTextHandlingSourceMapForSignature(text, data) {
101220
101800
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
101221
101801
  }
101222
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
101223
- var _a;
101802
+ function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
101803
+ var _a, _b;
101224
101804
  text = getTextHandlingSourceMapForSignature(text, data);
101225
101805
  var sourceFileDirectory;
101226
101806
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -101228,7 +101808,7 @@ var ts;
101228
101808
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
101229
101809
  }).join("\n");
101230
101810
  }
101231
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
101811
+ return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
101232
101812
  function flattenDiagnosticMessageText(diagnostic) {
101233
101813
  return ts.isString(diagnostic) ?
101234
101814
  diagnostic :
@@ -101247,8 +101827,9 @@ var ts;
101247
101827
  }
101248
101828
  }
101249
101829
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
101250
- function computeSignature(text, computeHash, data) {
101251
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101830
+ function computeSignature(text, host, data) {
101831
+ var _a;
101832
+ return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101252
101833
  }
101253
101834
  ts.computeSignature = computeSignature;
101254
101835
  function createBuilderProgram(kind, _a) {
@@ -101259,10 +101840,8 @@ var ts;
101259
101840
  oldState = undefined;
101260
101841
  return oldProgram;
101261
101842
  }
101262
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101263
- var computeHash = ts.maybeBind(host, host.createHash);
101264
- var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101265
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
101843
+ var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101844
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
101266
101845
  newProgram = undefined;
101267
101846
  oldProgram = undefined;
101268
101847
  oldState = undefined;
@@ -101276,6 +101855,7 @@ var ts;
101276
101855
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
101277
101856
  builderProgram.emit = emit;
101278
101857
  builderProgram.releaseProgram = function () { return releaseCache(state); };
101858
+ builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
101279
101859
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
101280
101860
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
101281
101861
  }
@@ -101297,7 +101877,7 @@ var ts;
101297
101877
  return ts.emitSkippedWithNoDiagnostics;
101298
101878
  }
101299
101879
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101300
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101880
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101301
101881
  var emitKind = 1;
101302
101882
  var isPendingEmitFile = false;
101303
101883
  if (!affected) {
@@ -101335,7 +101915,7 @@ var ts;
101335
101915
  var file = sourceFiles[0];
101336
101916
  var info = state.fileInfos.get(file.resolvedPath);
101337
101917
  if (info.signature === file.version) {
101338
- var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
101918
+ var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
101339
101919
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
101340
101920
  emitSignature = signature;
101341
101921
  if (signature !== file.version) {
@@ -101359,7 +101939,7 @@ var ts;
101359
101939
  if (state.compilerOptions.composite) {
101360
101940
  var filePath = sourceFiles[0].resolvedPath;
101361
101941
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
101362
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
101942
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
101363
101943
  if (emitSignature === oldSignature)
101364
101944
  return;
101365
101945
  ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
@@ -101368,7 +101948,7 @@ var ts;
101368
101948
  }
101369
101949
  }
101370
101950
  else if (state.compilerOptions.composite) {
101371
- var newSignature = computeSignature(text, computeHash, data);
101951
+ var newSignature = computeSignature(text, host, data);
101372
101952
  if (newSignature === state.outSignature)
101373
101953
  return;
101374
101954
  state.outSignature = newSignature;
@@ -101429,7 +102009,7 @@ var ts;
101429
102009
  }
101430
102010
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101431
102011
  while (true) {
101432
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
102012
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101433
102013
  if (!affected) {
101434
102014
  return undefined;
101435
102015
  }
@@ -101487,12 +102067,32 @@ var ts;
101487
102067
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
101488
102068
  }
101489
102069
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
101490
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
101491
- var _a, _b, _c, _d;
101492
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101493
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101494
- var state;
102070
+ function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
102071
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
101495
102072
  var filePaths;
102073
+ var fileAbsolutePaths;
102074
+ return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
102075
+ function toPath(path) {
102076
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
102077
+ }
102078
+ function toAbsolutePath(path) {
102079
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
102080
+ }
102081
+ function toFilePath(fileId) {
102082
+ var _a;
102083
+ 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]));
102084
+ }
102085
+ function toFileAbsolutePath(fileId) {
102086
+ var _a;
102087
+ 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]));
102088
+ }
102089
+ }
102090
+ ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
102091
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
102092
+ var _a, _b, _c;
102093
+ var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
102094
+ var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
102095
+ var state;
101496
102096
  var filePathsSetList;
101497
102097
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
101498
102098
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -101501,13 +102101,13 @@ var ts;
101501
102101
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
101502
102102
  latestChangedDtsFile: latestChangedDtsFile,
101503
102103
  outSignature: program.outSignature,
102104
+ resuableCacheResolutions: toResuableCacheResolutions(),
101504
102105
  };
101505
102106
  }
101506
102107
  else {
101507
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
101508
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
102108
+ filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101509
102109
  var fileInfos_2 = new ts.Map();
101510
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
102110
+ var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101511
102111
  program.fileInfos.forEach(function (fileInfo, index) {
101512
102112
  var path = toFilePath(index + 1);
101513
102113
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -101515,7 +102115,7 @@ var ts;
101515
102115
  if (emitSignatures_1 && stateFileInfo.signature)
101516
102116
  emitSignatures_1.set(path, stateFileInfo.signature);
101517
102117
  });
101518
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
102118
+ (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
101519
102119
  if (ts.isNumber(value))
101520
102120
  emitSignatures_1.delete(toFilePath(value));
101521
102121
  else
@@ -101534,14 +102134,17 @@ var ts;
101534
102134
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
101535
102135
  latestChangedDtsFile: latestChangedDtsFile,
101536
102136
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
102137
+ resuableCacheResolutions: toResuableCacheResolutions(),
101537
102138
  };
101538
102139
  }
102140
+ state.compilerOptions.configFilePath = configFilePath;
101539
102141
  return {
101540
102142
  getState: function () { return state; },
101541
102143
  saveEmitState: ts.noop,
101542
102144
  restoreEmitState: ts.noop,
101543
102145
  getProgram: ts.notImplemented,
101544
102146
  getProgramOrUndefined: ts.returnUndefined,
102147
+ getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
101545
102148
  releaseProgram: ts.noop,
101546
102149
  getCompilerOptions: function () { return state.compilerOptions; },
101547
102150
  getSourceFile: ts.notImplemented,
@@ -101561,15 +102164,6 @@ var ts;
101561
102164
  close: ts.noop,
101562
102165
  hasChangedEmitSignature: ts.returnFalse,
101563
102166
  };
101564
- function toPath(path) {
101565
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101566
- }
101567
- function toAbsolutePath(path) {
101568
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101569
- }
101570
- function toFilePath(fileId) {
101571
- return filePaths[fileId - 1];
101572
- }
101573
102167
  function toFilePathsSet(fileIdsListId) {
101574
102168
  return filePathsSetList[fileIdsListId - 1];
101575
102169
  }
@@ -101584,8 +102178,241 @@ var ts;
101584
102178
  });
101585
102179
  return map;
101586
102180
  }
102181
+ function toResuableCacheResolutions() {
102182
+ return program.cacheResolutions && {
102183
+ cache: program.cacheResolutions,
102184
+ getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
102185
+ };
102186
+ }
101587
102187
  }
101588
102188
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
102189
+ function createGetProgramOrOldBuildInfoProgramUndefined(state) {
102190
+ return function () {
102191
+ var _a;
102192
+ return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
102193
+ (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions, !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
102194
+ undefined);
102195
+ };
102196
+ }
102197
+ function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
102198
+ if (!cacheResolutions && !resuableCacheResolutions)
102199
+ return undefined;
102200
+ var fileExistsMap = new ts.Map();
102201
+ var packageJsonInfoMap = new ts.Map();
102202
+ var affectingLoationsSameMap = new ts.Map();
102203
+ var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
102204
+ var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
102205
+ var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
102206
+ var decodedPackageJsonMap;
102207
+ var packageJsonScopes;
102208
+ var decodedHashes;
102209
+ var resolutions;
102210
+ var originalPathOrResolvedFileNames;
102211
+ var resolutionEntries;
102212
+ return {
102213
+ getCompilerOptions: function () { return compilerOptions; },
102214
+ 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); },
102215
+ 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); },
102216
+ getPackageJsonScope: getPackageJsonScope,
102217
+ };
102218
+ function fileExists(fileName) {
102219
+ var result = fileExistsMap.get(fileName);
102220
+ if (result === undefined)
102221
+ fileExistsMap.set(fileName, result = host.fileExists(fileName));
102222
+ return result;
102223
+ }
102224
+ function getPackageJsonInfo(fileName) {
102225
+ var result = packageJsonInfoMap.get(fileName);
102226
+ if (result === undefined)
102227
+ packageJsonInfoMap.set(fileName, result = host.getPackageJsonInfo(fileName) || false);
102228
+ return result || undefined;
102229
+ }
102230
+ function affectingLocationsSame(fileName, expected) {
102231
+ var _a;
102232
+ var result = affectingLoationsSameMap.get(fileName);
102233
+ if (result !== undefined)
102234
+ return result;
102235
+ var packageJsonInfo = getPackageJsonInfo(fileName);
102236
+ var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
102237
+ if (ts.isString(expected)) {
102238
+ result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
102239
+ }
102240
+ else {
102241
+ var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
102242
+ result = currentText === expectedText;
102243
+ }
102244
+ affectingLoationsSameMap.set(fileName, result);
102245
+ return result;
102246
+ }
102247
+ function getPackageJsonScope(dirPath) {
102248
+ var _a;
102249
+ var fromCache = (_a = cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.dirToPackageJsonScope) === null || _a === void 0 ? void 0 : _a.get(dirPath);
102250
+ if (fromCache) {
102251
+ var packageJson = ts.getPackageJsconLocationFromScope(fromCache);
102252
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(packageJson);
102253
+ if (result === undefined) {
102254
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map())).set(packageJson, result = affectingLocationsSame(packageJson, fromCache.info) ?
102255
+ fromCache :
102256
+ fileExists(packageJson) ?
102257
+ { info: getPackageJsonInfo(packageJson), affectingLocations: [packageJson] } :
102258
+ false);
102259
+ }
102260
+ return result || undefined;
102261
+ }
102262
+ if (!(resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.packageJsons))
102263
+ return;
102264
+ if (!decodedPackageJsonMap) {
102265
+ decodedPackageJsonMap = new ts.Map();
102266
+ var filePathDecoder_1 = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder();
102267
+ for (var _i = 0, _b = resuableCacheResolutions.cache.packageJsons; _i < _b.length; _i++) {
102268
+ var dirIdOrDirAndPackageJson = _b[_i];
102269
+ var dirPath_1 = filePathDecoder_1.toFilePath(dirIdOrDirAndPackageJson[0]);
102270
+ var packageJson = filePathDecoder_1.toFileAbsolutePath(dirIdOrDirAndPackageJson[1]);
102271
+ ts.moduleNameToDirectorySet(decodedPackageJsonMap, dirPath_1, packageJson, ts.identity, function (fileName) { return ts.toPath(fileName, filePathDecoder_1.currentDirectory, filePathDecoder_1.getCanonicalFileName); }, ts.noop);
102272
+ }
102273
+ }
102274
+ return toPackageJsonScope(decodedPackageJsonMap.get(dirPath));
102275
+ }
102276
+ function toPackageJsonScope(file) {
102277
+ if (!file)
102278
+ return undefined;
102279
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(file);
102280
+ if (result !== undefined)
102281
+ return result || undefined;
102282
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map()));
102283
+ if (fileExists(file)) {
102284
+ result = {
102285
+ info: getPackageJsonInfo(file),
102286
+ affectingLocations: [file]
102287
+ };
102288
+ }
102289
+ packageJsonScopes.set(file, result || false);
102290
+ return result;
102291
+ }
102292
+ function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
102293
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
102294
+ 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)) ||
102295
+ ((_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));
102296
+ if (fromCache) {
102297
+ return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
102298
+ 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;
102299
+ }
102300
+ if (!reusableCache)
102301
+ return undefined;
102302
+ if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
102303
+ if (ts.isArray(reusableCache)) {
102304
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache, decodedModuleNameToDirectoryMap);
102305
+ }
102306
+ else {
102307
+ if (reusableCache.own)
102308
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
102309
+ reusableCache.redirects.forEach(function (_a) {
102310
+ var options = _a.options, cache = _a.cache;
102311
+ var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
102312
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
102313
+ });
102314
+ }
102315
+ decodedReusableCache.clearRedirectsMap();
102316
+ decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
102317
+ }
102318
+ 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)) ||
102319
+ ((_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));
102320
+ return resolutionId ? toResolution(resolutionId) : undefined;
102321
+ }
102322
+ function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
102323
+ var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
102324
+ reusableCache.forEach(function (_a) {
102325
+ var dirId = _a[0], entryId = _a[1];
102326
+ var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
102327
+ map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
102328
+ });
102329
+ }
102330
+ function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
102331
+ var modeAwareCache = ts.createModeAwareCache();
102332
+ entries.forEach(function (entryId) {
102333
+ var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
102334
+ modeAwareCache.set(name, mode, resolutionId);
102335
+ if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102336
+ return;
102337
+ var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
102338
+ var key = ts.getModeAwareCacheKey(name, mode);
102339
+ var moduleNameMap = mapForOptions.get(key);
102340
+ ;
102341
+ if (!moduleNameMap)
102342
+ mapForOptions.set(key, moduleNameMap = new ts.Map());
102343
+ ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
102344
+ });
102345
+ return modeAwareCache;
102346
+ }
102347
+ function toResolutionEntry(entryId) {
102348
+ var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
102349
+ if (existing)
102350
+ return existing;
102351
+ resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
102352
+ var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
102353
+ return resolutionEntries[entryId - 1] = [
102354
+ toName(nameId),
102355
+ resolutionId,
102356
+ mode
102357
+ ];
102358
+ }
102359
+ function toName(nameId) {
102360
+ return resuableCacheResolutions.cache.names[nameId - 1];
102361
+ }
102362
+ function toOriginalPathOrResolvedFileName(resolutionId) {
102363
+ var _a;
102364
+ 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 ||
102365
+ resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
102366
+ }
102367
+ function toAffectingFileLocation(fileId) {
102368
+ if (!decodedHashes && resuableCacheResolutions.cache.hash) {
102369
+ decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
102370
+ }
102371
+ var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
102372
+ var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
102373
+ return affectingLocationsSame(file, hash) ? file : undefined;
102374
+ }
102375
+ function toResolution(resolutionId) {
102376
+ var _a, _b;
102377
+ var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
102378
+ if (existing !== undefined)
102379
+ return existing || undefined;
102380
+ resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
102381
+ var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
102382
+ var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
102383
+ var affectingLocations;
102384
+ if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
102385
+ var file = toAffectingFileLocation(fileId);
102386
+ if (file)
102387
+ (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
102388
+ return !!file;
102389
+ })) {
102390
+ var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
102391
+ return resolutions[resolutionId - 1] = {
102392
+ resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
102393
+ resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
102394
+ failedLookupLocations: ts.emptyArray,
102395
+ affectingLocations: affectingLocations,
102396
+ resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
102397
+ };
102398
+ }
102399
+ resolutions[resolutionId - 1] = false;
102400
+ return undefined;
102401
+ }
102402
+ function toResolved(resolved, resolvedFileName, extension) {
102403
+ if (!resolved)
102404
+ return undefined;
102405
+ return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
102406
+ }
102407
+ function toResolutionDiagnostic(d) {
102408
+ return {
102409
+ isImports: !!d.isImports,
102410
+ entry: d.entry || "",
102411
+ packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
102412
+ };
102413
+ }
102414
+ }
102415
+ ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
101589
102416
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
101590
102417
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101591
102418
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -101605,6 +102432,7 @@ var ts;
101605
102432
  restoreEmitState: ts.noop,
101606
102433
  getProgram: getProgram,
101607
102434
  getProgramOrUndefined: function () { return getState().program; },
102435
+ getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
101608
102436
  releaseProgram: function () { return getState().program = undefined; },
101609
102437
  getCompilerOptions: function () { return getState().compilerOptions; },
101610
102438
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -101687,15 +102515,57 @@ var ts;
101687
102515
  return true;
101688
102516
  }
101689
102517
  ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
102518
+ function getResolvedModuleOfResolution(resolution) {
102519
+ return resolution.resolvedModule;
102520
+ }
102521
+ ts.getResolvedModuleOfResolution = getResolvedModuleOfResolution;
102522
+ function getResolvedTypeReferenceDirectiveOfResolution(resolution) {
102523
+ return resolution.resolvedTypeReferenceDirective;
102524
+ }
102525
+ ts.getResolvedTypeReferenceDirectiveOfResolution = getResolvedTypeReferenceDirectiveOfResolution;
102526
+ function toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, onRedirectedReferenceKey, forEachResolution, toPath, ancestoryWorker) {
102527
+ if (!(fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()))
102528
+ return perDirCache;
102529
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102530
+ var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
102531
+ var options = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
102532
+ var key = ts.getRedirectsCacheKey(options);
102533
+ onRedirectedReferenceKey(key);
102534
+ var dirPath = ts.getDirectoryPath(path);
102535
+ var perDirResolutionCache = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
102536
+ var cacheForDir = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
102537
+ fileCacheFromProgram.forEach(function (r, name, mode) {
102538
+ if (forEachResolution(r, name, mode, key, redirectedReference, dirPath))
102539
+ return;
102540
+ if (cacheForDir === null || cacheForDir === void 0 ? void 0 : cacheForDir.has(name, mode))
102541
+ return;
102542
+ if (!cacheForDir) {
102543
+ perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options, key));
102544
+ perDirResolutionCache.set(dirPath, cacheForDir = ts.createModeAwareCache());
102545
+ }
102546
+ cacheForDir.set(name, mode, r);
102547
+ if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102548
+ return;
102549
+ var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options, key);
102550
+ var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
102551
+ var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
102552
+ if (!directoryPathMap)
102553
+ actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
102554
+ ts.moduleNameToDirectorySet(directoryPathMap, dirPath, r, ts.getResolvedFileNameForModuleNameToDirectorySet, toPath, function (ancestorPath) { return ancestoryWorker(ancestorPath, name, mode, perDirResolutionCache); });
102555
+ });
102556
+ return perDirCache;
102557
+ }
102558
+ ts.toPerDirectoryResolution = toPerDirectoryResolution;
101690
102559
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
101691
102560
  var filesWithChangedSetOfUnresolvedImports;
101692
102561
  var filesWithInvalidatedResolutions;
101693
- var filesWithInvalidatedNonRelativeUnresolvedImports;
101694
- var nonRelativeExternalModuleResolutions = ts.createMultiMap();
101695
102562
  var resolutionsWithFailedLookups = [];
101696
102563
  var resolutionsWithOnlyAffectingLocations = [];
101697
102564
  var resolvedFileToResolution = ts.createMultiMap();
101698
- var impliedFormatPackageJsons = new ts.Map();
102565
+ var perFilePackageJsonScope = new ts.Map();
102566
+ var watchedPackageJsonScopes = [];
102567
+ var packageJsonsToCloseWatcherOn;
102568
+ var resolutionsToCloseWatcherOn;
101699
102569
  var hasChangedAutomaticTypeDirectiveNames = false;
101700
102570
  var affectingPathChecksForFile;
101701
102571
  var affectingPathChecks;
@@ -101704,13 +102574,12 @@ var ts;
101704
102574
  var isInDirectoryChecks;
101705
102575
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
101706
102576
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
102577
+ var oldModuleAndTypeRefCache;
102578
+ var oldPackageJsonInfoCache;
101707
102579
  var resolvedModuleNames = new ts.Map();
101708
- var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
101709
- var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
101710
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
102580
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
101711
102581
  var resolvedTypeReferenceDirectives = new ts.Map();
101712
- var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
101713
- var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
102582
+ var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache());
101714
102583
  var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
101715
102584
  var customFailedLookupPaths = new ts.Map();
101716
102585
  var directoryWatchesOfFailedLookups = new ts.Map();
@@ -101720,32 +102589,23 @@ var ts;
101720
102589
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
101721
102590
  var typeRootsWatches = new ts.Map();
101722
102591
  return {
102592
+ resolvedModuleNames: resolvedModuleNames,
102593
+ resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
101723
102594
  getModuleResolutionCache: function () { return moduleResolutionCache; },
102595
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
101724
102596
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
101725
102597
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
101726
102598
  startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
101727
102599
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
101728
102600
  resolveModuleNames: resolveModuleNames,
101729
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
101730
102601
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
101731
- removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
101732
- removeResolutionsOfFile: removeResolutionsOfFile,
101733
102602
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
101734
102603
  invalidateResolutionOfFile: invalidateResolutionOfFile,
101735
102604
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
101736
102605
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
101737
102606
  createHasInvalidatedResolution: createHasInvalidatedResolution,
101738
- isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
101739
- updateTypeRootsWatch: updateTypeRootsWatch,
101740
- closeTypeRootsWatch: closeTypeRootsWatch,
101741
102607
  clear: clear
101742
102608
  };
101743
- function getResolvedModule(resolution) {
101744
- return resolution.resolvedModule;
101745
- }
101746
- function getResolvedTypeReferenceDirective(resolution) {
101747
- return resolution.resolvedTypeReferenceDirective;
101748
- }
101749
102609
  function isInDirectoryPath(dir, file) {
101750
102610
  if (dir === undefined || file.length <= dir.length) {
101751
102611
  return false;
@@ -101756,21 +102616,25 @@ var ts;
101756
102616
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
101757
102617
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
101758
102618
  customFailedLookupPaths.clear();
101759
- nonRelativeExternalModuleResolutions.clear();
101760
102619
  closeTypeRootsWatch();
101761
102620
  resolvedModuleNames.clear();
101762
102621
  resolvedTypeReferenceDirectives.clear();
101763
102622
  resolvedFileToResolution.clear();
101764
102623
  resolutionsWithFailedLookups.length = 0;
101765
102624
  resolutionsWithOnlyAffectingLocations.length = 0;
102625
+ watchedPackageJsonScopes.length = 0;
101766
102626
  failedLookupChecks = undefined;
101767
102627
  startsWithPathChecks = undefined;
101768
102628
  isInDirectoryChecks = undefined;
101769
102629
  affectingPathChecks = undefined;
101770
102630
  affectingPathChecksForFile = undefined;
102631
+ resolutionsToCloseWatcherOn = undefined;
102632
+ packageJsonsToCloseWatcherOn = undefined;
102633
+ oldModuleAndTypeRefCache = undefined;
102634
+ oldPackageJsonInfoCache = undefined;
101771
102635
  moduleResolutionCache.clear();
101772
102636
  typeReferenceDirectiveResolutionCache.clear();
101773
- impliedFormatPackageJsons.clear();
102637
+ perFilePackageJsonScope.clear();
101774
102638
  hasChangedAutomaticTypeDirectiveNames = false;
101775
102639
  }
101776
102640
  function startRecordingFilesWithChangedResolutions() {
@@ -101781,13 +102645,6 @@ var ts;
101781
102645
  filesWithChangedSetOfUnresolvedImports = undefined;
101782
102646
  return collected;
101783
102647
  }
101784
- function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
101785
- if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
101786
- return false;
101787
- }
101788
- var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
101789
- return !!value && !!value.length;
101790
- }
101791
102648
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
101792
102649
  invalidateResolutionsOfFailedLookupLocations();
101793
102650
  if (forceAllFilesAsInvalidated) {
@@ -101796,71 +102653,239 @@ var ts;
101796
102653
  }
101797
102654
  var collected = filesWithInvalidatedResolutions;
101798
102655
  filesWithInvalidatedResolutions = undefined;
101799
- return function (path) { return (!!collected && collected.has(path)) ||
101800
- isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
102656
+ return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
101801
102657
  }
101802
102658
  function startCachingPerDirectoryResolution() {
101803
- moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
101804
- typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
101805
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101806
- nonRelativeExternalModuleResolutions.clear();
102659
+ var packageJsonInfoCache = moduleResolutionCache.getPackageJsonInfoCache();
102660
+ var internalCache = packageJsonInfoCache.getInternalMap();
102661
+ moduleResolutionCache.clear();
102662
+ typeReferenceDirectiveResolutionCache.clear();
102663
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
102664
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
102665
+ if (oldModuleAndTypeRefCache) {
102666
+ oldModuleAndTypeRefCache.clearRedirectsMap();
102667
+ moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
102668
+ typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
102669
+ }
102670
+ packageJsonInfoCache.setInternalMap(internalCache);
102671
+ packageJsonInfoCache.setOldPackageJsonScopeCache(oldPackageJsonInfoCache);
101807
102672
  }
101808
102673
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
101809
- filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
101810
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101811
- nonRelativeExternalModuleResolutions.clear();
101812
- if (newProgram !== oldProgram) {
101813
- newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
101814
- var _a, _b, _c;
101815
- var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
101816
- var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
101817
- for (var i = existing.length; i < expected; i++) {
101818
- createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false);
102674
+ hasChangedAutomaticTypeDirectiveNames = false;
102675
+ if (!newProgram) {
102676
+ clear();
102677
+ return;
102678
+ }
102679
+ if (newProgram === oldProgram)
102680
+ return;
102681
+ var needsResolutionUpdate = newProgram.structureIsReused !== 3;
102682
+ var modules;
102683
+ var typeRefs;
102684
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
102685
+ var dirToPackageJsonScope = new ts.Map();
102686
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
102687
+ var newFile = _a[_i];
102688
+ if (needsResolutionUpdate) {
102689
+ modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, newFile.resolvedModules, newFile, getResolvedModuleOfResolution, modules, moduleNameToDirectoryMap);
102690
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newFile.resolvedTypeReferenceDirectiveNames, newFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102691
+ }
102692
+ ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope);
102693
+ }
102694
+ if (needsResolutionUpdate) {
102695
+ var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
102696
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102697
+ if (!modules && !typeRefs) {
102698
+ oldModuleAndTypeRefCache = undefined;
102699
+ }
102700
+ else {
102701
+ oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
102702
+ }
102703
+ if (oldProgram) {
102704
+ for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
102705
+ var f = _c[_b];
102706
+ if (!newProgram.getSourceFileByPath(f.path))
102707
+ removeResolutionsOfFile(f.path);
101819
102708
  }
101820
- if (existing.length > expected) {
101821
- for (var i = expected; i < existing.length; i++) {
101822
- fileWatchesOfAffectingLocations.get(existing[i]).files--;
101823
- }
102709
+ var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
102710
+ if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
102711
+ removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
101824
102712
  }
101825
- if (expected)
101826
- impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
101827
- else
101828
- impliedFormatPackageJsons.delete(newFile.path);
101829
- });
101830
- impliedFormatPackageJsons.forEach(function (existing, path) {
101831
- if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
101832
- existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
101833
- impliedFormatPackageJsons.delete(path);
101834
- }
101835
- });
102713
+ }
101836
102714
  }
101837
- directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
101838
- if (watcher.refCount === 0) {
101839
- directoryWatchesOfFailedLookups.delete(path);
101840
- watcher.watcher.close();
102715
+ perFilePackageJsonScope.forEach(function (existing, path) {
102716
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
102717
+ stopWatchingPackageJsonScope(existing, path);
102718
+ perFilePackageJsonScope.delete(path);
101841
102719
  }
101842
102720
  });
102721
+ if (dirToPackageJsonScope.size) {
102722
+ oldPackageJsonInfoCache = getOldPackageJsonInfoCache(dirToPackageJsonScope);
102723
+ }
102724
+ else {
102725
+ oldPackageJsonInfoCache = undefined;
102726
+ }
102727
+ if (needsResolutionUpdate && (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions()))
102728
+ updateTypeRootsWatch();
102729
+ resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
102730
+ resolutionsToCloseWatcherOn = undefined;
102731
+ packageJsonsToCloseWatcherOn === null || packageJsonsToCloseWatcherOn === void 0 ? void 0 : packageJsonsToCloseWatcherOn.forEach(closeWatchersOfPackageJsonScope);
102732
+ packageJsonsToCloseWatcherOn = undefined;
101843
102733
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
101844
102734
  if (watcher.files === 0 && watcher.resolutions === 0) {
101845
102735
  fileWatchesOfAffectingLocations.delete(path);
101846
102736
  watcher.watcher.close();
101847
102737
  }
101848
102738
  });
101849
- hasChangedAutomaticTypeDirectiveNames = false;
101850
102739
  }
101851
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102740
+ function ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope) {
102741
+ var _a;
102742
+ var existing = perFilePackageJsonScope.get(newFile.path);
102743
+ var scope = ts.isExternalOrCommonJsModule(newFile) ? newFile.packageJsonScope : undefined;
102744
+ if (scope) {
102745
+ ((_a = scope.files) !== null && _a !== void 0 ? _a : (scope.files = new ts.Set())).add(newFile.path);
102746
+ watchPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
102747
+ watchPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
102748
+ perFilePackageJsonScope.set(newFile.path, scope);
102749
+ ts.moduleNameToDirectorySet(dirToPackageJsonScope, ts.getDirectoryPath(newFile.resolvedPath), scope, ts.getPackageJsconLocationFromScope, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102750
+ }
102751
+ if (existing && scope !== existing)
102752
+ stopWatchingPackageJsonScope(existing, newFile.path);
102753
+ }
102754
+ function stopWatchingPackageJsonScope(scope, path) {
101852
102755
  var _a, _b;
102756
+ (_a = scope.files) === null || _a === void 0 ? void 0 : _a.delete(path);
102757
+ if (!((_b = scope.files) === null || _b === void 0 ? void 0 : _b.size))
102758
+ (packageJsonsToCloseWatcherOn !== null && packageJsonsToCloseWatcherOn !== void 0 ? packageJsonsToCloseWatcherOn : (packageJsonsToCloseWatcherOn = [])).push(scope);
102759
+ }
102760
+ function watchPackageJsonScopeLocations(scope, locations, field) {
102761
+ var _a, _b;
102762
+ var locationsLength = (_a = locations === null || locations === void 0 ? void 0 : locations.length) !== null && _a !== void 0 ? _a : 0;
102763
+ if (!locationsLength || scope[field] === locationsLength)
102764
+ return;
102765
+ if (!scope.watchedFailed && !scope.watchedAffected)
102766
+ watchedPackageJsonScopes.push(scope);
102767
+ for (var i = (_b = scope[field]) !== null && _b !== void 0 ? _b : 0; i < locationsLength; i++) {
102768
+ createFileWatcherOfAffectingLocation(locations[i], false);
102769
+ }
102770
+ scope[field] = locationsLength;
102771
+ }
102772
+ function closeWatchersOfPackageJsonScope(scope) {
102773
+ var _a;
102774
+ if (((_a = scope.files) === null || _a === void 0 ? void 0 : _a.size) || !scope.files)
102775
+ return;
102776
+ scope.files = undefined;
102777
+ ts.unorderedRemoveItem(watchedPackageJsonScopes, scope);
102778
+ stopWatchingPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
102779
+ stopWatchingPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
102780
+ }
102781
+ function stopWatchingPackageJsonScopeLocations(scope, locations, field) {
102782
+ if (!scope[field])
102783
+ return;
102784
+ for (var i = 0; i < scope[field]; i++) {
102785
+ fileWatchesOfAffectingLocations.get(locations[i]).files--;
102786
+ }
102787
+ scope[field] = undefined;
102788
+ }
102789
+ function getOldPackageJsonInfoCache(dirToPackageJsonScope) {
102790
+ var packageJsons;
102791
+ return {
102792
+ getPackageJsonScope: function (dir) {
102793
+ var _a;
102794
+ var scope = dirToPackageJsonScope.get(dir);
102795
+ if (!scope)
102796
+ return undefined;
102797
+ if (!scope.isInvalidated)
102798
+ return scope;
102799
+ if (!resolutionHost.getCompilationSettings().cacheResolutions || !scope.info)
102800
+ return undefined;
102801
+ var packageJson = ts.getPackageJsconLocationFromScope(scope);
102802
+ var result = packageJsons === null || packageJsons === void 0 ? void 0 : packageJsons.get(packageJson);
102803
+ if (result !== undefined)
102804
+ return result || undefined;
102805
+ if (resolutionHost.fileExists(packageJson)) {
102806
+ result = {
102807
+ info: ts.getPackageJsonInfo(ts.getDirectoryPath(packageJson), false, ts.getTemporaryModuleResolutionState(moduleResolutionCache.getPackageJsonInfoCache(), ((_a = resolutionHost.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(resolutionHost)) || resolutionHost, resolutionHost.getCompilationSettings())),
102808
+ affectingLocations: [packageJson],
102809
+ };
102810
+ }
102811
+ (packageJsons !== null && packageJsons !== void 0 ? packageJsons : (packageJsons = new ts.Map())).set(packageJson, result || false);
102812
+ return result;
102813
+ }
102814
+ };
102815
+ }
102816
+ function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
102817
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102818
+ var resolutionsInFile = perFileCache.get(path);
102819
+ var seenNamesInFile = ts.createModeAwareCache();
102820
+ perDirCache = toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, function (key) {
102821
+ if (resolutionsInFile && resolutionsInFile.key !== key) {
102822
+ resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102823
+ resolutionsInFile = undefined;
102824
+ }
102825
+ }, function (r, name, mode, key) {
102826
+ seenNamesInFile.set(name, mode, true);
102827
+ var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
102828
+ if (existing && r !== existing)
102829
+ stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
102830
+ watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
102831
+ if (!resolutionsInFile)
102832
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
102833
+ resolutionsInFile.cache.set(name, mode, r);
102834
+ }, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102835
+ if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
102836
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102837
+ if (!seenNamesInFile.has(name, mode)) {
102838
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102839
+ resolutionsInFile.cache.delete(name, mode);
102840
+ }
102841
+ });
102842
+ if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
102843
+ perFileCache.delete(path);
102844
+ }
102845
+ return perDirCache;
102846
+ }
102847
+ function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
102848
+ if (!modules && !typeRefs)
102849
+ return undefined;
102850
+ return {
102851
+ modules: {
102852
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
102853
+ },
102854
+ typeRefs: {
102855
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, undefined); }
102856
+ },
102857
+ clearRedirectsMap: function () {
102858
+ modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
102859
+ typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
102860
+ moduleNameToDirectoryMap.clearRedirectsMap();
102861
+ },
102862
+ };
102863
+ }
102864
+ function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
102865
+ var _a, _b, _c, _d;
102866
+ if (!perDirCache)
102867
+ return undefined;
102868
+ 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)) ||
102869
+ ((_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));
102870
+ return result && !result.isInvalidated ? result : undefined;
102871
+ }
102872
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102873
+ var _a;
101853
102874
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
101854
102875
  if (!resolutionHost.getGlobalCache) {
101855
102876
  return primaryResult;
101856
102877
  }
101857
102878
  var globalCache = resolutionHost.getGlobalCache();
101858
102879
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
101859
- 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;
102880
+ 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;
101860
102881
  if (resolvedModule) {
101861
102882
  primaryResult.resolvedModule = resolvedModule;
101862
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
101863
- (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
102883
+ if (!compilerOptions.cacheResolutions)
102884
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
102885
+ else
102886
+ primaryResult.failedLookupLocations.length = 0;
102887
+ primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102888
+ primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
101864
102889
  return primaryResult;
101865
102890
  }
101866
102891
  }
@@ -101870,68 +102895,35 @@ var ts;
101870
102895
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
101871
102896
  }
101872
102897
  function resolveNamesWithLocalCache(_a) {
101873
- var _b, _c, _d;
101874
- 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;
102898
+ var _b, _c, _d, _e;
102899
+ 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;
101875
102900
  var path = resolutionHost.toPath(containingFile);
101876
- var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
101877
- var dirPath = ts.getDirectoryPath(path);
101878
- var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
101879
- var perDirectoryResolution = perDirectoryCache.get(dirPath);
101880
- if (!perDirectoryResolution) {
101881
- perDirectoryResolution = ts.createModeAwareCache();
101882
- perDirectoryCache.set(dirPath, perDirectoryResolution);
102901
+ var resolutionsInFile = perFileCache.get(path);
102902
+ var compilerOptions = resolutionHost.getCompilationSettings();
102903
+ var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
102904
+ if (!resolutionsInFile || resolutionsInFile.key !== key) {
102905
+ resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102906
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
101883
102907
  }
101884
102908
  var resolvedModules = [];
101885
- var compilerOptions = resolutionHost.getCompilationSettings();
101886
- var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
101887
- var program = resolutionHost.getCurrentProgram();
101888
- var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
101889
- var unmatchedRedirects = oldRedirect ?
101890
- !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
101891
- !!redirectedReference;
101892
102909
  var seenNamesInFile = ts.createModeAwareCache();
101893
102910
  var i = 0;
101894
- for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
101895
- var entry = names_5[_i];
101896
- var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
102911
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
102912
+ var entry = names_4[_i];
102913
+ var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
101897
102914
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
101898
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
102915
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
101899
102916
  i++;
101900
- var resolution = resolutionsInFile.get(name, mode);
101901
- if (!seenNamesInFile.has(name, mode) &&
101902
- unmatchedRedirects || !resolution || resolution.isInvalidated ||
101903
- (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
102917
+ var resolution = resolutionsInFile.cache.get(name, mode);
102918
+ if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
101904
102919
  var existingResolution = resolution;
101905
- var resolutionInDirectory = perDirectoryResolution.get(name, mode);
101906
- if (resolutionInDirectory) {
101907
- resolution = resolutionInDirectory;
101908
- var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
101909
- if (ts.isTraceEnabled(compilerOptions, host)) {
101910
- var resolved = getResolutionWithResolvedFileName(resolution);
101911
- ts.trace(host, loader === resolveModuleName ?
101912
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101913
- resolved.packagetId ?
101914
- 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 :
101915
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101916
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
101917
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101918
- resolved.packagetId ?
101919
- 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 :
101920
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101921
- 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));
101922
- }
102920
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102921
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102922
+ resolutionHost.onDiscoveredSymlink();
101923
102923
  }
101924
- else {
101925
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
101926
- perDirectoryResolution.set(name, mode, resolution);
101927
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
101928
- resolutionHost.onDiscoveredSymlink();
101929
- }
101930
- }
101931
- resolutionsInFile.set(name, mode, resolution);
101932
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
102924
+ resolutionsInFile.cache.set(name, mode, resolution);
101933
102925
  if (existingResolution) {
101934
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
102926
+ stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
101935
102927
  }
101936
102928
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
101937
102929
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -101944,27 +102936,33 @@ var ts;
101944
102936
  var resolved = getResolutionWithResolvedFileName(resolution);
101945
102937
  ts.trace(host, loader === resolveModuleName ?
101946
102938
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101947
- resolved.packagetId ?
102939
+ resolved.packageId ?
101948
102940
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101949
102941
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101950
102942
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
101951
102943
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101952
- resolved.packagetId ?
102944
+ resolved.packageId ?
101953
102945
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101954
102946
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101955
- 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));
102947
+ 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));
101956
102948
  }
101957
102949
  }
101958
102950
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
101959
102951
  seenNamesInFile.set(name, mode, true);
101960
- resolvedModules.push(getResolutionWithResolvedFileName(resolution));
102952
+ resolvedModules.push(resolution);
101961
102953
  }
101962
- resolutionsInFile.forEach(function (resolution, name, mode) {
101963
- if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
101964
- stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
101965
- resolutionsInFile.delete(name, mode);
101966
- }
102954
+ (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
102955
+ var name = _a.name, mode = _a.mode;
102956
+ return seenNamesInFile.set(name, mode, true);
101967
102957
  });
102958
+ if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
102959
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102960
+ if (!seenNamesInFile.has(name, mode)) {
102961
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102962
+ resolutionsInFile.cache.delete(name, mode);
102963
+ }
102964
+ });
102965
+ }
101968
102966
  return resolvedModules;
101969
102967
  function resolutionIsEqualTo(oldResolution, newResolution) {
101970
102968
  if (oldResolution === newResolution) {
@@ -101984,40 +102982,31 @@ var ts;
101984
102982
  return oldResult.resolvedFileName === newResult.resolvedFileName;
101985
102983
  }
101986
102984
  }
101987
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
102985
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
101988
102986
  return resolveNamesWithLocalCache({
101989
102987
  names: typeDirectiveNames,
101990
102988
  containingFile: containingFile,
101991
102989
  redirectedReference: redirectedReference,
101992
- cache: resolvedTypeReferenceDirectives,
101993
- perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
102990
+ perFileCache: resolvedTypeReferenceDirectives,
101994
102991
  loader: resolveTypeReferenceDirective,
101995
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
101996
- shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
101997
- containingSourceFileMode: containingFileMode
102992
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveOfResolution,
102993
+ containingSourceFileMode: containingFileMode,
102994
+ partialResolutionInfo: partialResolutionInfo,
101998
102995
  });
101999
102996
  }
102000
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
102997
+ function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
102001
102998
  return resolveNamesWithLocalCache({
102002
102999
  names: moduleNames,
102003
103000
  containingFile: containingFile,
102004
103001
  redirectedReference: redirectedReference,
102005
- cache: resolvedModuleNames,
102006
- perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
103002
+ perFileCache: resolvedModuleNames,
102007
103003
  loader: resolveModuleName,
102008
- getResolutionWithResolvedFileName: getResolvedModule,
102009
- shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
102010
- reusedNames: reusedNames,
103004
+ getResolutionWithResolvedFileName: getResolvedModuleOfResolution,
103005
+ partialResolutionInfo: partialResolutionInfo,
102011
103006
  logChanges: logChangesWhenResolvingModule,
102012
103007
  containingSourceFile: containingSourceFile,
102013
103008
  });
102014
103009
  }
102015
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
102016
- var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
102017
- if (!cache)
102018
- return undefined;
102019
- return cache.get(moduleName, resolutionMode);
102020
- }
102021
103010
  function isNodeModulesAtTypesDirectory(dirPath) {
102022
103011
  return ts.endsWith(dirPath, "/node_modules/@types");
102023
103012
  }
@@ -102071,37 +103060,41 @@ var ts;
102071
103060
  function isPathWithDefaultFailedLookupExtension(path) {
102072
103061
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
102073
103062
  }
102074
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
102075
- if (resolution.refCount) {
102076
- resolution.refCount++;
102077
- ts.Debug.assertIsDefined(resolution.files);
103063
+ function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
103064
+ if (resolution.files) {
103065
+ resolution.files.add(filePath);
103066
+ if (resolution.watchedFailed !== false)
103067
+ watchFailedLookupLocationOfResolution(resolution);
103068
+ watchAffectingLocationsOfResolution(resolution);
103069
+ return;
103070
+ }
103071
+ resolution.files = new ts.Set();
103072
+ resolution.files.add(filePath);
103073
+ var resolved = getResolutionWithResolvedFileName(resolution);
103074
+ if (resolved && resolved.resolvedFileName) {
103075
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
103076
+ }
103077
+ if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
103078
+ watchFailedLookupLocationOfResolution(resolution);
103079
+ watchAffectingLocationsOfResolution(resolution);
102078
103080
  }
102079
103081
  else {
102080
- resolution.refCount = 1;
102081
- ts.Debug.assert(ts.length(resolution.files) === 0);
102082
- if (ts.isExternalModuleNameRelative(name)) {
102083
- watchFailedLookupLocationOfResolution(resolution);
102084
- }
102085
- else {
102086
- nonRelativeExternalModuleResolutions.add(name, resolution);
102087
- }
102088
- var resolved = getResolutionWithResolvedFileName(resolution);
102089
- if (resolved && resolved.resolvedFileName) {
102090
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102091
- }
103082
+ resolution.watchedFailed = false;
103083
+ watchAffectingLocationsOfResolution(resolution);
102092
103084
  }
102093
- (resolution.files || (resolution.files = [])).push(filePath);
102094
103085
  }
102095
103086
  function watchFailedLookupLocationOfResolution(resolution) {
102096
- ts.Debug.assert(!!resolution.refCount);
102097
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102098
- if (!failedLookupLocations.length && !affectingLocations.length)
103087
+ var failedLookupLocations = resolution.failedLookupLocations;
103088
+ if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
102099
103089
  return;
102100
- if (failedLookupLocations.length)
103090
+ if (!resolution.watchedFailed) {
102101
103091
  resolutionsWithFailedLookups.push(resolution);
102102
- var setAtRoot = false;
102103
- for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
102104
- var failedLookupLocation = failedLookupLocations_1[_i];
103092
+ if (resolution.watchedAffected)
103093
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
103094
+ }
103095
+ var setAtRoot = !!resolution.setAtRoot;
103096
+ for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
103097
+ var failedLookupLocation = failedLookupLocations[i];
102105
103098
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102106
103099
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102107
103100
  if (toWatch) {
@@ -102119,22 +103112,22 @@ var ts;
102119
103112
  }
102120
103113
  }
102121
103114
  }
102122
- if (setAtRoot) {
103115
+ if (setAtRoot && !resolution.setAtRoot) {
102123
103116
  setDirectoryWatcher(rootDir, rootPath, true);
102124
103117
  }
102125
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
103118
+ resolution.setAtRoot = setAtRoot;
103119
+ resolution.watchedFailed = failedLookupLocations.length;
102126
103120
  }
102127
- function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
102128
- ts.Debug.assert(!!resolution.refCount);
103121
+ function watchAffectingLocationsOfResolution(resolution) {
102129
103122
  var affectingLocations = resolution.affectingLocations;
102130
- if (!affectingLocations.length)
103123
+ if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
102131
103124
  return;
102132
- if (addToResolutionsWithOnlyAffectingLocations)
103125
+ if (!resolution.watchedFailed && !resolution.watchedAffected)
102133
103126
  resolutionsWithOnlyAffectingLocations.push(resolution);
102134
- for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
102135
- var affectingLocation = affectingLocations_1[_i];
102136
- createFileWatcherOfAffectingLocation(affectingLocation, true);
103127
+ for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
103128
+ createFileWatcherOfAffectingLocation(affectingLocations[i], true);
102137
103129
  }
103130
+ resolution.watchedAffected = affectingLocations.length;
102138
103131
  }
102139
103132
  function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
102140
103133
  var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
@@ -102193,15 +103186,6 @@ var ts;
102193
103186
  paths.add(affectingLocation);
102194
103187
  }
102195
103188
  }
102196
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
102197
- var program = resolutionHost.getCurrentProgram();
102198
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
102199
- resolutions.forEach(watchFailedLookupLocationOfResolution);
102200
- }
102201
- else {
102202
- resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); });
102203
- }
102204
- }
102205
103189
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
102206
103190
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102207
103191
  if (dirWatcher) {
@@ -102212,21 +103196,27 @@ var ts;
102212
103196
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
102213
103197
  }
102214
103198
  }
102215
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102216
- ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
102217
- resolution.refCount--;
102218
- if (resolution.refCount) {
103199
+ function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
103200
+ var _a, _b;
103201
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
103202
+ if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
103203
+ (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
103204
+ }
103205
+ function closeWatchersOfResolution(_a) {
103206
+ var _b;
103207
+ var resolution = _a.resolution, getResolved = _a.getResolved;
103208
+ if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
102219
103209
  return;
102220
- }
102221
- var resolved = getResolutionWithResolvedFileName(resolution);
103210
+ resolution.files = undefined;
103211
+ var resolved = getResolved(resolution);
102222
103212
  if (resolved && resolved.resolvedFileName) {
102223
103213
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102224
103214
  }
102225
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102226
- if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
103215
+ if (resolution.watchedFailed) {
103216
+ ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
102227
103217
  var removeAtRoot = false;
102228
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
102229
- var failedLookupLocation = failedLookupLocations_2[_i];
103218
+ for (var i = 0; i < resolution.watchedFailed; i++) {
103219
+ var failedLookupLocation = resolution.failedLookupLocations[i];
102230
103220
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102231
103221
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102232
103222
  if (toWatch) {
@@ -102249,22 +103239,28 @@ var ts;
102249
103239
  }
102250
103240
  }
102251
103241
  }
103242
+ ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
102252
103243
  if (removeAtRoot) {
102253
103244
  removeDirectoryWatcher(rootPath);
102254
103245
  }
102255
103246
  }
102256
- else if (affectingLocations.length) {
103247
+ else if (resolution.watchedAffected) {
102257
103248
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102258
103249
  }
102259
- for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
102260
- var affectingLocation = affectingLocations_2[_a];
102261
- var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102262
- watcher.resolutions--;
103250
+ if (resolution.watchedAffected) {
103251
+ for (var i = 0; i < resolution.watchedAffected; i++) {
103252
+ var watcher = fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]);
103253
+ watcher.resolutions--;
103254
+ }
102263
103255
  }
102264
103256
  }
102265
103257
  function removeDirectoryWatcher(dirPath) {
102266
103258
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102267
103259
  dirWatcher.refCount--;
103260
+ if (dirWatcher.refCount === 0) {
103261
+ directoryWatchesOfFailedLookups.delete(dirPath);
103262
+ dirWatcher.watcher.close();
103263
+ }
102268
103264
  }
102269
103265
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
102270
103266
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -102278,26 +103274,16 @@ var ts;
102278
103274
  function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
102279
103275
  var resolutions = cache.get(filePath);
102280
103276
  if (resolutions) {
102281
- resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
103277
+ resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
102282
103278
  cache.delete(filePath);
102283
103279
  }
102284
103280
  }
102285
- function removeResolutionsFromProjectReferenceRedirects(filePath) {
102286
- if (!ts.fileExtensionIs(filePath, ".json"))
102287
- return;
102288
- var program = resolutionHost.getCurrentProgram();
102289
- if (!program)
102290
- return;
102291
- var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
102292
- if (!resolvedProjectReference)
102293
- return;
102294
- resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
102295
- }
102296
103281
  function removeResolutionsOfFile(filePath) {
102297
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
102298
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
103282
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleOfResolution);
103283
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveOfResolution);
102299
103284
  }
102300
103285
  function invalidateResolutions(resolutions, canInvalidate) {
103286
+ var _a;
102301
103287
  if (!resolutions)
102302
103288
  return false;
102303
103289
  var invalidated = false;
@@ -102306,16 +103292,14 @@ var ts;
102306
103292
  if (resolution.isInvalidated || !canInvalidate(resolution))
102307
103293
  continue;
102308
103294
  resolution.isInvalidated = invalidated = true;
102309
- for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102310
- var containingFilePath = _b[_a];
103295
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
102311
103296
  (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102312
103297
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
102313
- }
103298
+ });
102314
103299
  }
102315
103300
  return invalidated;
102316
103301
  }
102317
103302
  function invalidateResolutionOfFile(filePath) {
102318
- removeResolutionsOfFile(filePath);
102319
103303
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
102320
103304
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
102321
103305
  hasChangedAutomaticTypeDirectiveNames &&
@@ -102324,8 +103308,28 @@ var ts;
102324
103308
  }
102325
103309
  }
102326
103310
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
102327
- ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
102328
- filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
103311
+ filesMap.forEach(function (_a, filePath) {
103312
+ var imports = _a.imports;
103313
+ if (!imports.length)
103314
+ return;
103315
+ var resolvedModules = resolvedModuleNames.get(filePath);
103316
+ var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
103317
+ if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
103318
+ return;
103319
+ imports.forEach(function (_a) {
103320
+ var name = _a.name, mode = _a.mode;
103321
+ var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
103322
+ if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
103323
+ resolvedModule.isInvalidated = true;
103324
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103325
+ }
103326
+ var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
103327
+ if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
103328
+ resolvedTypeRef.isInvalidated = true;
103329
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103330
+ }
103331
+ });
103332
+ });
102329
103333
  }
102330
103334
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
102331
103335
  if (isCreatingWatchedDirectory) {
@@ -102364,12 +103368,17 @@ var ts;
102364
103368
  var _a;
102365
103369
  var invalidated = false;
102366
103370
  if (affectingPathChecksForFile) {
102367
- (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
102368
- if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
102369
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
103371
+ for (var _i = 0, watchedPackageJsonScopes_1 = watchedPackageJsonScopes; _i < watchedPackageJsonScopes_1.length; _i++) {
103372
+ var scope = watchedPackageJsonScopes_1[_i];
103373
+ if (scope.isInvalidated)
103374
+ continue;
103375
+ if (ts.some(scope.failedLookupLocations, function (location) { return affectingPathChecksForFile.has(location); }) ||
103376
+ ts.some(scope.affectingLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
103377
+ scope.isInvalidated = true;
102370
103378
  invalidated = true;
103379
+ (_a = scope.files) === null || _a === void 0 ? void 0 : _a.forEach(function (path) { return (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(path); });
102371
103380
  }
102372
- });
103381
+ }
102373
103382
  affectingPathChecksForFile = undefined;
102374
103383
  }
102375
103384
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
@@ -102400,7 +103409,8 @@ var ts;
102400
103409
  ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
102401
103410
  }
102402
103411
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102403
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
103412
+ var _a;
103413
+ return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) { return affectingPathChecks.has(location); }));
102404
103414
  }
102405
103415
  function closeTypeRootsWatch() {
102406
103416
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -102701,9 +103711,9 @@ var ts;
102701
103711
  var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
102702
103712
  var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
102703
103713
  if (!preferSymlinks) {
102704
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
102705
- if (result_16)
102706
- return result_16;
103714
+ var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
103715
+ if (result_17)
103716
+ return result_17;
102707
103717
  }
102708
103718
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
102709
103719
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -102722,10 +103732,10 @@ var ts;
102722
103732
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
102723
103733
  var symlinkDirectory = symlinkDirectories_1[_i];
102724
103734
  var option = ts.resolvePath(symlinkDirectory, relative);
102725
- var result_17 = cb(option, target === referenceRedirect);
103735
+ var result_18 = cb(option, target === referenceRedirect);
102726
103736
  shouldFilterIgnoredPaths = true;
102727
- if (result_17)
102728
- return result_17;
103737
+ if (result_18)
103738
+ return result_18;
102729
103739
  }
102730
103740
  });
102731
103741
  });
@@ -102784,9 +103794,9 @@ var ts;
102784
103794
  };
102785
103795
  var out_directory_1;
102786
103796
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
102787
- var state_11 = _loop_35(directory);
103797
+ var state_12 = _loop_35(directory);
102788
103798
  directory = out_directory_1;
102789
- if (state_11 === "break")
103799
+ if (state_12 === "break")
102790
103800
  break;
102791
103801
  }
102792
103802
  if (allFileNames.size) {
@@ -102876,9 +103886,9 @@ var ts;
102876
103886
  };
102877
103887
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
102878
103888
  var patternText_1 = _a[_i];
102879
- var state_12 = _loop_36(patternText_1);
102880
- if (typeof state_12 === "object")
102881
- return state_12.value;
103889
+ var state_13 = _loop_36(patternText_1);
103890
+ if (typeof state_13 === "object")
103891
+ return state_13.value;
102882
103892
  }
102883
103893
  }
102884
103894
  function validateEnding(_a) {
@@ -103331,7 +104341,7 @@ var ts;
103331
104341
  }
103332
104342
  ts.explainFiles = explainFiles;
103333
104343
  function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
103334
- var _a;
104344
+ var _a, _b;
103335
104345
  var result;
103336
104346
  if (file.path !== file.resolvedPath) {
103337
104347
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
@@ -103342,17 +104352,17 @@ var ts;
103342
104352
  if (ts.isExternalOrCommonJsModule(file)) {
103343
104353
  switch (file.impliedNodeFormat) {
103344
104354
  case ts.ModuleKind.ESNext:
103345
- if (file.packageJsonScope) {
103346
- (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
104355
+ if ((_a = file.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
104356
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
103347
104357
  }
103348
104358
  break;
103349
104359
  case ts.ModuleKind.CommonJS:
103350
- if (file.packageJsonScope) {
103351
- (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.packageJsonContent.type ?
104360
+ if ((_b = file.packageJsonScope) === null || _b === void 0 ? void 0 : _b.info) {
104361
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.info.packageJsonContent.type ?
103352
104362
  ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
103353
- ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
104363
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
103354
104364
  }
103355
- else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
104365
+ else if (file.packageJsonScope) {
103356
104366
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
103357
104367
  }
103358
104368
  break;
@@ -103723,7 +104733,7 @@ var ts;
103723
104733
  })(ts || (ts = {}));
103724
104734
  var ts;
103725
104735
  (function (ts) {
103726
- function readBuilderProgram(compilerOptions, host) {
104736
+ function readBuildInfoForProgram(compilerOptions, host) {
103727
104737
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
103728
104738
  if (!buildInfoPath)
103729
104739
  return undefined;
@@ -103743,7 +104753,12 @@ var ts;
103743
104753
  return undefined;
103744
104754
  if (!buildInfo.program)
103745
104755
  return undefined;
103746
- return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
104756
+ return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
104757
+ }
104758
+ ts.readBuildInfoForProgram = readBuildInfoForProgram;
104759
+ function readBuilderProgram(compilerOptions, host) {
104760
+ var result = readBuildInfoForProgram(compilerOptions, host);
104761
+ return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
103747
104762
  }
103748
104763
  ts.readBuilderProgram = readBuilderProgram;
103749
104764
  function createIncrementalCompilerHost(options, system) {
@@ -103876,7 +104891,7 @@ var ts;
103876
104891
  }
103877
104892
  return host.resolveModuleNames.apply(host, args);
103878
104893
  }) :
103879
- (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
104894
+ (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
103880
104895
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
103881
104896
  (function () {
103882
104897
  var args = [];
@@ -103885,10 +104900,13 @@ var ts;
103885
104900
  }
103886
104901
  return host.resolveTypeReferenceDirectives.apply(host, args);
103887
104902
  }) :
103888
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
104903
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
103889
104904
  compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
103890
104905
  ts.maybeBind(host, host.getModuleResolutionCache) :
103891
104906
  (function () { return resolutionCache.getModuleResolutionCache(); });
104907
+ compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
104908
+ ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
104909
+ (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
103892
104910
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
103893
104911
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
103894
104912
  synchronizeProgram();
@@ -103954,7 +104972,8 @@ var ts;
103954
104972
  }
103955
104973
  }
103956
104974
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
103957
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
104975
+ var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
104976
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103958
104977
  if (hasChangedConfigFileParsingErrors) {
103959
104978
  if (reportFileChangeDetectedOnCreateProgram) {
103960
104979
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -103973,6 +104992,11 @@ var ts;
103973
104992
  if (host.afterProgramCreate && program !== builderProgram) {
103974
104993
  host.afterProgramCreate(builderProgram);
103975
104994
  }
104995
+ compilerHost.readFile = originalReadFile;
104996
+ compilerHost.fileExists = originalFileExists;
104997
+ compilerHost.directoryExists = originalDirectoryExists;
104998
+ compilerHost.createDirectory = originalCreateDirectory;
104999
+ compilerHost.writeFile = originalWriteFile;
103976
105000
  return builderProgram;
103977
105001
  }
103978
105002
  function createNewProgram(hasInvalidatedResolution) {
@@ -103981,7 +105005,6 @@ var ts;
103981
105005
  writeLog(" options: " + JSON.stringify(compilerOptions));
103982
105006
  if (projectReferences)
103983
105007
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
103984
- var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
103985
105008
  hasChangedCompilerOptions = false;
103986
105009
  hasChangedConfigFileParsingErrors = false;
103987
105010
  resolutionCache.startCachingPerDirectoryResolution();
@@ -103991,9 +105014,6 @@ var ts;
103991
105014
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
103992
105015
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
103993
105016
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
103994
- if (needsUpdateInTypeRootWatch) {
103995
- resolutionCache.updateTypeRootsWatch();
103996
- }
103997
105017
  if (missingFilePathsRequestedForRelease) {
103998
105018
  for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
103999
105019
  var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
@@ -104078,7 +105098,7 @@ var ts;
104078
105098
  var hostSourceFile = sourceFilesCache.get(path);
104079
105099
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
104080
105100
  }
104081
- function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
105101
+ function onReleaseOldSourceFile(oldSourceFile) {
104082
105102
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
104083
105103
  if (hostSourceFileInfo !== undefined) {
104084
105104
  if (isFileMissingOnHost(hostSourceFileInfo)) {
@@ -104089,9 +105109,6 @@ var ts;
104089
105109
  hostSourceFileInfo.fileWatcher.close();
104090
105110
  }
104091
105111
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
104092
- if (!hasSourceFileByPath) {
104093
- resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
104094
- }
104095
105112
  }
104096
105113
  }
104097
105114
  }
@@ -104326,7 +105343,6 @@ var ts;
104326
105343
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
104327
105344
  if (config)
104328
105345
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104329
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
104330
105346
  }
104331
105347
  scheduleProgramUpdate();
104332
105348
  });
@@ -104339,7 +105355,6 @@ var ts;
104339
105355
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
104340
105356
  if (config)
104341
105357
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104342
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
104343
105358
  scheduleProgramUpdate();
104344
105359
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
104345
105360
  if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) {
@@ -104512,20 +105527,22 @@ var ts;
104512
105527
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
104513
105528
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
104514
105529
  compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
105530
+ compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
104515
105531
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
104516
105532
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
104517
105533
  if (!compilerHost.resolveModuleNames) {
104518
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
104519
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
104520
- return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
105534
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
105535
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
105536
+ return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
104521
105537
  };
104522
105538
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
104523
105539
  }
104524
105540
  if (!compilerHost.resolveTypeReferenceDirectives) {
104525
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
105541
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
104526
105542
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
104527
- return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
105543
+ return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
104528
105544
  };
105545
+ compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
104529
105546
  }
104530
105547
  compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), undefined); };
104531
105548
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -105469,7 +106486,7 @@ var ts;
105469
106486
  if (buildInfoTime && buildInfoTime < inputTime) {
105470
106487
  var version_3 = void 0;
105471
106488
  var currentVersion = void 0;
105472
- if (buildInfoProgram) {
106489
+ if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
105473
106490
  if (!buildInfoVersionMap)
105474
106491
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
105475
106492
  version_3 = buildInfoVersionMap.get(toPath(state, inputFile));