@typescript-deploys/pr-build 4.9.0-pr-50293-2 → 4.9.0-pr-50294-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -6671,6 +6671,8 @@ var ts;
6671
6671
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
6672
6672
  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}"),
6673
6673
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
6674
+ 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."),
6675
+ 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."),
6674
6676
  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."),
6675
6677
  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}'."),
6676
6678
  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."),
@@ -6855,6 +6857,7 @@ var ts;
6855
6857
  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."),
6856
6858
  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."),
6857
6859
  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."),
6860
+ 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."),
6858
6861
  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'."),
6859
6862
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
6860
6863
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -10992,7 +10995,8 @@ var ts;
10992
10995
  }
10993
10996
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
10994
10997
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
10995
- return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10998
+ return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
10999
+ optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10996
11000
  }
10997
11001
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
10998
11002
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -11064,21 +11068,20 @@ var ts;
11064
11068
  }
11065
11069
  ts.getFullWidth = getFullWidth;
11066
11070
  function getResolvedModule(sourceFile, moduleNameText, mode) {
11067
- return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
11071
+ var _a, _b;
11072
+ 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;
11068
11073
  }
11069
11074
  ts.getResolvedModule = getResolvedModule;
11070
11075
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
11071
- if (!sourceFile.resolvedModules) {
11072
- sourceFile.resolvedModules = ts.createModeAwareCache();
11073
- }
11076
+ var _a;
11077
+ (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
11074
11078
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
11075
11079
  }
11076
11080
  ts.setResolvedModule = setResolvedModule;
11077
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
11078
- if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
11079
- sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
11080
- }
11081
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, undefined, resolvedTypeReferenceDirective);
11081
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
11082
+ var _a;
11083
+ (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
11084
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
11082
11085
  }
11083
11086
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
11084
11087
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -11088,11 +11091,15 @@ var ts;
11088
11091
  }
11089
11092
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
11090
11093
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
11091
- return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
11092
- oldResolution.extension === newResolution.extension &&
11093
- oldResolution.resolvedFileName === newResolution.resolvedFileName &&
11094
- oldResolution.originalPath === newResolution.originalPath &&
11095
- packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
11094
+ return oldResolution === newResolution ||
11095
+ oldResolution.resolvedModule === newResolution.resolvedModule ||
11096
+ !!oldResolution.resolvedModule &&
11097
+ !!newResolution.resolvedModule &&
11098
+ oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
11099
+ oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
11100
+ oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
11101
+ oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
11102
+ packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
11096
11103
  }
11097
11104
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
11098
11105
  function packageIdIsEqual(a, b) {
@@ -11108,9 +11115,13 @@ var ts;
11108
11115
  }
11109
11116
  ts.packageIdToString = packageIdToString;
11110
11117
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
11111
- return oldResolution.resolvedFileName === newResolution.resolvedFileName
11112
- && oldResolution.primary === newResolution.primary
11113
- && oldResolution.originalPath === newResolution.originalPath;
11118
+ return oldResolution === newResolution ||
11119
+ oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
11120
+ !!oldResolution.resolvedTypeReferenceDirective &&
11121
+ !!newResolution.resolvedTypeReferenceDirective &&
11122
+ oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
11123
+ !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
11124
+ oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
11114
11125
  }
11115
11126
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
11116
11127
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -15310,15 +15321,15 @@ var ts;
15310
15321
  }
15311
15322
  ts.base64decode = base64decode;
15312
15323
  function readJsonOrUndefined(path, hostOrText) {
15313
- var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
15324
+ var jsonText = ts.isString(hostOrText) || hostOrText === undefined ? hostOrText : hostOrText.readFile(path);
15314
15325
  if (!jsonText)
15315
15326
  return undefined;
15316
15327
  var result = ts.parseConfigFileTextToJson(path, jsonText);
15317
15328
  return !result.error ? result.config : undefined;
15318
15329
  }
15319
15330
  ts.readJsonOrUndefined = readJsonOrUndefined;
15320
- function readJson(path, host) {
15321
- return readJsonOrUndefined(path, host) || {};
15331
+ function readJson(path, hostOrText) {
15332
+ return readJsonOrUndefined(path, hostOrText) || {};
15322
15333
  }
15323
15334
  ts.readJson = readJson;
15324
15335
  function directoryProbablyExists(directoryName, host) {
@@ -16298,14 +16309,15 @@ var ts;
16298
16309
  },
16299
16310
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
16300
16311
  var _this = this;
16301
- var _a;
16312
+ var _a, _b;
16302
16313
  ts.Debug.assert(!hasProcessedResolutions);
16303
16314
  hasProcessedResolutions = true;
16304
16315
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
16305
16316
  var file = files_1[_i];
16306
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
16317
+ (_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); });
16318
+ (_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); });
16307
16319
  }
16308
- typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
16320
+ typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
16309
16321
  },
16310
16322
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
16311
16323
  };
@@ -32226,6 +32238,17 @@ var ts;
32226
32238
  transpileOptionValue: undefined,
32227
32239
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
32228
32240
  },
32241
+ {
32242
+ name: "cacheResolutions",
32243
+ type: "boolean",
32244
+ category: ts.Diagnostics.Projects,
32245
+ description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
32246
+ affectsModuleResolution: true,
32247
+ affectsMultiFileEmitBuildInfo: true,
32248
+ affectsBundleEmitBuildInfo: true,
32249
+ transpileOptionValue: undefined,
32250
+ defaultValueDescription: false,
32251
+ },
32229
32252
  {
32230
32253
  name: "assumeChangesOnlyAffectDirectDependencies",
32231
32254
  type: "boolean",
@@ -34182,6 +34205,9 @@ var ts;
34182
34205
  if (result.configFilePath) {
34183
34206
  result.configFilePath = toAbsolutePath(result.configFilePath);
34184
34207
  }
34208
+ if (result.pathsBasePath) {
34209
+ result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
34210
+ }
34185
34211
  return result;
34186
34212
  }
34187
34213
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -35007,20 +35033,35 @@ var ts;
35007
35033
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
35008
35034
  return { fileName: resolved.path, packageId: resolved.packageId };
35009
35035
  }
35010
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
35011
- var _a, _b;
35036
+ function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
35037
+ var _a;
35038
+ var _b;
35012
35039
  if (resultFromCache) {
35013
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
35014
- (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
35040
+ if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
35041
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
35042
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
35043
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
35015
35044
  return resultFromCache;
35016
35045
  }
35017
35046
  return {
35018
35047
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
35019
- failedLookupLocations: failedLookupLocations,
35020
- affectingLocations: affectingLocations,
35021
- resolutionDiagnostics: diagnostics,
35048
+ failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
35049
+ affectingLocations: initializeResolutionField(affectingLocations),
35050
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
35022
35051
  };
35023
35052
  }
35053
+ function initializeResolutionField(value) {
35054
+ return value.length ? value : undefined;
35055
+ }
35056
+ function updateResolutionField(to, value) {
35057
+ if (!(value === null || value === void 0 ? void 0 : value.length))
35058
+ return to;
35059
+ if (!(to === null || to === void 0 ? void 0 : to.length))
35060
+ return value;
35061
+ to.push.apply(to, value);
35062
+ return to;
35063
+ }
35064
+ ts.updateResolutionField = updateResolutionField;
35024
35065
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
35025
35066
  if (!ts.hasProperty(jsonContent, fieldName)) {
35026
35067
  if (state.traceEnabled) {
@@ -35159,8 +35200,7 @@ var ts;
35159
35200
  options = redirectedReference.commandLine.options;
35160
35201
  }
35161
35202
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
35162
- var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
35163
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35203
+ var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, resolutionMode, redirectedReference) : undefined;
35164
35204
  if (result) {
35165
35205
  if (traceEnabled) {
35166
35206
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35211,7 +35251,7 @@ var ts;
35211
35251
  features: features,
35212
35252
  conditions: conditions,
35213
35253
  requestContainingDirectory: containingDirectory,
35214
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35254
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35215
35255
  };
35216
35256
  var resolved = primaryLookup();
35217
35257
  var primary = true;
@@ -35231,8 +35271,15 @@ var ts;
35231
35271
  isExternalLibraryImport: pathContainsNodeModules(fileName),
35232
35272
  };
35233
35273
  }
35234
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
35235
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35274
+ result = {
35275
+ resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
35276
+ failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
35277
+ affectingLocations: initializeResolutionField(affectingLocations),
35278
+ resolutionDiagnostics: initializeResolutionField(diagnostics),
35279
+ };
35280
+ if (containingDirectory && cache) {
35281
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35282
+ }
35236
35283
  if (traceEnabled)
35237
35284
  traceResult(result);
35238
35285
  return result;
@@ -35242,10 +35289,10 @@ var ts;
35242
35289
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
35243
35290
  }
35244
35291
  else if (result.resolvedTypeReferenceDirective.packageId) {
35245
- 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);
35292
+ 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);
35246
35293
  }
35247
35294
  else {
35248
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
35295
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
35249
35296
  }
35250
35297
  }
35251
35298
  function primaryLookup() {
@@ -35340,62 +35387,181 @@ var ts;
35340
35387
  return result;
35341
35388
  }
35342
35389
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
35343
- function createCacheWithRedirects(options) {
35344
- var ownMap = new ts.Map();
35390
+ function getPackageJsconLocationFromScope(scope) {
35391
+ return ts.lastOrUndefined(scope.affectingLocations);
35392
+ }
35393
+ ts.getPackageJsconLocationFromScope = getPackageJsconLocationFromScope;
35394
+ function compilerOptionValueToString(value) {
35395
+ var _a;
35396
+ if (value === null || typeof value !== "object") {
35397
+ return "" + value;
35398
+ }
35399
+ if (ts.isArray(value)) {
35400
+ return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
35401
+ }
35402
+ var str = "{";
35403
+ for (var key in value) {
35404
+ if (ts.hasProperty(value, key)) {
35405
+ str += key + ": " + compilerOptionValueToString(value[key]);
35406
+ }
35407
+ }
35408
+ return str + "}";
35409
+ }
35410
+ function getKeyForCompilationSettings(settings, options) {
35411
+ return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
35412
+ }
35413
+ ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
35414
+ function getRedirectsCacheKey(options) {
35415
+ return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
35416
+ }
35417
+ ts.getRedirectsCacheKey = getRedirectsCacheKey;
35418
+ function createCacheWithRedirects(ownOptions) {
35419
+ var ownMap;
35420
+ var ownKey;
35421
+ var redirectsKeyToCache = new ts.Map();
35345
35422
  var redirectsMap = new ts.Map();
35346
35423
  return {
35347
35424
  getOwnMap: getOwnMap,
35348
- redirectsMap: redirectsMap,
35425
+ redirectsKeyToCache: redirectsKeyToCache,
35426
+ createMapForCompilerOptions: createMapForCompilerOptions,
35427
+ getMapOfCacheRedirects: getMapOfCacheRedirects,
35349
35428
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
35350
35429
  clear: clear,
35351
- setOwnOptions: setOwnOptions,
35352
- setOwnMap: setOwnMap
35430
+ update: update,
35431
+ clearRedirectsMap: function () { return redirectsMap.clear(); },
35353
35432
  };
35354
- function getOwnMap() {
35355
- return ownMap;
35433
+ function ensureOwnKeyCached() {
35434
+ ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
35435
+ if (ownKey && !redirectsKeyToCache.has(ownKey))
35436
+ redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
35356
35437
  }
35357
- function setOwnOptions(newOptions) {
35358
- options = newOptions;
35438
+ function createMapForCompilerOptions(options, optionsKey) {
35439
+ if (options === ownOptions)
35440
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35441
+ return getOrCreateRedirectMapAndKey(options, undefined, optionsKey);
35359
35442
  }
35360
- function setOwnMap(newOwnMap) {
35361
- ownMap = newOwnMap;
35443
+ function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
35444
+ var _a;
35445
+ if (path || options.configFile) {
35446
+ var redirects = redirectsMap.get(path || options.configFile.path);
35447
+ if (redirects)
35448
+ return redirects;
35449
+ }
35450
+ var key = optionsKey || getRedirectsCacheKey(options);
35451
+ var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
35452
+ if (!map) {
35453
+ ensureOwnKeyCached();
35454
+ if (ownKey === key) {
35455
+ map = ownMap;
35456
+ }
35457
+ else {
35458
+ redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
35459
+ }
35460
+ }
35461
+ if (path || options.configFile)
35462
+ redirectsMap.set(path || options.configFile.path, map);
35463
+ return map;
35362
35464
  }
35363
- function getOrCreateMapOfCacheRedirects(redirectedReference) {
35364
- if (!redirectedReference) {
35365
- return ownMap;
35465
+ function getOwnMap() {
35466
+ return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35467
+ }
35468
+ function update(newOwnOptions) {
35469
+ if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
35470
+ ensureOwnKeyCached();
35471
+ if (!redirectsMap.has(ownOptions.configFile.path)) {
35472
+ redirectsMap.set(ownOptions.configFile.path, ownMap);
35473
+ }
35474
+ }
35475
+ if (newOwnOptions.configFile) {
35476
+ var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
35477
+ if (existing_1) {
35478
+ ownMap = existing_1;
35479
+ ownOptions = newOwnOptions;
35480
+ return;
35481
+ }
35366
35482
  }
35367
- var path = redirectedReference.sourceFile.path;
35368
- var redirects = redirectsMap.get(path);
35369
- if (!redirects) {
35370
- redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
35371
- redirectsMap.set(path, redirects);
35483
+ var key = getRedirectsCacheKey(newOwnOptions);
35484
+ var existing = redirectsKeyToCache.get(key);
35485
+ ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
35486
+ ownKey = key;
35487
+ ownOptions = newOwnOptions;
35488
+ if (newOwnOptions.configFile)
35489
+ redirectsMap.set(newOwnOptions.configFile.path, ownMap);
35490
+ }
35491
+ function getMapOfCacheRedirects(redirectedReference) {
35492
+ if (!redirectedReference)
35493
+ return ownMap;
35494
+ var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
35495
+ if (directResult)
35496
+ return directResult;
35497
+ var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
35498
+ var fromKey = redirectsKeyToCache.get(key);
35499
+ if (fromKey) {
35500
+ redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
35501
+ return fromKey.map;
35502
+ }
35503
+ if (ownMap)
35504
+ ensureOwnKeyCached();
35505
+ if (ownKey === key) {
35506
+ redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
35507
+ return ownMap;
35372
35508
  }
35373
- return redirects;
35509
+ return undefined;
35510
+ }
35511
+ function getOrCreateMapOfCacheRedirects(redirectedReference) {
35512
+ return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
35513
+ getOwnMap() :
35514
+ getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, undefined);
35374
35515
  }
35375
35516
  function clear() {
35376
- ownMap.clear();
35517
+ ownKey = undefined;
35518
+ ownMap = undefined;
35377
35519
  redirectsMap.clear();
35520
+ redirectsKeyToCache.clear();
35378
35521
  }
35379
35522
  }
35380
35523
  ts.createCacheWithRedirects = createCacheWithRedirects;
35381
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35382
- var cache;
35383
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
35524
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
35525
+ var dirToPackageJsonScope = new ts.Map();
35526
+ var oldPackageJsonInfoCache;
35527
+ return {
35528
+ getPackageJsonInfo: getPackageJsonInfo,
35529
+ setPackageJsonInfo: setPackageJsonInfo,
35530
+ clear: clear,
35531
+ entries: entries,
35532
+ getInternalMap: function () { return cache; },
35533
+ setInternalMap: function (value) { return cache = value; },
35534
+ clone: clone,
35535
+ getPackageJsonScope: getPackageJsonScope,
35536
+ setPackageJsonScope: setPackageJsonScope,
35537
+ setOldPackageJsonScopeCache: function (cache) { return oldPackageJsonInfoCache = cache; },
35538
+ };
35384
35539
  function getPackageJsonInfo(packageJsonPath) {
35385
- return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35540
+ return cache === null || cache === void 0 ? void 0 : cache.get(toPath(packageJsonPath));
35386
35541
  }
35387
35542
  function setPackageJsonInfo(packageJsonPath, info) {
35388
- (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info);
35543
+ (cache || (cache = new ts.Map())).set(toPath(packageJsonPath), info);
35389
35544
  }
35390
35545
  function clear() {
35546
+ oldPackageJsonInfoCache = undefined;
35391
35547
  cache = undefined;
35548
+ dirToPackageJsonScope.clear();
35392
35549
  }
35393
35550
  function entries() {
35394
35551
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35395
35552
  return iter ? ts.arrayFrom(iter) : [];
35396
35553
  }
35397
- function getInternalMap() {
35398
- return cache;
35554
+ function clone() {
35555
+ return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
35556
+ }
35557
+ function getPackageJsonScope(dir) {
35558
+ return dirToPackageJsonScope.get(dir) || (oldPackageJsonInfoCache === null || oldPackageJsonInfoCache === void 0 ? void 0 : oldPackageJsonInfoCache.getPackageJsonScope(dir));
35559
+ }
35560
+ function setPackageJsonScope(dir, scope) {
35561
+ moduleNameToDirectorySet(dirToPackageJsonScope, dir, scope, getPackageJsconLocationFromScope, toPath, ts.noop);
35562
+ }
35563
+ function toPath(file) {
35564
+ return ts.toPath(file, currentDirectory, getCanonicalFileName);
35399
35565
  }
35400
35566
  }
35401
35567
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
@@ -35407,45 +35573,43 @@ var ts;
35407
35573
  }
35408
35574
  return result;
35409
35575
  }
35410
- function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35411
- if (!options.configFile)
35412
- return;
35413
- if (directoryToModuleNameMap.redirectsMap.size === 0) {
35414
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35415
- ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35416
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35417
- directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35418
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35419
- }
35420
- else {
35421
- ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35422
- var ref = {
35423
- sourceFile: options.configFile,
35424
- commandLine: { options: options }
35425
- };
35426
- directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35427
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35428
- }
35429
- directoryToModuleNameMap.setOwnOptions(options);
35430
- moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35431
- }
35432
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35576
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
35577
+ var directoryToModuleNameMap = createCacheWithRedirects(options);
35578
+ var oldResolutionCache;
35433
35579
  return {
35580
+ getFromCache: getFromCache,
35434
35581
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
35435
35582
  clear: clear,
35436
35583
  update: update,
35584
+ setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
35437
35585
  };
35438
35586
  function clear() {
35587
+ oldResolutionCache = undefined;
35439
35588
  directoryToModuleNameMap.clear();
35440
35589
  }
35441
35590
  function update(options) {
35442
- updateRedirectsMap(options, directoryToModuleNameMap);
35591
+ directoryToModuleNameMap.update(options);
35443
35592
  }
35444
35593
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35445
35594
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35446
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
35595
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
35596
+ }
35597
+ function getFromCache(directoryName, name, mode, redirectedReference) {
35598
+ var _a, _b;
35599
+ var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35600
+ 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);
35601
+ if (result)
35602
+ return result;
35603
+ var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
35604
+ if (resultFromOld)
35605
+ getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
35606
+ return resultFromOld;
35447
35607
  }
35448
35608
  }
35609
+ function getModeAwareCacheKey(specifier, mode) {
35610
+ return (mode === undefined ? specifier : mode + "|" + specifier);
35611
+ }
35612
+ ts.getModeAwareCacheKey = getModeAwareCacheKey;
35449
35613
  function createModeAwareCache() {
35450
35614
  var underlying = new ts.Map();
35451
35615
  var memoizedReverseKeys = new ts.Map();
@@ -35470,13 +35634,22 @@ var ts;
35470
35634
  return cb(elem, specifier, mode);
35471
35635
  });
35472
35636
  },
35637
+ entries: function () {
35638
+ var keys = underlying.entries();
35639
+ return {
35640
+ next: function () {
35641
+ var next = keys.next();
35642
+ return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
35643
+ },
35644
+ };
35645
+ },
35473
35646
  size: function () {
35474
35647
  return underlying.size;
35475
- }
35648
+ },
35476
35649
  };
35477
35650
  return cache;
35478
35651
  function getUnderlyingCacheKey(specifier, mode) {
35479
- var result = mode === undefined ? specifier : mode + "|" + specifier;
35652
+ var result = getModeAwareCacheKey(specifier, mode);
35480
35653
  memoizedReverseKeys.set(result, [specifier, mode]);
35481
35654
  return result;
35482
35655
  }
@@ -35487,100 +35660,122 @@ var ts;
35487
35660
  var map = createModeAwareCache();
35488
35661
  for (var i = 0; i < keys.length; ++i) {
35489
35662
  var entry = keys[i];
35490
- var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
35663
+ var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
35491
35664
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
35492
35665
  map.set(name, mode, values[i]);
35493
35666
  }
35494
35667
  return map;
35495
35668
  }
35496
35669
  ts.zipToModeAwareCache = zipToModeAwareCache;
35497
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35498
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35499
- moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35670
+ function getCommonPrefix(directory, resolution, toPath) {
35671
+ var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
35672
+ var i = 0;
35673
+ var limit = Math.min(directory.length, resolutionDirectory.length);
35674
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35675
+ i++;
35676
+ }
35677
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35678
+ return directory;
35679
+ }
35680
+ var rootLength = ts.getRootLength(directory);
35681
+ if (i < rootLength) {
35682
+ return undefined;
35683
+ }
35684
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35685
+ if (sep === -1) {
35686
+ return undefined;
35687
+ }
35688
+ return directory.substr(0, Math.max(sep, rootLength));
35689
+ }
35690
+ function getResolvedFileNameForModuleNameToDirectorySet(result) {
35691
+ return result.resolvedModule &&
35692
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35693
+ }
35694
+ ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
35695
+ function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
35696
+ if (directoryPathMap.has(directory))
35697
+ return;
35698
+ directoryPathMap.set(directory, result);
35699
+ var resolvedFileName = getResolvedFileName(result);
35700
+ var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
35701
+ var current = directory;
35702
+ while (current !== commonPrefix) {
35703
+ var parent = ts.getDirectoryPath(current);
35704
+ if (parent === current)
35705
+ break;
35706
+ if (directoryPathMap.has(parent)) {
35707
+ ancestoryWorker(parent);
35708
+ break;
35709
+ }
35710
+ directoryPathMap.set(parent, result);
35711
+ ancestoryWorker(parent);
35712
+ current = parent;
35713
+ }
35714
+ }
35715
+ ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
35716
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35717
+ var moduleNameToDirectoryMap = createCacheWithRedirects(options);
35718
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35500
35719
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35501
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35720
+ var oldResolutionCache;
35721
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
35502
35722
  function clear() {
35503
- clearAllExceptPackageJsonInfoCache();
35504
- packageJsonInfoCache.clear();
35505
- }
35506
- function clearAllExceptPackageJsonInfoCache() {
35723
+ oldResolutionCache = undefined;
35507
35724
  perDirectoryResolutionCache.clear();
35508
35725
  moduleNameToDirectoryMap.clear();
35726
+ packageJsonInfoCache.clear();
35509
35727
  }
35510
35728
  function update(options) {
35511
- updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35729
+ perDirectoryResolutionCache.update(options);
35730
+ moduleNameToDirectoryMap.update(options);
35731
+ }
35732
+ function setOldResolutionCache(cache) {
35733
+ oldResolutionCache = cache;
35734
+ perDirectoryResolutionCache.setOldResolutionCache(cache);
35735
+ }
35736
+ function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
35737
+ var _a, _b;
35738
+ ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35739
+ 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);
35740
+ if (result)
35741
+ return result;
35742
+ var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
35743
+ if (fromOld)
35744
+ getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
35745
+ return fromOld;
35512
35746
  }
35513
35747
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35514
35748
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35515
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
35749
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35516
35750
  }
35517
35751
  function createPerModuleNameCache() {
35518
35752
  var directoryPathMap = new ts.Map();
35519
35753
  return { get: get, set: set };
35520
35754
  function get(directory) {
35521
- return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
35755
+ return directoryPathMap.get(toPath(directory));
35522
35756
  }
35523
35757
  function set(directory, result) {
35524
- var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
35525
- if (directoryPathMap.has(path)) {
35526
- return;
35527
- }
35528
- directoryPathMap.set(path, result);
35529
- var resolvedFileName = result.resolvedModule &&
35530
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35531
- var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35532
- var current = path;
35533
- while (current !== commonPrefix) {
35534
- var parent = ts.getDirectoryPath(current);
35535
- if (parent === current || directoryPathMap.has(parent)) {
35536
- break;
35537
- }
35538
- directoryPathMap.set(parent, result);
35539
- current = parent;
35540
- }
35541
- }
35542
- function getCommonPrefix(directory, resolution) {
35543
- var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
35544
- var i = 0;
35545
- var limit = Math.min(directory.length, resolutionDirectory.length);
35546
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35547
- i++;
35548
- }
35549
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35550
- return directory;
35551
- }
35552
- var rootLength = ts.getRootLength(directory);
35553
- if (i < rootLength) {
35554
- return undefined;
35555
- }
35556
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35557
- if (sep === -1) {
35558
- return undefined;
35559
- }
35560
- return directory.substr(0, Math.max(sep, rootLength));
35758
+ return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
35561
35759
  }
35562
35760
  }
35761
+ function toPath(fileName) {
35762
+ return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
35763
+ }
35563
35764
  }
35564
35765
  ts.createModuleResolutionCache = createModuleResolutionCache;
35565
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35566
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35766
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35767
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35567
35768
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35568
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35769
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear });
35569
35770
  function clear() {
35570
- clearAllExceptPackageJsonInfoCache();
35571
- packageJsonInfoCache.clear();
35572
- }
35573
- function clearAllExceptPackageJsonInfoCache() {
35574
35771
  perDirectoryResolutionCache.clear();
35772
+ packageJsonInfoCache.clear();
35575
35773
  }
35576
35774
  }
35577
35775
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35578
35776
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35579
35777
  var containingDirectory = ts.getDirectoryPath(containingFile);
35580
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35581
- if (!perFolderCache)
35582
- return undefined;
35583
- return perFolderCache.get(moduleName, mode);
35778
+ return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
35584
35779
  }
35585
35780
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
35586
35781
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -35595,8 +35790,7 @@ var ts;
35595
35790
  }
35596
35791
  }
35597
35792
  var containingDirectory = ts.getDirectoryPath(containingFile);
35598
- var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35599
- var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35793
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
35600
35794
  if (result) {
35601
35795
  if (traceEnabled) {
35602
35796
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -35648,8 +35842,8 @@ var ts;
35648
35842
  if (result && result.resolvedModule)
35649
35843
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
35650
35844
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
35651
- if (perFolderCache) {
35652
- perFolderCache.set(moduleName, resolutionMode, result);
35845
+ if (cache) {
35846
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35653
35847
  if (!ts.isExternalModuleNameRelative(moduleName)) {
35654
35848
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35655
35849
  }
@@ -35853,10 +36047,10 @@ var ts;
35853
36047
  features: features,
35854
36048
  conditions: conditions,
35855
36049
  requestContainingDirectory: containingDirectory,
35856
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
36050
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35857
36051
  };
35858
36052
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
35859
- 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);
36053
+ 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);
35860
36054
  function tryResolve(extensions) {
35861
36055
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
35862
36056
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -36192,21 +36386,42 @@ var ts;
36192
36386
  features: NodeResolutionFeatures.None,
36193
36387
  conditions: ts.emptyArray,
36194
36388
  requestContainingDirectory: undefined,
36195
- reportDiagnostic: ts.noop
36389
+ reportResolutionDiagnostic: ts.noop
36196
36390
  };
36197
36391
  }
36198
36392
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
36199
- function getPackageScopeForPath(fileName, state) {
36200
- var parts = ts.getPathComponents(fileName);
36201
- parts.pop();
36202
- while (parts.length > 0) {
36203
- var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), false, state);
36204
- if (pkg) {
36205
- return pkg;
36206
- }
36207
- parts.pop();
36208
- }
36209
- return undefined;
36393
+ function getPackageScope(dir, packageJsonInfoCache, host, options) {
36394
+ var state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
36395
+ var failedLookupLocations = [];
36396
+ var affectingLocations = [];
36397
+ state.failedLookupLocations = failedLookupLocations;
36398
+ state.affectingLocations = affectingLocations;
36399
+ var result = ts.forEachAncestorDirectory(dir, function (directory) {
36400
+ var _a;
36401
+ var fromCache = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonScope(directory);
36402
+ if (fromCache) {
36403
+ var host_2 = state.host, traceEnabled = state.traceEnabled;
36404
+ if (traceEnabled) {
36405
+ trace(host_2, fromCache.info ?
36406
+ ts.Diagnostics.Directory_0_resolves_to_1_scope_according_to_cache :
36407
+ ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_according_to_cache, directory, getPackageJsconLocationFromScope(fromCache));
36408
+ }
36409
+ return fromCache;
36410
+ }
36411
+ var info = getPackageJsonInfo(directory, false, state);
36412
+ if (info)
36413
+ return { info: info };
36414
+ }) || { info: undefined };
36415
+ result.failedLookupLocations = updateResolutionField(result.failedLookupLocations, !options.cacheResolutions || !result.info ? failedLookupLocations : undefined);
36416
+ result.affectingLocations = updateResolutionField(result.affectingLocations, affectingLocations);
36417
+ packageJsonInfoCache === null || packageJsonInfoCache === void 0 ? void 0 : packageJsonInfoCache.setPackageJsonScope(dir, result);
36418
+ return result;
36419
+ }
36420
+ ts.getPackageScope = getPackageScope;
36421
+ function getPackageScopeForPath(dir, state) {
36422
+ return ts.forEachAncestorDirectory(dir, function (directory) {
36423
+ return getPackageJsonInfo(directory, false, state);
36424
+ });
36210
36425
  }
36211
36426
  ts.getPackageScopeForPath = getPackageScopeForPath;
36212
36427
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
@@ -36234,12 +36449,13 @@ var ts;
36234
36449
  }
36235
36450
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
36236
36451
  if (directoryExists && host.fileExists(packageJsonPath)) {
36237
- var packageJsonContent = ts.readJson(packageJsonPath, host);
36452
+ var packageJsonText = host.readFile(packageJsonPath);
36453
+ var packageJsonContent = ts.readJson(packageJsonPath, packageJsonText);
36238
36454
  if (traceEnabled) {
36239
36455
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
36240
36456
  }
36241
36457
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
36242
- var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36458
+ var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36243
36459
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
36244
36460
  state.affectingLocations.push(packageJsonPath);
36245
36461
  return result;
@@ -36352,7 +36568,7 @@ var ts;
36352
36568
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
36353
36569
  var _a, _b;
36354
36570
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36355
- 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));
36571
+ 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));
36356
36572
  var scope = getPackageScopeForPath(directoryPath, state);
36357
36573
  if (!scope || !scope.packageJsonContent.exports) {
36358
36574
  return undefined;
@@ -36411,7 +36627,7 @@ var ts;
36411
36627
  return toSearchResult(undefined);
36412
36628
  }
36413
36629
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36414
- 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));
36630
+ 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));
36415
36631
  var scope = getPackageScopeForPath(directoryPath, state);
36416
36632
  if (!scope) {
36417
36633
  if (state.traceEnabled) {
@@ -36611,11 +36827,8 @@ var ts;
36611
36827
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
36612
36828
  }
36613
36829
  }
36614
- if (commonSourceDirGuesses.length > 1) {
36615
- state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
36616
- ? 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
36617
- : 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));
36618
- }
36830
+ if (commonSourceDirGuesses.length > 1)
36831
+ state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
36619
36832
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
36620
36833
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
36621
36834
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -36680,10 +36893,10 @@ var ts;
36680
36893
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
36681
36894
  }
36682
36895
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
36683
- var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
36896
+ var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
36684
36897
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
36685
36898
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
36686
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
36899
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36687
36900
  if (resolutionFromCache) {
36688
36901
  return resolutionFromCache;
36689
36902
  }
@@ -36820,8 +37033,8 @@ var ts;
36820
37033
  typesPackageName;
36821
37034
  }
36822
37035
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
36823
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36824
- var result = cache && cache.get(containingDirectory);
37036
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
37037
+ var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
36825
37038
  if (result) {
36826
37039
  if (state.traceEnabled) {
36827
37040
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36846,19 +37059,18 @@ var ts;
36846
37059
  features: NodeResolutionFeatures.None,
36847
37060
  conditions: [],
36848
37061
  requestContainingDirectory: containingDirectory,
36849
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37062
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36850
37063
  };
36851
37064
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
36852
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37065
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36853
37066
  function tryResolve(extensions) {
36854
37067
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
36855
37068
  if (resolvedUsingSettings) {
36856
37069
  return { value: resolvedUsingSettings };
36857
37070
  }
36858
37071
  if (!ts.isExternalModuleNameRelative(moduleName)) {
36859
- var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, undefined, redirectedReference);
36860
37072
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
36861
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
37073
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, undefined, directory, redirectedReference, state);
36862
37074
  if (resolutionFromCache) {
36863
37075
  return resolutionFromCache;
36864
37076
  }
@@ -36897,10 +37109,10 @@ var ts;
36897
37109
  features: NodeResolutionFeatures.None,
36898
37110
  conditions: [],
36899
37111
  requestContainingDirectory: undefined,
36900
- reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37112
+ reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36901
37113
  };
36902
37114
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
36903
- return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37115
+ return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36904
37116
  }
36905
37117
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
36906
37118
  function toSearchResult(value) {
@@ -39913,9 +40125,10 @@ var ts;
39913
40125
  host.getSourceFiles().forEach(function (sf) {
39914
40126
  if (!sf.resolvedModules)
39915
40127
  return;
39916
- sf.resolvedModules.forEach(function (r) {
39917
- if (r && r.packageId)
39918
- map.set(r.packageId.name, r.extension === ".d.ts" || !!map.get(r.packageId.name));
40128
+ sf.resolvedModules.forEach(function (_a) {
40129
+ var resolvedModule = _a.resolvedModule;
40130
+ if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
40131
+ map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" || !!map.get(resolvedModule.packageId.name));
39919
40132
  });
39920
40133
  });
39921
40134
  return map;
@@ -42510,7 +42723,7 @@ var ts;
42510
42723
  : undefined;
42511
42724
  }
42512
42725
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
42513
- var _a, _b, _c, _d, _e, _f, _g, _h;
42726
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
42514
42727
  if (isForAugmentation === void 0) { isForAugmentation = false; }
42515
42728
  if (ts.startsWith(moduleReference, "@types/")) {
42516
42729
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -42556,7 +42769,7 @@ var ts;
42556
42769
  var diagnosticDetails = void 0;
42557
42770
  var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
42558
42771
  if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") {
42559
- var scope = currentSourceFile.packageJsonScope;
42772
+ var scope = (_h = currentSourceFile.packageJsonScope) === null || _h === void 0 ? void 0 : _h.info;
42560
42773
  var targetExt = ext === ".ts" ? ".mts" : ext === ".js" ? ".mjs" : undefined;
42561
42774
  if (scope && !scope.packageJsonContent.type) {
42562
42775
  if (targetExt) {
@@ -42640,10 +42853,10 @@ var ts;
42640
42853
  }
42641
42854
  else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
42642
42855
  var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
42643
- var suggestedExt = (_h = suggestedExtensions.find(function (_a) {
42856
+ var suggestedExt = (_j = suggestedExtensions.find(function (_a) {
42644
42857
  var actualExt = _a[0], _importExt = _a[1];
42645
42858
  return host.fileExists(absoluteRef_1 + actualExt);
42646
- })) === null || _h === void 0 ? void 0 : _h[1];
42859
+ })) === null || _j === void 0 ? void 0 : _j[1];
42647
42860
  if (suggestedExt) {
42648
42861
  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);
42649
42862
  }
@@ -72992,12 +73205,12 @@ var ts;
72992
73205
  var parent = node.parent;
72993
73206
  var paramTag = node.parent.parent;
72994
73207
  if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
72995
- var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
73208
+ var host_3 = ts.getHostSignatureFromJSDoc(paramTag);
72996
73209
  var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent);
72997
- if (host_2 || isCallbackTag) {
73210
+ if (host_3 || isCallbackTag) {
72998
73211
  var lastParamDeclaration = isCallbackTag
72999
73212
  ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters)
73000
- : ts.lastOrUndefined(host_2.parameters);
73213
+ : ts.lastOrUndefined(host_3.parameters);
73001
73214
  var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
73002
73215
  if (!lastParamDeclaration ||
73003
73216
  symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -74232,11 +74445,12 @@ var ts;
74232
74445
  var fileToDirective;
74233
74446
  if (resolvedTypeReferenceDirectives) {
74234
74447
  fileToDirective = new ts.Map();
74235
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
74236
- if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
74448
+ resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
74449
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
74450
+ if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
74237
74451
  return;
74238
74452
  }
74239
- var file = host.getSourceFile(resolvedDirective.resolvedFileName);
74453
+ var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
74240
74454
  if (file) {
74241
74455
  addReferencedFilesToTypeDirective(file, key, mode);
74242
74456
  }
@@ -75513,9 +75727,9 @@ var ts;
75513
75727
  }
75514
75728
  var parent = ts.walkUpParenthesizedTypes(node.parent);
75515
75729
  if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
75516
- var host_3 = ts.getJSDocHost(parent);
75517
- if (host_3) {
75518
- parent = ts.getSingleVariableOfVariableStatement(host_3) || host_3;
75730
+ var host_4 = ts.getJSDocHost(parent);
75731
+ if (host_4) {
75732
+ parent = ts.getSingleVariableOfVariableStatement(host_4) || host_4;
75519
75733
  }
75520
75734
  }
75521
75735
  switch (parent.kind) {
@@ -92035,7 +92249,7 @@ var ts;
92035
92249
  var sourceMap = sourceMapGenerator.toString();
92036
92250
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
92037
92251
  if (printer.bundleFileInfo)
92038
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
92252
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
92039
92253
  }
92040
92254
  }
92041
92255
  else {
@@ -92044,7 +92258,7 @@ var ts;
92044
92258
  var text = writer.getText();
92045
92259
  ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
92046
92260
  if (printer.bundleFileInfo)
92047
- printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
92261
+ printer.bundleFileInfo.hash = ts.computeSignature(text, host);
92048
92262
  writer.clear();
92049
92263
  }
92050
92264
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92179,7 +92393,6 @@ var ts;
92179
92393
  }
92180
92394
  ts.emitUsingBuildInfo = emitUsingBuildInfo;
92181
92395
  function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransformers) {
92182
- var createHash = ts.maybeBind(host, host.createHash);
92183
92396
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
92184
92397
  var buildInfo = host.getBuildInfo(buildInfoPath, config.options);
92185
92398
  if (!buildInfo)
@@ -92189,22 +92402,22 @@ var ts;
92189
92402
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
92190
92403
  if (!jsFileText)
92191
92404
  return jsFilePath;
92192
- if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92405
+ if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
92193
92406
  return jsFilePath;
92194
92407
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92195
92408
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
92196
92409
  return sourceMapFilePath || "inline sourcemap decoding";
92197
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92410
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
92198
92411
  return sourceMapFilePath;
92199
92412
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
92200
92413
  if (declarationFilePath && !declarationText)
92201
92414
  return declarationFilePath;
92202
- if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92415
+ if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
92203
92416
  return declarationFilePath;
92204
92417
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92205
92418
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
92206
92419
  return declarationMapPath || "inline sourcemap decoding";
92207
- if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92420
+ if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
92208
92421
  return declarationMapPath;
92209
92422
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92210
92423
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
@@ -92242,7 +92455,7 @@ var ts;
92242
92455
  var newBuildInfo = data.buildInfo;
92243
92456
  newBuildInfo.program = buildInfo.program;
92244
92457
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
92245
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
92458
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
92246
92459
  }
92247
92460
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
92248
92461
  newBuildInfo.bundle.js.sources = js.sources;
@@ -92276,7 +92489,7 @@ var ts;
92276
92489
  getSourceFileFromReference: ts.returnUndefined,
92277
92490
  redirectTargetsMap: ts.createMultiMap(),
92278
92491
  getFileIncludeReasons: ts.notImplemented,
92279
- createHash: createHash,
92492
+ createHash: ts.maybeBind(host, host.createHash),
92280
92493
  buildInfoCallbacks: host.buildInfoCallbacks,
92281
92494
  };
92282
92495
  emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
@@ -97280,7 +97493,7 @@ var ts;
97280
97493
  var name = names_2[_i];
97281
97494
  var result = void 0;
97282
97495
  var mode = getModeForFileReference(name, containingFileMode);
97283
- var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
97496
+ var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
97284
97497
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
97285
97498
  if (cache.has(cacheKey)) {
97286
97499
  result = cache.get(cacheKey);
@@ -97364,7 +97577,21 @@ var ts;
97364
97577
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97365
97578
  }
97366
97579
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
97367
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
97580
+ var emptyResolution = {
97581
+ resolvedModule: undefined,
97582
+ resolvedTypeReferenceDirective: undefined,
97583
+ failedLookupLocations: [],
97584
+ affectingLocations: [],
97585
+ resolutionDiagnostics: [],
97586
+ };
97587
+ function isResolvedModuleWithFailedLookupLocation(resolved) {
97588
+ return !!resolved && !!resolved.failedLookupLocations;
97589
+ }
97590
+ function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
97591
+ return !!resolved && !!resolved.failedLookupLocations;
97592
+ }
97593
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
97594
+ var _a;
97368
97595
  if (names.length === 0) {
97369
97596
  return [];
97370
97597
  }
@@ -97374,7 +97601,7 @@ var ts;
97374
97601
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
97375
97602
  var name = names_3[_i];
97376
97603
  var result = void 0;
97377
- var mode = getModeForResolutionAtIndex(containingFile, i);
97604
+ var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
97378
97605
  i++;
97379
97606
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
97380
97607
  if (cache.has(cacheKey)) {
@@ -97432,14 +97659,14 @@ var ts;
97432
97659
  ts.isReferenceFileLocation = isReferenceFileLocation;
97433
97660
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97434
97661
  var _a, _b, _c;
97435
- var _d, _e, _f, _g;
97662
+ var _d, _e, _f, _g, _h, _j;
97436
97663
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
97437
97664
  var kind = ref.kind, index = ref.index;
97438
97665
  var pos, end, packageId, resolutionMode;
97439
97666
  switch (kind) {
97440
97667
  case ts.FileIncludeKind.Import:
97441
97668
  var importLiteral = getModuleNameStringLiteralAt(file, index);
97442
- 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;
97669
+ 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;
97443
97670
  if (importLiteral.pos === -1)
97444
97671
  return { file: file, packageId: packageId, text: importLiteral.text };
97445
97672
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -97450,7 +97677,7 @@ var ts;
97450
97677
  break;
97451
97678
  case ts.FileIncludeKind.TypeReferenceDirective:
97452
97679
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
97453
- 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;
97680
+ 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;
97454
97681
  break;
97455
97682
  case ts.FileIncludeKind.LibReferenceDirective:
97456
97683
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -97534,13 +97761,13 @@ var ts;
97534
97761
  return undefined;
97535
97762
  }
97536
97763
  function lookupFromPackageJson() {
97537
- var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
97538
- var packageJsonLocations = [];
97539
- state.failedLookupLocations = packageJsonLocations;
97540
- state.affectingLocations = packageJsonLocations;
97541
- var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
97542
- var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97543
- return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
97764
+ var _a;
97765
+ var packageJsonScope = ts.getPackageScope(ts.getDirectoryPath(fileName), packageJsonInfoCache, host, options);
97766
+ var impliedNodeFormat = ((_a = packageJsonScope.info) === null || _a === void 0 ? void 0 : _a.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97767
+ return {
97768
+ impliedNodeFormat: impliedNodeFormat,
97769
+ packageJsonScope: packageJsonScope,
97770
+ };
97544
97771
  }
97545
97772
  }
97546
97773
  ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
@@ -97652,10 +97879,10 @@ var ts;
97652
97879
  };
97653
97880
  }
97654
97881
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97655
- var _a, _b, _c, _d;
97882
+ var _a, _b, _c, _d, _e;
97656
97883
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97657
97884
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
97658
- var oldProgram = createProgramOptions.oldProgram;
97885
+ var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
97659
97886
  var processingDefaultLibFiles;
97660
97887
  var processingOtherFiles;
97661
97888
  var files;
@@ -97669,6 +97896,8 @@ var ts;
97669
97896
  var cachedDeclarationDiagnosticsForFile = {};
97670
97897
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
97671
97898
  var fileProcessingDiagnostics;
97899
+ var automaticTypeDirectiveNames;
97900
+ var automaticTypeDirectiveResolutions;
97672
97901
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97673
97902
  var currentNodeModulesDepth = 0;
97674
97903
  var modulesWithElidedImports = new ts.Map();
@@ -97691,29 +97920,72 @@ var ts;
97691
97920
  var actualResolveModuleNamesWorker;
97692
97921
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
97693
97922
  if (host.resolveModuleNames) {
97694
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
97695
- if (!resolved || resolved.extension !== undefined) {
97696
- return resolved;
97697
- }
97698
- var withExtension = ts.clone(resolved);
97699
- withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
97700
- return withExtension;
97701
- }); };
97923
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97924
+ var _a;
97925
+ 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) {
97926
+ var name = _a.name;
97927
+ return name;
97928
+ }), redirectedReference, options, containingFile, partialResolutionInfo);
97929
+ return result.some(isResolvedModuleWithFailedLookupLocation) ?
97930
+ result :
97931
+ result.map(function (resolved) { return resolved ?
97932
+ resolved.extension !== undefined ?
97933
+ { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97934
+ { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
97935
+ emptyResolution; });
97936
+ };
97702
97937
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
97703
97938
  }
97704
97939
  else {
97705
97940
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
97706
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
97707
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
97941
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
97942
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97943
+ return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
97944
+ };
97708
97945
  }
97709
97946
  var actualResolveTypeReferenceDirectiveNamesWorker;
97710
97947
  if (host.resolveTypeReferenceDirectives) {
97711
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
97948
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
97949
+ var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
97950
+ return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
97951
+ result :
97952
+ result.map(function (resolved) { return resolved ?
97953
+ { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97954
+ emptyResolution; });
97955
+ };
97956
+ typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
97712
97957
  }
97713
97958
  else {
97714
97959
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97715
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
97716
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
97960
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
97961
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
97962
+ return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
97963
+ };
97964
+ }
97965
+ var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
97966
+ var oldBuildInfoProgram;
97967
+ if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
97968
+ var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
97969
+ oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
97970
+ fileExists: function (fileName) { return host.fileExists(fileName); },
97971
+ createHash: ts.maybeBind(host, host.createHash),
97972
+ getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), false, state_11); },
97973
+ });
97974
+ if (oldBuildInfoProgram) {
97975
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
97976
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97977
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
97978
+ }
97979
+ });
97980
+ typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
97981
+ getResolved: function (dirPath, name, mode, redirectedReference) {
97982
+ return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
97983
+ }
97984
+ });
97985
+ moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache().setOldPackageJsonScopeCache({
97986
+ getPackageJsonScope: function (dirPath) { return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getPackageJsonScope(dirPath); }
97987
+ });
97988
+ }
97717
97989
  }
97718
97990
  var packageIdToSourceFile = new ts.Map();
97719
97991
  var sourceFileToPackageName = new ts.Map();
@@ -97726,9 +97998,9 @@ var ts;
97726
97998
  var projectReferenceRedirects;
97727
97999
  var mapFromFileToProjectReferenceRedirects;
97728
98000
  var mapFromToProjectReferenceRedirectSource;
97729
- var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
98001
+ var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
97730
98002
  !options.disableSourceOfProjectReferenceRedirect;
97731
- var _e = updateHostForUseSourceOfProjectReferenceRedirect({
98003
+ var _f = updateHostForUseSourceOfProjectReferenceRedirect({
97732
98004
  compilerHost: host,
97733
98005
  getSymlinkCache: getSymlinkCache,
97734
98006
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -97736,7 +98008,7 @@ var ts;
97736
98008
  getResolvedProjectReferences: getResolvedProjectReferences,
97737
98009
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
97738
98010
  forEachResolvedProjectReference: forEachResolvedProjectReference
97739
- }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
98011
+ }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
97740
98012
  var readFile = host.readFile.bind(host);
97741
98013
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97742
98014
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -97745,7 +98017,7 @@ var ts;
97745
98017
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
97746
98018
  structureIsReused = tryReuseStructureFromOldProgram();
97747
98019
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97748
- if (structureIsReused !== 2) {
98020
+ if (structureIsReused !== 3) {
97749
98021
  processingDefaultLibFiles = [];
97750
98022
  processingOtherFiles = [];
97751
98023
  if (projectReferences) {
@@ -97785,14 +98057,14 @@ var ts;
97785
98057
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
97786
98058
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
97787
98059
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97788
- var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
97789
- if (typeReferences.length) {
97790
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
97791
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97792
- var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97793
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
97794
- for (var i = 0; i < typeReferences.length; i++) {
97795
- 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 });
98060
+ automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
98061
+ automaticTypeDirectiveResolutions = ts.createModeAwareCache();
98062
+ if (automaticTypeDirectiveNames.length) {
98063
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: automaticTypeDirectiveNames.length });
98064
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
98065
+ for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
98066
+ automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], undefined, resolutions[i]);
98067
+ 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 });
97796
98068
  }
97797
98069
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97798
98070
  }
@@ -97823,13 +98095,13 @@ var ts;
97823
98095
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
97824
98096
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
97825
98097
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
97826
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
98098
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
97827
98099
  }
97828
98100
  }
97829
98101
  if (!host.getParsedCommandLine) {
97830
98102
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
97831
98103
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
97832
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
98104
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
97833
98105
  }
97834
98106
  });
97835
98107
  }
@@ -97845,6 +98117,8 @@ var ts;
97845
98117
  }
97846
98118
  typeReferenceDirectiveResolutionCache = undefined;
97847
98119
  oldProgram = undefined;
98120
+ oldBuildInfoProgram = undefined;
98121
+ oldProgramOrOldBuildInfoProgramConstructor = undefined;
97848
98122
  var program = {
97849
98123
  getRootFileNames: function () { return rootNames; },
97850
98124
  getSourceFile: getSourceFile,
@@ -97852,6 +98126,7 @@ var ts;
97852
98126
  getSourceFiles: function () { return files; },
97853
98127
  getMissingFilePaths: function () { return missingFilePaths; },
97854
98128
  getModuleResolutionCache: function () { return moduleResolutionCache; },
98129
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
97855
98130
  getFilesByNameMap: function () { return filesByName; },
97856
98131
  getCompilerOptions: function () { return options; },
97857
98132
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -97876,6 +98151,9 @@ var ts;
97876
98151
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
97877
98152
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
97878
98153
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
98154
+ getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
98155
+ getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
98156
+ getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
97879
98157
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
97880
98158
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
97881
98159
  getSourceFileFromReference: getSourceFileFromReference,
@@ -97885,12 +98163,12 @@ var ts;
97885
98163
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
97886
98164
  isEmittedFile: isEmittedFile,
97887
98165
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
97888
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
97889
98166
  getProjectReferences: getProjectReferences,
97890
98167
  getResolvedProjectReferences: getResolvedProjectReferences,
97891
98168
  getProjectReferenceRedirect: getProjectReferenceRedirect,
97892
98169
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
97893
98170
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
98171
+ getRedirectReferenceForResolution: getRedirectReferenceForResolution,
97894
98172
  forEachResolvedProjectReference: forEachResolvedProjectReference,
97895
98173
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
97896
98174
  emitBuildInfo: emitBuildInfo,
@@ -97898,7 +98176,7 @@ var ts;
97898
98176
  readFile: readFile,
97899
98177
  directoryExists: directoryExists,
97900
98178
  getSymlinkCache: getSymlinkCache,
97901
- realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
98179
+ realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
97902
98180
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
97903
98181
  getFileIncludeReasons: function () { return fileReasons; },
97904
98182
  structureIsReused: structureIsReused,
@@ -97912,6 +98190,8 @@ var ts;
97912
98190
  case 0:
97913
98191
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
97914
98192
  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)));
98193
+ case 2:
98194
+ return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
97915
98195
  default:
97916
98196
  ts.Debug.assertNever(diagnostic);
97917
98197
  }
@@ -97921,57 +98201,44 @@ var ts;
97921
98201
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
97922
98202
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97923
98203
  return program;
97924
- function addResolutionDiagnostics(list) {
97925
- if (!list)
97926
- return;
97927
- for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
97928
- var elem = list_3[_i];
97929
- programDiagnostics.add(elem);
97930
- }
98204
+ function getAutomaticTypeDirectiveContainingFile() {
98205
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
98206
+ return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97931
98207
  }
97932
- function pullDiagnosticsFromCache(names, containingFile) {
97933
- var _a;
97934
- if (!moduleResolutionCache)
98208
+ function addResolutionDiagnostics(resolution) {
98209
+ if (!resolution.resolutionDiagnostics)
97935
98210
  return;
97936
- var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97937
- var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97938
- var containingDir = ts.getDirectoryPath(containingFileName);
97939
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
97940
- var i = 0;
97941
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
97942
- var n = names_4[_i];
97943
- var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
97944
- var name = typeof n === "string" ? n : n.fileName;
97945
- i++;
97946
- if (ts.isExternalModuleNameRelative(name))
97947
- continue;
97948
- var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
97949
- addResolutionDiagnostics(diags);
97950
- }
98211
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
98212
+ kind: 2,
98213
+ diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
98214
+ ? 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
98215
+ : 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); })
98216
+ });
97951
98217
  }
97952
- function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
98218
+ function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
97953
98219
  if (!moduleNames.length)
97954
98220
  return ts.emptyArray;
97955
98221
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97956
- var redirectedReference = getRedirectReferenceForResolution(containingFile);
98222
+ if (redirectedReference === undefined)
98223
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97957
98224
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
97958
98225
  ts.performance.mark("beforeResolveModule");
97959
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
98226
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
97960
98227
  ts.performance.mark("afterResolveModule");
97961
98228
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
97962
98229
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97963
- pullDiagnosticsFromCache(moduleNames, containingFile);
97964
98230
  return result;
97965
98231
  }
97966
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
98232
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
97967
98233
  if (!typeDirectiveNames.length)
97968
98234
  return [];
97969
98235
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
97970
- var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
98236
+ if (redirectedReference === undefined && !ts.isString(containingFile))
98237
+ redirectedReference = getRedirectReferenceForResolution(containingFile);
97971
98238
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97972
98239
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
97973
98240
  ts.performance.mark("beforeResolveTypeReference");
97974
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
98241
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
97975
98242
  ts.performance.mark("afterResolveTypeReference");
97976
98243
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
97977
98244
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -98017,9 +98284,6 @@ var ts;
98017
98284
  }
98018
98285
  return ts.libs.length + 2;
98019
98286
  }
98020
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
98021
- return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
98022
- }
98023
98287
  function toPath(fileName) {
98024
98288
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
98025
98289
  }
@@ -98043,8 +98307,9 @@ var ts;
98043
98307
  return classifiableNames;
98044
98308
  }
98045
98309
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98310
+ var _a;
98046
98311
  if (structureIsReused === 0 && !file.ambientModuleNames.length) {
98047
- return resolveModuleNamesWorker(moduleNames, file, undefined);
98312
+ return resolveModuleNamesWorker(moduleNames, file, undefined, undefined);
98048
98313
  }
98049
98314
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
98050
98315
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -98059,21 +98324,34 @@ var ts;
98059
98324
  return result_14;
98060
98325
  }
98061
98326
  var unknownModuleNames;
98062
- var result;
98327
+ var unknownModuleNamesIndex;
98063
98328
  var reusedNames;
98064
- var predictedToResolveToAmbientModuleMarker = {};
98329
+ var result;
98330
+ var predictedToResolveToAmbientModuleMarker = true;
98331
+ var redirectedReference;
98065
98332
  for (var i = 0; i < moduleNames.length; i++) {
98066
98333
  var moduleName = moduleNames[i];
98067
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98068
- var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
98069
- if (oldResolvedModule) {
98334
+ if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98335
+ var mode = getModeForResolutionAtIndex(file, i);
98336
+ var oldResolution = !oldBuildInfoProgram ?
98337
+ (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
98338
+ oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
98339
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
98070
98340
  if (ts.isTraceEnabled(options, host)) {
98071
- ts.trace(host, oldResolvedModule.packageId ?
98072
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98073
- 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));
98341
+ var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
98342
+ if (!oldBuildInfoProgram) {
98343
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98344
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98345
+ 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));
98346
+ }
98347
+ else {
98348
+ ts.trace(host, oldResolution.resolvedModule.packageId ?
98349
+ 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 :
98350
+ 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));
98351
+ }
98074
98352
  }
98075
- (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
98076
- (reusedNames || (reusedNames = [])).push(moduleName);
98353
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
98354
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
98077
98355
  continue;
98078
98356
  }
98079
98357
  }
@@ -98088,14 +98366,15 @@ var ts;
98088
98366
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
98089
98367
  }
98090
98368
  if (resolvesToAmbientModuleInNonModifiedFile) {
98091
- (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98369
+ (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98092
98370
  }
98093
98371
  else {
98094
- (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
98372
+ (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
98373
+ (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
98095
98374
  }
98096
98375
  }
98097
98376
  var resolutions = unknownModuleNames && unknownModuleNames.length
98098
- ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
98377
+ ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
98099
98378
  : ts.emptyArray;
98100
98379
  if (!result) {
98101
98380
  ts.Debug.assert(resolutions.length === moduleNames.length);
@@ -98105,7 +98384,7 @@ var ts;
98105
98384
  for (var i = 0; i < result.length; i++) {
98106
98385
  if (result[i]) {
98107
98386
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
98108
- result[i] = undefined;
98387
+ result[i] = emptyResolution;
98109
98388
  }
98110
98389
  }
98111
98390
  else {
@@ -98133,6 +98412,78 @@ var ts;
98133
98412
  return true;
98134
98413
  }
98135
98414
  }
98415
+ function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98416
+ var _a;
98417
+ if (structureIsReused === 0) {
98418
+ return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, undefined, undefined);
98419
+ }
98420
+ var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
98421
+ var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
98422
+ var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
98423
+ if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
98424
+ var result_15 = [];
98425
+ for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
98426
+ var typeDirectiveName = _b[_i];
98427
+ var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
98428
+ result_15.push(resolvedTypeReferenceDirective);
98429
+ }
98430
+ return result_15;
98431
+ }
98432
+ var unknownTypeReferenceDirectiveNames;
98433
+ var unknownTypeReferenceDirectiveNamesIndex;
98434
+ var result;
98435
+ var reusedNames;
98436
+ var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
98437
+ containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
98438
+ !hasInvalidatedResolution(toPath(inferredTypeFile)));
98439
+ var redirectedReference;
98440
+ for (var i = 0; i < typeDirectiveNames.length; i++) {
98441
+ var entry = typeDirectiveNames[i];
98442
+ if (canReuseResolutions) {
98443
+ var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
98444
+ var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
98445
+ var oldResolution = !oldBuildInfoProgram ?
98446
+ (_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) :
98447
+ oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
98448
+ if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98449
+ if (ts.isTraceEnabled(options, host)) {
98450
+ var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
98451
+ if (!oldBuildInfoProgram) {
98452
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98453
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98454
+ 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));
98455
+ }
98456
+ else {
98457
+ ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98458
+ 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 :
98459
+ 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));
98460
+ }
98461
+ }
98462
+ (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
98463
+ (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
98464
+ continue;
98465
+ }
98466
+ }
98467
+ (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
98468
+ (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
98469
+ }
98470
+ if (!unknownTypeReferenceDirectiveNames)
98471
+ return result || ts.emptyArray;
98472
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
98473
+ if (!result) {
98474
+ ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
98475
+ return resolutions;
98476
+ }
98477
+ var j = 0;
98478
+ for (var i = 0; i < result.length; i++) {
98479
+ if (!result[i]) {
98480
+ result[i] = resolutions[j];
98481
+ j++;
98482
+ }
98483
+ }
98484
+ ts.Debug.assert(j === resolutions.length);
98485
+ return result;
98486
+ }
98136
98487
  function canReuseProjectReferences() {
98137
98488
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
98138
98489
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -98151,12 +98502,17 @@ var ts;
98151
98502
  });
98152
98503
  }
98153
98504
  function tryReuseStructureFromOldProgram() {
98154
- var _a, _b;
98155
- if (!oldProgram) {
98505
+ var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
98506
+ if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
98156
98507
  return 0;
98157
98508
  }
98158
- var oldOptions = oldProgram.getCompilerOptions();
98159
- if (ts.changesAffectModuleResolution(oldOptions, options)) {
98509
+ var result = tryReuseStructureFromOldProgramWorker();
98510
+ return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 ?
98511
+ 1 :
98512
+ result;
98513
+ }
98514
+ function tryReuseStructureFromOldProgramWorker() {
98515
+ if (!oldProgram) {
98160
98516
  return 0;
98161
98517
  }
98162
98518
  var oldRootNames = oldProgram.getRootFileNames();
@@ -98171,7 +98527,7 @@ var ts;
98171
98527
  }
98172
98528
  var newSourceFiles = [];
98173
98529
  var modifiedSourceFiles = [];
98174
- structureIsReused = 2;
98530
+ structureIsReused = 3;
98175
98531
  if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
98176
98532
  return 0;
98177
98533
  }
@@ -98179,14 +98535,13 @@ var ts;
98179
98535
  var seenPackageNames = new ts.Map();
98180
98536
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
98181
98537
  var oldSourceFile = oldSourceFiles_2[_i];
98182
- var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
98538
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
98183
98539
  var newSourceFile = host.getSourceFileByPath
98184
98540
  ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
98185
98541
  : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat);
98186
98542
  if (!newSourceFile) {
98187
98543
  return 0;
98188
98544
  }
98189
- newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
98190
98545
  newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
98191
98546
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
98192
98547
  var fileChanged = void 0;
@@ -98221,86 +98576,95 @@ var ts;
98221
98576
  }
98222
98577
  if (fileChanged) {
98223
98578
  if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
98224
- structureIsReused = 1;
98579
+ structureIsReused = 2;
98225
98580
  }
98226
98581
  else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
98227
- structureIsReused = 1;
98582
+ structureIsReused = 2;
98228
98583
  }
98229
98584
  else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
98230
- structureIsReused = 1;
98585
+ structureIsReused = 2;
98231
98586
  }
98232
98587
  else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
98233
- structureIsReused = 1;
98588
+ structureIsReused = 2;
98234
98589
  }
98235
98590
  else {
98236
98591
  collectExternalModuleReferences(newSourceFile);
98237
98592
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98238
- structureIsReused = 1;
98593
+ structureIsReused = 2;
98239
98594
  }
98240
98595
  else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98241
- structureIsReused = 1;
98596
+ structureIsReused = 2;
98242
98597
  }
98243
98598
  else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98244
- structureIsReused = 1;
98599
+ structureIsReused = 2;
98245
98600
  }
98246
98601
  else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
98247
- structureIsReused = 1;
98602
+ structureIsReused = 2;
98248
98603
  }
98249
98604
  }
98250
98605
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98251
98606
  }
98252
98607
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
98253
- structureIsReused = 1;
98608
+ structureIsReused = 2;
98254
98609
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98255
98610
  }
98256
98611
  newSourceFiles.push(newSourceFile);
98257
98612
  }
98258
- if (structureIsReused !== 2) {
98613
+ if (structureIsReused !== 3) {
98259
98614
  return structureIsReused;
98260
98615
  }
98261
98616
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98262
- for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
98263
- var oldFile = oldSourceFiles_3[_c];
98617
+ for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
98618
+ var oldFile = oldSourceFiles_3[_a];
98264
98619
  if (!ts.contains(modifiedFiles, oldFile)) {
98265
- for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
98266
- var moduleName = _e[_d];
98620
+ for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
98621
+ var moduleName = _c[_b];
98267
98622
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98268
98623
  }
98269
98624
  }
98270
98625
  }
98271
- for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
98272
- var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
98626
+ for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
98627
+ var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
98273
98628
  var moduleNames = getModuleNames(newSourceFile);
98274
98629
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98275
98630
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
98276
98631
  if (resolutionsChanged) {
98277
- structureIsReused = 1;
98632
+ structureIsReused = 2;
98278
98633
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98279
98634
  }
98280
98635
  else {
98281
98636
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98282
98637
  }
98283
98638
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98284
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
98639
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98285
98640
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
98286
98641
  if (typeReferenceResolutionsChanged) {
98287
- structureIsReused = 1;
98642
+ structureIsReused = 2;
98288
98643
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98289
98644
  }
98290
98645
  else {
98291
98646
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98292
98647
  }
98293
98648
  }
98294
- if (structureIsReused !== 2) {
98649
+ if (structureIsReused !== 3) {
98295
98650
  return structureIsReused;
98296
98651
  }
98297
- if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
98298
- return 1;
98652
+ if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
98653
+ return 2;
98654
+ }
98655
+ if (host.hasChangedAutomaticTypeDirectiveNames) {
98656
+ if (host.hasChangedAutomaticTypeDirectiveNames())
98657
+ return 2;
98658
+ }
98659
+ else {
98660
+ automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
98661
+ if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98662
+ return 2;
98299
98663
  }
98300
98664
  missingFilePaths = oldProgram.getMissingFilePaths();
98301
98665
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98302
- for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
98303
- var newSourceFile = newSourceFiles_1[_h];
98666
+ for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
98667
+ var newSourceFile = newSourceFiles_1[_f];
98304
98668
  filesByName.set(newSourceFile.path, newSourceFile);
98305
98669
  }
98306
98670
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98321,10 +98685,12 @@ var ts;
98321
98685
  fileReasons = oldProgram.getFileIncludeReasons();
98322
98686
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98323
98687
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98688
+ automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98689
+ automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98324
98690
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98325
98691
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98326
98692
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
98327
- return 2;
98693
+ return 3;
98328
98694
  }
98329
98695
  function getEmitHost(writeFileCallback) {
98330
98696
  return {
@@ -99002,14 +99368,12 @@ var ts;
99002
99368
  }
99003
99369
  }
99004
99370
  function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
99005
- var _a;
99006
99371
  var redirect = Object.create(redirectTarget);
99007
99372
  redirect.fileName = fileName;
99008
99373
  redirect.path = path;
99009
99374
  redirect.resolvedPath = resolvedPath;
99010
99375
  redirect.originalFileName = originalFileName;
99011
99376
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
99012
- redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
99013
99377
  redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
99014
99378
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
99015
99379
  Object.defineProperties(redirect, {
@@ -99034,7 +99398,7 @@ var ts;
99034
99398
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99035
99399
  return result;
99036
99400
  }
99037
- function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
99401
+ function getCreateSourceFileOptions(fileName) {
99038
99402
  var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
99039
99403
  var languageVersion = ts.getEmitScriptTarget(options);
99040
99404
  var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
@@ -99042,7 +99406,7 @@ var ts;
99042
99406
  { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
99043
99407
  }
99044
99408
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
99045
- var _a, _b;
99409
+ var _a;
99046
99410
  var path = toPath(fileName);
99047
99411
  if (useSourceOfProjectReferenceRedirect) {
99048
99412
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -99112,7 +99476,7 @@ var ts;
99112
99476
  redirectedPath = toPath(redirect);
99113
99477
  }
99114
99478
  }
99115
- var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
99479
+ var sourceFileOptions = getCreateSourceFileOptions(fileName);
99116
99480
  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));
99117
99481
  if (packageId) {
99118
99482
  var packageIdKey = ts.packageIdToString(packageId);
@@ -99138,7 +99502,6 @@ var ts;
99138
99502
  file.path = path;
99139
99503
  file.resolvedPath = toPath(fileName);
99140
99504
  file.originalFileName = originalFileName;
99141
- file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
99142
99505
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
99143
99506
  addFileIncludeReason(file, reason);
99144
99507
  if (host.useCaseSensitiveFileNames()) {
@@ -99255,33 +99618,40 @@ var ts;
99255
99618
  }
99256
99619
  function processTypeReferenceDirectives(file) {
99257
99620
  var typeDirectives = file.typeReferenceDirectives;
99258
- if (!typeDirectives) {
99621
+ if (!typeDirectives.length) {
99622
+ file.resolvedTypeReferenceDirectiveNames = undefined;
99259
99623
  return;
99260
99624
  }
99261
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
99625
+ var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
99262
99626
  for (var index = 0; index < typeDirectives.length; index++) {
99263
99627
  var ref = file.typeReferenceDirectives[index];
99264
99628
  var resolvedTypeReferenceDirective = resolutions[index];
99265
99629
  var fileName = ts.toFileNameLowerCase(ref.fileName);
99266
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
99630
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99267
99631
  var mode = ref.resolutionMode || file.impliedNodeFormat;
99268
99632
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
99269
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99633
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99634
+ kind: 2,
99635
+ diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
99636
+ });
99270
99637
  }
99271
99638
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
99272
99639
  }
99273
99640
  }
99274
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99275
- 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 });
99276
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99641
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99642
+ 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 });
99643
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99277
99644
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99278
99645
  }
99279
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99280
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99646
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99647
+ var _a;
99648
+ addResolutionDiagnostics(resolution);
99649
+ var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
99281
99650
  if (previousResolution && previousResolution.primary) {
99282
99651
  return;
99283
99652
  }
99284
99653
  var saveResolution = true;
99654
+ var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
99285
99655
  if (resolvedTypeReferenceDirective) {
99286
99656
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99287
99657
  currentNodeModulesDepth++;
@@ -99310,7 +99680,7 @@ var ts;
99310
99680
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99311
99681
  }
99312
99682
  if (saveResolution) {
99313
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99683
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99314
99684
  }
99315
99685
  }
99316
99686
  function pathForLibFile(libFileName) {
@@ -99339,7 +99709,7 @@ var ts;
99339
99709
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
99340
99710
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
99341
99711
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
99342
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99712
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99343
99713
  kind: 0,
99344
99714
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
99345
99715
  diagnostic: diagnostic,
@@ -99362,19 +99732,20 @@ var ts;
99362
99732
  for (var index = 0; index < moduleNames.length; index++) {
99363
99733
  var resolution = resolutions[index];
99364
99734
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
99365
- if (!resolution) {
99735
+ addResolutionDiagnostics(resolution);
99736
+ if (!resolution.resolvedModule) {
99366
99737
  continue;
99367
99738
  }
99368
- var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
99369
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
99739
+ var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
99740
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
99370
99741
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
99371
- var resolvedFileName = resolution.resolvedFileName;
99742
+ var resolvedFileName = resolution.resolvedModule.resolvedFileName;
99372
99743
  if (isFromNodeModulesSearch) {
99373
99744
  currentNodeModulesDepth++;
99374
99745
  }
99375
99746
  var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
99376
99747
  var shouldAddFile = resolvedFileName
99377
- && !getResolutionDiagnostic(optionsForFile, resolution)
99748
+ && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
99378
99749
  && !optionsForFile.noResolve
99379
99750
  && index < file.imports.length
99380
99751
  && !elideImport
@@ -99384,7 +99755,7 @@ var ts;
99384
99755
  modulesWithElidedImports.set(file.path, true);
99385
99756
  }
99386
99757
  else if (shouldAddFile) {
99387
- findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
99758
+ findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
99388
99759
  }
99389
99760
  if (isFromNodeModulesSearch) {
99390
99761
  currentNodeModulesDepth--;
@@ -99485,6 +99856,9 @@ var ts;
99485
99856
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
99486
99857
  }
99487
99858
  }
99859
+ if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
99860
+ createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
99861
+ }
99488
99862
  var outputFile = ts.outFile(options);
99489
99863
  if (options.tsBuildInfoFile) {
99490
99864
  if (!ts.isIncrementalCompilation(options)) {
@@ -99734,7 +100108,7 @@ var ts;
99734
100108
  }
99735
100109
  }
99736
100110
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
99737
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
100111
+ (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99738
100112
  kind: 1,
99739
100113
  file: file && file.path,
99740
100114
  fileProcessingReason: fileProcessingReason,
@@ -99995,8 +100369,8 @@ var ts;
99995
100369
  if (!symlinks) {
99996
100370
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
99997
100371
  }
99998
- if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
99999
- symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100372
+ if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100373
+ symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
100000
100374
  }
100001
100375
  return symlinks;
100002
100376
  }
@@ -100355,7 +100729,8 @@ var ts;
100355
100729
  }
100356
100730
  }
100357
100731
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100358
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
100732
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
100733
+ var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
100359
100734
  if (!resolvedTypeReferenceDirective) {
100360
100735
  return;
100361
100736
  }
@@ -100404,12 +100779,13 @@ var ts;
100404
100779
  return oldState && !oldState.referencedMap === !newReferencedMap;
100405
100780
  }
100406
100781
  BuilderState.canReuseOldState = canReuseOldState;
100407
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100782
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100408
100783
  var _a, _b, _c;
100409
100784
  var fileInfos = new ts.Map();
100410
100785
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
100411
100786
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
100412
100787
  var useOldState = canReuseOldState(referencedMap, oldState);
100788
+ var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100413
100789
  newProgram.getTypeChecker();
100414
100790
  for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
100415
100791
  var sourceFile = _d[_i];
@@ -100453,23 +100829,23 @@ var ts;
100453
100829
  state.allFileNames = undefined;
100454
100830
  }
100455
100831
  BuilderState.releaseCache = releaseCache;
100456
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100832
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100457
100833
  var _a, _b;
100458
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
100834
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
100459
100835
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
100460
100836
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
100461
100837
  return result;
100462
100838
  }
100463
100839
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
100464
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100840
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100465
100841
  var sourceFile = programOfThisState.getSourceFileByPath(path);
100466
100842
  if (!sourceFile) {
100467
100843
  return ts.emptyArray;
100468
100844
  }
100469
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100845
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100470
100846
  return [sourceFile];
100471
100847
  }
100472
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100848
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100473
100849
  }
100474
100850
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100475
100851
  function updateSignatureOfFile(state, signature, path) {
@@ -100477,7 +100853,7 @@ var ts;
100477
100853
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
100478
100854
  }
100479
100855
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
100480
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
100856
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
100481
100857
  var _a;
100482
100858
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
100483
100859
  if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
@@ -100488,7 +100864,7 @@ var ts;
100488
100864
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
100489
100865
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
100490
100866
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
100491
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
100867
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
100492
100868
  if (latestSignature !== prevSignature) {
100493
100869
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100494
100870
  }
@@ -100622,7 +100998,7 @@ var ts;
100622
100998
  }
100623
100999
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100624
101000
  }
100625
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
101001
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100626
101002
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100627
101003
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100628
101004
  }
@@ -100638,7 +101014,7 @@ var ts;
100638
101014
  if (!seenFileNamesMap.has(currentPath)) {
100639
101015
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100640
101016
  seenFileNamesMap.set(currentPath, currentSourceFile);
100641
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
101017
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100642
101018
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
100643
101019
  }
100644
101020
  }
@@ -100652,9 +101028,9 @@ var ts;
100652
101028
  function hasSameKeys(map1, map2) {
100653
101029
  return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
100654
101030
  }
100655
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
101031
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100656
101032
  var _a, _b;
100657
- var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
101033
+ var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100658
101034
  state.program = newProgram;
100659
101035
  var compilerOptions = newProgram.getCompilerOptions();
100660
101036
  state.compilerOptions = compilerOptions;
@@ -100707,7 +101083,7 @@ var ts;
100707
101083
  return;
100708
101084
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100709
101085
  if (diagnostics) {
100710
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
101086
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100711
101087
  if (!state.semanticDiagnosticsFromOldState) {
100712
101088
  state.semanticDiagnosticsFromOldState = new ts.Set();
100713
101089
  }
@@ -100729,13 +101105,16 @@ var ts;
100729
101105
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
100730
101106
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
100731
101107
  }
100732
- state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
101108
+ state.buildInfoEmitPending = !useOldState ||
101109
+ state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
101110
+ state.fileInfos.size !== oldState.fileInfos.size;
100733
101111
  return state;
100734
101112
  }
100735
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
101113
+ function convertToDiagnostics(diagnostics, newProgram) {
100736
101114
  if (!diagnostics.length)
100737
101115
  return ts.emptyArray;
100738
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
101116
+ var buildInfoDirectory;
101117
+ var getCanonicalFileName;
100739
101118
  return diagnostics.map(function (diagnostic) {
100740
101119
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
100741
101120
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100751,7 +101130,8 @@ var ts;
100751
101130
  return result;
100752
101131
  });
100753
101132
  function toPath(path) {
100754
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101133
+ buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
101134
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
100755
101135
  }
100756
101136
  }
100757
101137
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -100760,6 +101140,8 @@ var ts;
100760
101140
  }
100761
101141
  function releaseCache(state) {
100762
101142
  ts.BuilderState.releaseCache(state);
101143
+ if (!state.resuableCacheResolutions)
101144
+ getCacheResolutions(state);
100763
101145
  state.program = undefined;
100764
101146
  }
100765
101147
  function backupBuilderProgramEmitState(state) {
@@ -100794,7 +101176,7 @@ var ts;
100794
101176
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100795
101177
  ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100796
101178
  }
100797
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
101179
+ function getNextAffectedFile(state, cancellationToken, host) {
100798
101180
  var _a, _b;
100799
101181
  while (true) {
100800
101182
  var affectedFiles = state.affectedFiles;
@@ -100805,7 +101187,7 @@ var ts;
100805
101187
  var affectedFile = affectedFiles[affectedFilesIndex];
100806
101188
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
100807
101189
  state.affectedFilesIndex = affectedFilesIndex;
100808
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101190
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
100809
101191
  return affectedFile;
100810
101192
  }
100811
101193
  affectedFilesIndex++;
@@ -100826,7 +101208,7 @@ var ts;
100826
101208
  ts.Debug.assert(!state.semanticDiagnosticsPerFile);
100827
101209
  return program;
100828
101210
  }
100829
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
101211
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
100830
101212
  state.currentChangedFilePath = nextKey.value;
100831
101213
  state.affectedFilesIndex = 0;
100832
101214
  if (!state.seenAffectedFiles)
@@ -100869,24 +101251,24 @@ var ts;
100869
101251
  });
100870
101252
  }
100871
101253
  }
100872
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101254
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
100873
101255
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
100874
101256
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
100875
101257
  removeDiagnosticsOfLibraryFiles(state);
100876
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
101258
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
100877
101259
  return;
100878
101260
  }
100879
101261
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
100880
101262
  return;
100881
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101263
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
100882
101264
  }
100883
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
101265
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
100884
101266
  removeSemanticDiagnosticsOf(state, path);
100885
101267
  if (!state.changedFilesSet.has(path)) {
100886
101268
  var program = ts.Debug.checkDefined(state.program);
100887
101269
  var sourceFile = program.getSourceFileByPath(path);
100888
101270
  if (sourceFile) {
100889
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
101271
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
100890
101272
  if (ts.getEmitDeclarations(state.compilerOptions)) {
100891
101273
  addToAffectedFilesPendingEmit(state, path, 0);
100892
101274
  }
@@ -100906,16 +101288,16 @@ var ts;
100906
101288
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
100907
101289
  return newSignature !== oldSignature;
100908
101290
  }
100909
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
101291
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
100910
101292
  var _a;
100911
101293
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
100912
101294
  return false;
100913
101295
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
100914
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
101296
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
100915
101297
  removeDiagnosticsOfLibraryFiles(state);
100916
101298
  return true;
100917
101299
  }
100918
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101300
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
100919
101301
  var _a;
100920
101302
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
100921
101303
  return;
@@ -100929,9 +101311,9 @@ var ts;
100929
101311
  var currentPath = queue.pop();
100930
101312
  if (!seenFileNamesMap.has(currentPath)) {
100931
101313
  seenFileNamesMap.set(currentPath, true);
100932
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101314
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
100933
101315
  return;
100934
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101316
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
100935
101317
  if (isChangedSignature(state, currentPath)) {
100936
101318
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
100937
101319
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -100941,27 +101323,27 @@ var ts;
100941
101323
  }
100942
101324
  var seenFileAndExportsOfFile = new ts.Set();
100943
101325
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100944
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101326
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
100945
101327
  return true;
100946
101328
  var references = state.referencedMap.getKeys(exportedFromPath);
100947
101329
  return references && ts.forEachKey(references, function (filePath) {
100948
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101330
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
100949
101331
  });
100950
101332
  });
100951
101333
  }
100952
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101334
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
100953
101335
  var _a, _b;
100954
101336
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
100955
101337
  return undefined;
100956
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101338
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
100957
101339
  return true;
100958
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101340
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
100959
101341
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
100960
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101342
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
100961
101343
  });
100962
101344
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
100963
101345
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
100964
- handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
101346
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, host);
100965
101347
  });
100966
101348
  return undefined;
100967
101349
  }
@@ -101016,34 +101398,45 @@ var ts;
101016
101398
  return !!ts.outFile(info.options || {});
101017
101399
  }
101018
101400
  ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
101019
- function getProgramBuildInfo(state, getCanonicalFileName) {
101401
+ function getProgramBuildInfo(state, host) {
101020
101402
  var outFilePath = ts.outFile(state.compilerOptions);
101021
- if (outFilePath && !state.compilerOptions.composite)
101403
+ if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
101022
101404
  return;
101023
101405
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
101024
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101406
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101407
+ var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
101408
+ var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
101025
101409
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
101410
+ var fileNames = [];
101411
+ var fileNameToFileId = new ts.Map();
101412
+ var resolutions;
101413
+ var names;
101414
+ var resolutionNameToResolutionNameId;
101415
+ var resolutionEntries;
101416
+ var resolutionEntryToResolutionEntryId;
101417
+ var affectedFilesHash;
101026
101418
  if (outFilePath) {
101027
- var fileNames_1 = [];
101028
- var fileInfos_1 = [];
101029
- state.program.getRootFileNames().forEach(function (f) {
101030
- var sourceFile = state.program.getSourceFile(f);
101031
- if (!sourceFile)
101032
- return;
101033
- fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
101034
- fileInfos_1.push(sourceFile.version);
101035
- });
101036
- var result_15 = {
101037
- fileNames: fileNames_1,
101419
+ var fileInfos_1;
101420
+ if (state.compilerOptions.composite) {
101421
+ state.program.getRootFileNames().forEach(function (f) {
101422
+ var sourceFile = state.program.getSourceFile(f);
101423
+ if (!sourceFile)
101424
+ return;
101425
+ var fileId = toFileId(sourceFile.resolvedPath);
101426
+ (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
101427
+ });
101428
+ }
101429
+ var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
101430
+ var result_16 = {
101431
+ fileNames: fileNames,
101038
101432
  fileInfos: fileInfos_1,
101039
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
101433
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101040
101434
  outSignature: state.outSignature,
101041
101435
  latestChangedDtsFile: latestChangedDtsFile,
101436
+ cacheResolutions: cacheResolutions_1,
101042
101437
  };
101043
- return result_15;
101438
+ return result_16;
101044
101439
  }
101045
- var fileNames = [];
101046
- var fileNameToFileId = new ts.Map();
101047
101440
  var fileIdsList;
101048
101441
  var fileNamesToFileIdListId;
101049
101442
  var emitSignatures;
@@ -101100,7 +101493,7 @@ var ts;
101100
101493
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
101101
101494
  [
101102
101495
  toFileId(key),
101103
- convertToReusableDiagnostics(value, relativeToBuildInfo)
101496
+ value.map(toReusableDiagnostic)
101104
101497
  ] :
101105
101498
  toFileId(key));
101106
101499
  }
@@ -101122,10 +101515,11 @@ var ts;
101122
101515
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
101123
101516
  }
101124
101517
  }
101518
+ var cacheResolutions = toProgramBuildInfoCacheResolutions();
101125
101519
  var result = {
101126
101520
  fileNames: fileNames,
101127
101521
  fileInfos: fileInfos,
101128
- options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
101522
+ options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101129
101523
  fileIdsList: fileIdsList,
101130
101524
  referencedMap: referencedMap,
101131
101525
  exportedModulesMap: exportedModulesMap,
@@ -101134,6 +101528,7 @@ var ts;
101134
101528
  changeFileSet: changeFileSet,
101135
101529
  emitSignatures: emitSignatures,
101136
101530
  latestChangedDtsFile: latestChangedDtsFile,
101531
+ cacheResolutions: cacheResolutions,
101137
101532
  };
101138
101533
  return result;
101139
101534
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -101142,7 +101537,7 @@ var ts;
101142
101537
  function relativeToBuildInfo(path) {
101143
101538
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
101144
101539
  }
101145
- function toFileId(path) {
101540
+ function toFileAndAbsoluteFileId(path) {
101146
101541
  var fileId = fileNameToFileId.get(path);
101147
101542
  if (fileId === undefined) {
101148
101543
  fileNames.push(relativeToBuildInfo(path));
@@ -101150,6 +101545,12 @@ var ts;
101150
101545
  }
101151
101546
  return fileId;
101152
101547
  }
101548
+ function toFileId(path) {
101549
+ return toFileAndAbsoluteFileId(path);
101550
+ }
101551
+ function toAbsoluteFileId(path) {
101552
+ return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
101553
+ }
101153
101554
  function toFileIdListId(set) {
101154
101555
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
101155
101556
  var key = fileIds.join();
@@ -101160,53 +101561,232 @@ var ts;
101160
101561
  }
101161
101562
  return fileIdListId;
101162
101563
  }
101163
- function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
101564
+ function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
101164
101565
  var result;
101165
101566
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
101166
101567
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
101167
101568
  var name = _a[_i];
101168
101569
  var optionInfo = optionsNameMap.get(name.toLowerCase());
101169
- if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
101170
- (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
101570
+ if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
101571
+ (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
101572
+ }
101573
+ else if (affectsModuleResolution && name === "pathsBasePath") {
101574
+ (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
101575
+ continue;
101171
101576
  }
101172
101577
  }
101173
101578
  return result;
101174
101579
  }
101175
- }
101176
- function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
101177
- if (option) {
101178
- if (option.type === "list") {
101179
- var values = value;
101180
- if (option.element.isFilePath && values.length) {
101181
- return values.map(relativeToBuildInfo);
101580
+ function toReusableCompilerOptionValue(option, value) {
101581
+ if (option) {
101582
+ if (option.type === "list") {
101583
+ var values = value;
101584
+ if (option.element.isFilePath && values.length) {
101585
+ return values.map(relativeToBuildInfoEnsuringAbsolutePath);
101586
+ }
101587
+ }
101588
+ else if (option.isFilePath) {
101589
+ return relativeToBuildInfoEnsuringAbsolutePath(value);
101182
101590
  }
101183
101591
  }
101184
- else if (option.isFilePath) {
101185
- return relativeToBuildInfo(value);
101186
- }
101592
+ return value;
101187
101593
  }
101188
- return value;
101189
- }
101190
- function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
101191
- ts.Debug.assert(!!diagnostics.length);
101192
- return diagnostics.map(function (diagnostic) {
101193
- var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
101594
+ function toReadonlyArrayOrUndefined(array, map) {
101595
+ return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
101596
+ }
101597
+ function toReusableDiagnostic(diagnostic) {
101598
+ var result = toReusableDiagnosticRelatedInformation(diagnostic);
101194
101599
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
101195
101600
  result.reportDeprecated = diagnostic.reportsDeprecated;
101196
101601
  result.source = diagnostic.source;
101197
101602
  result.skippedOn = diagnostic.skippedOn;
101198
101603
  var relatedInformation = diagnostic.relatedInformation;
101199
- result.relatedInformation = relatedInformation ?
101200
- relatedInformation.length ?
101201
- relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
101202
- [] :
101203
- undefined;
101604
+ result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
101605
+ return result;
101606
+ }
101607
+ function toReusableDiagnosticRelatedInformation(diagnostic) {
101608
+ var file = diagnostic.file;
101609
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101610
+ }
101611
+ function toProgramBuildInfoCacheResolutions() {
101612
+ var cacheResolutions = getCacheResolutions(state);
101613
+ var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
101614
+ var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
101615
+ var packageJsons = toProgramBuildInfoPackageJsons(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.perDirPackageJsonMap);
101616
+ if (!resolutions)
101617
+ return;
101618
+ ts.Debug.assertIsDefined(names);
101619
+ ts.Debug.assertIsDefined(resolutionEntries);
101620
+ state.resuableCacheResolutions = {
101621
+ cache: {
101622
+ resolutions: resolutions.map(toProgramBuildInfoResolution),
101623
+ names: names,
101624
+ hash: toProgramBuildInfoHashes(),
101625
+ resolutionEntries: resolutionEntries,
101626
+ modules: modules,
101627
+ typeRefs: typeRefs,
101628
+ packageJsons: packageJsons,
101629
+ },
101630
+ getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
101631
+ };
101632
+ return state.resuableCacheResolutions.cache;
101633
+ }
101634
+ function toProgramBuildInfoPackageJsons(cache) {
101635
+ var result;
101636
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (packageJson, dirPath) {
101637
+ var packageJsonDirPath = ts.getDirectoryPath(ts.toPath(packageJson, currentDirectory, getCanonicalFileName));
101638
+ if (packageJsonDirPath !== dirPath) {
101639
+ (result !== null && result !== void 0 ? result : (result = [])).push([
101640
+ toFileId(dirPath),
101641
+ toAbsoluteFileId(packageJson),
101642
+ ]);
101643
+ }
101644
+ });
101645
+ return result;
101646
+ }
101647
+ function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
101648
+ if (!cache)
101649
+ return undefined;
101650
+ var ownMap = cache.getOwnMap();
101651
+ var own = toProgramBuildInfoResolutionCache(ownMap);
101652
+ var redirects;
101653
+ cache.redirectsKeyToCache.forEach(function (_a) {
101654
+ var map = _a.map, options = _a.options;
101655
+ if (map === ownMap)
101656
+ return;
101657
+ var redirectCache = toProgramBuildInfoResolutionCache(map);
101658
+ if (redirectCache) {
101659
+ (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
101660
+ options: toProgramBuildInfoCompilerOptions(options, undefined, true),
101661
+ cache: redirectCache
101662
+ });
101663
+ }
101664
+ });
101665
+ return !redirects ? own : { own: own, redirects: redirects };
101666
+ }
101667
+ function toProgramBuildInfoResolutionCache(cache) {
101668
+ var result;
101669
+ cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
101670
+ (result !== null && result !== void 0 ? result : (result = [])).push([
101671
+ toFileId(dirPath),
101672
+ ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
101673
+ ]) :
101674
+ undefined; });
101204
101675
  return result;
101676
+ }
101677
+ function toProgramBuildInfoResolutionEntryId(_a) {
101678
+ var name = _a[0], mode = _a[1], resolution = _a[2];
101679
+ var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
101680
+ var resolutionId = toProgramBuildInfoResolutionId(resolution);
101681
+ var key = resolutionNameId + "," + mode + "," + resolutionId;
101682
+ var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
101683
+ if (resolutionEntryId === undefined) {
101684
+ (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
101685
+ (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
101686
+ }
101687
+ return resolutionEntryId;
101688
+ }
101689
+ function toProgramBuildInfoResolutionNameId(name) {
101690
+ var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
101691
+ if (resolutionNameId === undefined) {
101692
+ (names !== null && names !== void 0 ? names : (names = [])).push(name);
101693
+ (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
101694
+ }
101695
+ return resolutionNameId;
101696
+ }
101697
+ function toProgramBuildInfoResolutionId(resolution) {
101698
+ if (resolution.serializationIndex === undefined) {
101699
+ (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
101700
+ resolution.serializationIndex = resolutions.length;
101701
+ }
101702
+ return resolution.serializationIndex;
101703
+ }
101704
+ function toProgramBuildInfoResolution(resolution) {
101705
+ resolution.serializationIndex = undefined;
101706
+ return {
101707
+ resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
101708
+ resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
101709
+ affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
101710
+ resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
101711
+ };
101712
+ }
101713
+ function toProgramBuildInfoHashes() {
101714
+ if (!affectedFilesHash)
101715
+ return undefined;
101716
+ var hashes = [];
101717
+ for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
101718
+ var key = _a[_i];
101719
+ var value = affectedFilesHash.get(key);
101720
+ hashes.push(value ? [key, value] : key);
101721
+ }
101722
+ return hashes;
101723
+ }
101724
+ function toAffectedFileId(file) {
101725
+ var _a;
101726
+ var fileId = toAbsoluteFileId(file);
101727
+ if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
101728
+ var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
101729
+ var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101730
+ (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
101731
+ }
101732
+ return fileId;
101733
+ }
101734
+ function toProgramBuildInfoResolved(resolved) {
101735
+ 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;
101736
+ }
101737
+ function toProgramBuildInfoResolutionDiagnostic(d) {
101738
+ return {
101739
+ isImports: d.isImports || undefined,
101740
+ entry: d.entry || undefined,
101741
+ packagePath: toAbsoluteFileId(d.packagePath),
101742
+ };
101743
+ }
101744
+ }
101745
+ function getCacheResolutions(state) {
101746
+ var _a;
101747
+ if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
101748
+ return state.cacheResolutions;
101749
+ var modules;
101750
+ var typeRefs;
101751
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
101752
+ var dirToPackageJsonScope = new ts.Map();
101753
+ var perDirPackageJsonMap;
101754
+ var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101755
+ state.program.getSourceFiles().forEach(function (f) {
101756
+ var _a;
101757
+ modules = toPerDirectoryCache(state, getCanonicalFileName, modules, ts.getResolvedModuleOfResolution, f, f.resolvedModules, moduleNameToDirectoryMap);
101758
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, f, f.resolvedTypeReferenceDirectiveNames);
101759
+ if ((_a = f.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
101760
+ var dirPath = ts.getDirectoryPath(f.resolvedPath);
101761
+ if (!(dirToPackageJsonScope === null || dirToPackageJsonScope === void 0 ? void 0 : dirToPackageJsonScope.has(dirPath))) {
101762
+ (perDirPackageJsonMap !== null && perDirPackageJsonMap !== void 0 ? perDirPackageJsonMap : (perDirPackageJsonMap = new ts.Map())).set(dirPath, ts.getPackageJsconLocationFromScope(f.packageJsonScope));
101763
+ 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); });
101764
+ }
101765
+ }
101205
101766
  });
101767
+ var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
101768
+ if (automaticTypeDirectiveNames.length) {
101769
+ var currentDirectory = state.program.getCurrentDirectory();
101770
+ var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
101771
+ typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
101772
+ }
101773
+ return state.cacheResolutions = {
101774
+ modules: modules,
101775
+ typeRefs: typeRefs,
101776
+ moduleNameToDirectoryMap: moduleNameToDirectoryMap,
101777
+ dirToPackageJsonScope: dirToPackageJsonScope,
101778
+ perDirPackageJsonMap: perDirPackageJsonMap,
101779
+ packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
101780
+ };
101206
101781
  }
101207
- function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
101208
- var file = diagnostic.file;
101209
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101782
+ function toPerDirectoryCache(state, getCanonicalFileName, perDirCache, getResolutionWithResolvedFileName, sourceFileOrPath, fileCacheFromProgram, moduleNameToDirectoryMap) {
101783
+ return ts.toPerDirectoryResolution(state.program, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, ts.noop, function (r, name, mode, _key, redirectedReference, dirPath) {
101784
+ var _a, _b, _c;
101785
+ return !((_a = getResolutionWithResolvedFileName(r)) === null || _a === void 0 ? void 0 : _a.resolvedFileName) ||
101786
+ (moduleNameToDirectoryMap &&
101787
+ !ts.isExternalModuleNameRelative(name) &&
101788
+ ((_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)));
101789
+ }, 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); });
101210
101790
  }
101211
101791
  var BuilderProgramKind;
101212
101792
  (function (BuilderProgramKind) {
@@ -101230,7 +101810,7 @@ var ts;
101230
101810
  rootNames: newProgramOrRootNames,
101231
101811
  options: hostOrOptions,
101232
101812
  host: oldProgramOrHost,
101233
- oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
101813
+ oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
101234
101814
  configFileParsingDiagnostics: configFileParsingDiagnostics,
101235
101815
  projectReferences: projectReferences
101236
101816
  });
@@ -101248,8 +101828,8 @@ var ts;
101248
101828
  function getTextHandlingSourceMapForSignature(text, data) {
101249
101829
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
101250
101830
  }
101251
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
101252
- var _a;
101831
+ function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
101832
+ var _a, _b;
101253
101833
  text = getTextHandlingSourceMapForSignature(text, data);
101254
101834
  var sourceFileDirectory;
101255
101835
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -101257,7 +101837,7 @@ var ts;
101257
101837
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
101258
101838
  }).join("\n");
101259
101839
  }
101260
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
101840
+ return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
101261
101841
  function flattenDiagnosticMessageText(diagnostic) {
101262
101842
  return ts.isString(diagnostic) ?
101263
101843
  diagnostic :
@@ -101276,8 +101856,9 @@ var ts;
101276
101856
  }
101277
101857
  }
101278
101858
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
101279
- function computeSignature(text, computeHash, data) {
101280
- return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101859
+ function computeSignature(text, host, data) {
101860
+ var _a;
101861
+ return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101281
101862
  }
101282
101863
  ts.computeSignature = computeSignature;
101283
101864
  function createBuilderProgram(kind, _a) {
@@ -101288,10 +101869,8 @@ var ts;
101288
101869
  oldState = undefined;
101289
101870
  return oldProgram;
101290
101871
  }
101291
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101292
- var computeHash = ts.maybeBind(host, host.createHash);
101293
- var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101294
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
101872
+ var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101873
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
101295
101874
  newProgram = undefined;
101296
101875
  oldProgram = undefined;
101297
101876
  oldState = undefined;
@@ -101305,6 +101884,7 @@ var ts;
101305
101884
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
101306
101885
  builderProgram.emit = emit;
101307
101886
  builderProgram.releaseProgram = function () { return releaseCache(state); };
101887
+ builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
101308
101888
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
101309
101889
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
101310
101890
  }
@@ -101326,7 +101906,7 @@ var ts;
101326
101906
  return ts.emitSkippedWithNoDiagnostics;
101327
101907
  }
101328
101908
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101329
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101909
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101330
101910
  var emitKind = 1;
101331
101911
  var isPendingEmitFile = false;
101332
101912
  if (!affected) {
@@ -101364,7 +101944,7 @@ var ts;
101364
101944
  var file = sourceFiles[0];
101365
101945
  var info = state.fileInfos.get(file.resolvedPath);
101366
101946
  if (info.signature === file.version) {
101367
- var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
101947
+ var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
101368
101948
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
101369
101949
  emitSignature = signature;
101370
101950
  if (signature !== file.version) {
@@ -101388,7 +101968,7 @@ var ts;
101388
101968
  if (state.compilerOptions.composite) {
101389
101969
  var filePath = sourceFiles[0].resolvedPath;
101390
101970
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
101391
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
101971
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
101392
101972
  if (emitSignature === oldSignature)
101393
101973
  return;
101394
101974
  ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
@@ -101397,7 +101977,7 @@ var ts;
101397
101977
  }
101398
101978
  }
101399
101979
  else if (state.compilerOptions.composite) {
101400
- var newSignature = computeSignature(text, computeHash, data);
101980
+ var newSignature = computeSignature(text, host, data);
101401
101981
  if (newSignature === state.outSignature)
101402
101982
  return;
101403
101983
  state.outSignature = newSignature;
@@ -101458,7 +102038,7 @@ var ts;
101458
102038
  }
101459
102039
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101460
102040
  while (true) {
101461
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
102041
+ var affected = getNextAffectedFile(state, cancellationToken, host);
101462
102042
  if (!affected) {
101463
102043
  return undefined;
101464
102044
  }
@@ -101516,12 +102096,32 @@ var ts;
101516
102096
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
101517
102097
  }
101518
102098
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
101519
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
101520
- var _a, _b, _c, _d;
101521
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101522
- var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101523
- var state;
102099
+ function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
102100
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
101524
102101
  var filePaths;
102102
+ var fileAbsolutePaths;
102103
+ return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
102104
+ function toPath(path) {
102105
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
102106
+ }
102107
+ function toAbsolutePath(path) {
102108
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
102109
+ }
102110
+ function toFilePath(fileId) {
102111
+ var _a;
102112
+ 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]));
102113
+ }
102114
+ function toFileAbsolutePath(fileId) {
102115
+ var _a;
102116
+ 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]));
102117
+ }
102118
+ }
102119
+ ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
102120
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
102121
+ var _a, _b, _c;
102122
+ var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
102123
+ var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
102124
+ var state;
101525
102125
  var filePathsSetList;
101526
102126
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
101527
102127
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -101530,13 +102130,13 @@ var ts;
101530
102130
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
101531
102131
  latestChangedDtsFile: latestChangedDtsFile,
101532
102132
  outSignature: program.outSignature,
102133
+ resuableCacheResolutions: toResuableCacheResolutions(),
101533
102134
  };
101534
102135
  }
101535
102136
  else {
101536
- filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
101537
- filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
102137
+ filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101538
102138
  var fileInfos_2 = new ts.Map();
101539
- var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
102139
+ var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101540
102140
  program.fileInfos.forEach(function (fileInfo, index) {
101541
102141
  var path = toFilePath(index + 1);
101542
102142
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -101544,7 +102144,7 @@ var ts;
101544
102144
  if (emitSignatures_1 && stateFileInfo.signature)
101545
102145
  emitSignatures_1.set(path, stateFileInfo.signature);
101546
102146
  });
101547
- (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
102147
+ (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
101548
102148
  if (ts.isNumber(value))
101549
102149
  emitSignatures_1.delete(toFilePath(value));
101550
102150
  else
@@ -101563,14 +102163,17 @@ var ts;
101563
102163
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
101564
102164
  latestChangedDtsFile: latestChangedDtsFile,
101565
102165
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
102166
+ resuableCacheResolutions: toResuableCacheResolutions(),
101566
102167
  };
101567
102168
  }
102169
+ state.compilerOptions.configFilePath = configFilePath;
101568
102170
  return {
101569
102171
  getState: function () { return state; },
101570
102172
  saveEmitState: ts.noop,
101571
102173
  restoreEmitState: ts.noop,
101572
102174
  getProgram: ts.notImplemented,
101573
102175
  getProgramOrUndefined: ts.returnUndefined,
102176
+ getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
101574
102177
  releaseProgram: ts.noop,
101575
102178
  getCompilerOptions: function () { return state.compilerOptions; },
101576
102179
  getSourceFile: ts.notImplemented,
@@ -101590,15 +102193,6 @@ var ts;
101590
102193
  close: ts.noop,
101591
102194
  hasChangedEmitSignature: ts.returnFalse,
101592
102195
  };
101593
- function toPath(path) {
101594
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101595
- }
101596
- function toAbsolutePath(path) {
101597
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101598
- }
101599
- function toFilePath(fileId) {
101600
- return filePaths[fileId - 1];
101601
- }
101602
102196
  function toFilePathsSet(fileIdsListId) {
101603
102197
  return filePathsSetList[fileIdsListId - 1];
101604
102198
  }
@@ -101613,8 +102207,241 @@ var ts;
101613
102207
  });
101614
102208
  return map;
101615
102209
  }
102210
+ function toResuableCacheResolutions() {
102211
+ return program.cacheResolutions && {
102212
+ cache: program.cacheResolutions,
102213
+ getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
102214
+ };
102215
+ }
101616
102216
  }
101617
102217
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
102218
+ function createGetProgramOrOldBuildInfoProgramUndefined(state) {
102219
+ return function () {
102220
+ var _a;
102221
+ return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
102222
+ (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions, !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
102223
+ undefined);
102224
+ };
102225
+ }
102226
+ function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
102227
+ if (!cacheResolutions && !resuableCacheResolutions)
102228
+ return undefined;
102229
+ var fileExistsMap = new ts.Map();
102230
+ var packageJsonInfoMap = new ts.Map();
102231
+ var affectingLoationsSameMap = new ts.Map();
102232
+ var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
102233
+ var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
102234
+ var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
102235
+ var decodedPackageJsonMap;
102236
+ var packageJsonScopes;
102237
+ var decodedHashes;
102238
+ var resolutions;
102239
+ var originalPathOrResolvedFileNames;
102240
+ var resolutionEntries;
102241
+ return {
102242
+ getCompilerOptions: function () { return compilerOptions; },
102243
+ 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); },
102244
+ 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); },
102245
+ getPackageJsonScope: getPackageJsonScope,
102246
+ };
102247
+ function fileExists(fileName) {
102248
+ var result = fileExistsMap.get(fileName);
102249
+ if (result === undefined)
102250
+ fileExistsMap.set(fileName, result = host.fileExists(fileName));
102251
+ return result;
102252
+ }
102253
+ function getPackageJsonInfo(fileName) {
102254
+ var result = packageJsonInfoMap.get(fileName);
102255
+ if (result === undefined)
102256
+ packageJsonInfoMap.set(fileName, result = host.getPackageJsonInfo(fileName) || false);
102257
+ return result || undefined;
102258
+ }
102259
+ function affectingLocationsSame(fileName, expected) {
102260
+ var _a;
102261
+ var result = affectingLoationsSameMap.get(fileName);
102262
+ if (result !== undefined)
102263
+ return result;
102264
+ var packageJsonInfo = getPackageJsonInfo(fileName);
102265
+ var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
102266
+ if (ts.isString(expected)) {
102267
+ result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
102268
+ }
102269
+ else {
102270
+ var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
102271
+ result = currentText === expectedText;
102272
+ }
102273
+ affectingLoationsSameMap.set(fileName, result);
102274
+ return result;
102275
+ }
102276
+ function getPackageJsonScope(dirPath) {
102277
+ var _a;
102278
+ var fromCache = (_a = cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.dirToPackageJsonScope) === null || _a === void 0 ? void 0 : _a.get(dirPath);
102279
+ if (fromCache) {
102280
+ var packageJson = ts.getPackageJsconLocationFromScope(fromCache);
102281
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(packageJson);
102282
+ if (result === undefined) {
102283
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map())).set(packageJson, result = affectingLocationsSame(packageJson, fromCache.info) ?
102284
+ fromCache :
102285
+ fileExists(packageJson) ?
102286
+ { info: getPackageJsonInfo(packageJson), affectingLocations: [packageJson] } :
102287
+ false);
102288
+ }
102289
+ return result || undefined;
102290
+ }
102291
+ if (!(resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.packageJsons))
102292
+ return;
102293
+ if (!decodedPackageJsonMap) {
102294
+ decodedPackageJsonMap = new ts.Map();
102295
+ var filePathDecoder_1 = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder();
102296
+ for (var _i = 0, _b = resuableCacheResolutions.cache.packageJsons; _i < _b.length; _i++) {
102297
+ var dirIdOrDirAndPackageJson = _b[_i];
102298
+ var dirPath_1 = filePathDecoder_1.toFilePath(dirIdOrDirAndPackageJson[0]);
102299
+ var packageJson = filePathDecoder_1.toFileAbsolutePath(dirIdOrDirAndPackageJson[1]);
102300
+ ts.moduleNameToDirectorySet(decodedPackageJsonMap, dirPath_1, packageJson, ts.identity, function (fileName) { return ts.toPath(fileName, filePathDecoder_1.currentDirectory, filePathDecoder_1.getCanonicalFileName); }, ts.noop);
102301
+ }
102302
+ }
102303
+ return toPackageJsonScope(decodedPackageJsonMap.get(dirPath));
102304
+ }
102305
+ function toPackageJsonScope(file) {
102306
+ if (!file)
102307
+ return undefined;
102308
+ var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(file);
102309
+ if (result !== undefined)
102310
+ return result || undefined;
102311
+ (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map()));
102312
+ if (fileExists(file)) {
102313
+ result = {
102314
+ info: getPackageJsonInfo(file),
102315
+ affectingLocations: [file]
102316
+ };
102317
+ }
102318
+ packageJsonScopes.set(file, result || false);
102319
+ return result;
102320
+ }
102321
+ function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
102322
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
102323
+ 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)) ||
102324
+ ((_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));
102325
+ if (fromCache) {
102326
+ return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
102327
+ 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;
102328
+ }
102329
+ if (!reusableCache)
102330
+ return undefined;
102331
+ if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
102332
+ if (ts.isArray(reusableCache)) {
102333
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache, decodedModuleNameToDirectoryMap);
102334
+ }
102335
+ else {
102336
+ if (reusableCache.own)
102337
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
102338
+ reusableCache.redirects.forEach(function (_a) {
102339
+ var options = _a.options, cache = _a.cache;
102340
+ var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
102341
+ setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
102342
+ });
102343
+ }
102344
+ decodedReusableCache.clearRedirectsMap();
102345
+ decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
102346
+ }
102347
+ 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)) ||
102348
+ ((_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));
102349
+ return resolutionId ? toResolution(resolutionId) : undefined;
102350
+ }
102351
+ function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
102352
+ var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
102353
+ reusableCache.forEach(function (_a) {
102354
+ var dirId = _a[0], entryId = _a[1];
102355
+ var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
102356
+ map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
102357
+ });
102358
+ }
102359
+ function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
102360
+ var modeAwareCache = ts.createModeAwareCache();
102361
+ entries.forEach(function (entryId) {
102362
+ var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
102363
+ modeAwareCache.set(name, mode, resolutionId);
102364
+ if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102365
+ return;
102366
+ var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
102367
+ var key = ts.getModeAwareCacheKey(name, mode);
102368
+ var moduleNameMap = mapForOptions.get(key);
102369
+ ;
102370
+ if (!moduleNameMap)
102371
+ mapForOptions.set(key, moduleNameMap = new ts.Map());
102372
+ ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
102373
+ });
102374
+ return modeAwareCache;
102375
+ }
102376
+ function toResolutionEntry(entryId) {
102377
+ var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
102378
+ if (existing)
102379
+ return existing;
102380
+ resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
102381
+ var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
102382
+ return resolutionEntries[entryId - 1] = [
102383
+ toName(nameId),
102384
+ resolutionId,
102385
+ mode
102386
+ ];
102387
+ }
102388
+ function toName(nameId) {
102389
+ return resuableCacheResolutions.cache.names[nameId - 1];
102390
+ }
102391
+ function toOriginalPathOrResolvedFileName(resolutionId) {
102392
+ var _a;
102393
+ 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 ||
102394
+ resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
102395
+ }
102396
+ function toAffectingFileLocation(fileId) {
102397
+ if (!decodedHashes && resuableCacheResolutions.cache.hash) {
102398
+ decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
102399
+ }
102400
+ var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
102401
+ var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
102402
+ return affectingLocationsSame(file, hash) ? file : undefined;
102403
+ }
102404
+ function toResolution(resolutionId) {
102405
+ var _a, _b;
102406
+ var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
102407
+ if (existing !== undefined)
102408
+ return existing || undefined;
102409
+ resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
102410
+ var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
102411
+ var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
102412
+ var affectingLocations;
102413
+ if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
102414
+ var file = toAffectingFileLocation(fileId);
102415
+ if (file)
102416
+ (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
102417
+ return !!file;
102418
+ })) {
102419
+ var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
102420
+ return resolutions[resolutionId - 1] = {
102421
+ resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
102422
+ resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
102423
+ failedLookupLocations: ts.emptyArray,
102424
+ affectingLocations: affectingLocations,
102425
+ resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
102426
+ };
102427
+ }
102428
+ resolutions[resolutionId - 1] = false;
102429
+ return undefined;
102430
+ }
102431
+ function toResolved(resolved, resolvedFileName, extension) {
102432
+ if (!resolved)
102433
+ return undefined;
102434
+ return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
102435
+ }
102436
+ function toResolutionDiagnostic(d) {
102437
+ return {
102438
+ isImports: !!d.isImports,
102439
+ entry: d.entry || "",
102440
+ packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
102441
+ };
102442
+ }
102443
+ }
102444
+ ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
101618
102445
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
101619
102446
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101620
102447
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -101634,6 +102461,7 @@ var ts;
101634
102461
  restoreEmitState: ts.noop,
101635
102462
  getProgram: getProgram,
101636
102463
  getProgramOrUndefined: function () { return getState().program; },
102464
+ getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
101637
102465
  releaseProgram: function () { return getState().program = undefined; },
101638
102466
  getCompilerOptions: function () { return getState().compilerOptions; },
101639
102467
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -101716,15 +102544,57 @@ var ts;
101716
102544
  return true;
101717
102545
  }
101718
102546
  ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
102547
+ function getResolvedModuleOfResolution(resolution) {
102548
+ return resolution.resolvedModule;
102549
+ }
102550
+ ts.getResolvedModuleOfResolution = getResolvedModuleOfResolution;
102551
+ function getResolvedTypeReferenceDirectiveOfResolution(resolution) {
102552
+ return resolution.resolvedTypeReferenceDirective;
102553
+ }
102554
+ ts.getResolvedTypeReferenceDirectiveOfResolution = getResolvedTypeReferenceDirectiveOfResolution;
102555
+ function toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, onRedirectedReferenceKey, forEachResolution, toPath, ancestoryWorker) {
102556
+ if (!(fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()))
102557
+ return perDirCache;
102558
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102559
+ var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
102560
+ var options = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
102561
+ var key = ts.getRedirectsCacheKey(options);
102562
+ onRedirectedReferenceKey(key);
102563
+ var dirPath = ts.getDirectoryPath(path);
102564
+ var perDirResolutionCache = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
102565
+ var cacheForDir = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
102566
+ fileCacheFromProgram.forEach(function (r, name, mode) {
102567
+ if (forEachResolution(r, name, mode, key, redirectedReference, dirPath))
102568
+ return;
102569
+ if (cacheForDir === null || cacheForDir === void 0 ? void 0 : cacheForDir.has(name, mode))
102570
+ return;
102571
+ if (!cacheForDir) {
102572
+ perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options, key));
102573
+ perDirResolutionCache.set(dirPath, cacheForDir = ts.createModeAwareCache());
102574
+ }
102575
+ cacheForDir.set(name, mode, r);
102576
+ if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102577
+ return;
102578
+ var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options, key);
102579
+ var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
102580
+ var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
102581
+ if (!directoryPathMap)
102582
+ actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
102583
+ ts.moduleNameToDirectorySet(directoryPathMap, dirPath, r, ts.getResolvedFileNameForModuleNameToDirectorySet, toPath, function (ancestorPath) { return ancestoryWorker(ancestorPath, name, mode, perDirResolutionCache); });
102584
+ });
102585
+ return perDirCache;
102586
+ }
102587
+ ts.toPerDirectoryResolution = toPerDirectoryResolution;
101719
102588
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
101720
102589
  var filesWithChangedSetOfUnresolvedImports;
101721
102590
  var filesWithInvalidatedResolutions;
101722
- var filesWithInvalidatedNonRelativeUnresolvedImports;
101723
- var nonRelativeExternalModuleResolutions = ts.createMultiMap();
101724
102591
  var resolutionsWithFailedLookups = [];
101725
102592
  var resolutionsWithOnlyAffectingLocations = [];
101726
102593
  var resolvedFileToResolution = ts.createMultiMap();
101727
- var impliedFormatPackageJsons = new ts.Map();
102594
+ var perFilePackageJsonScope = new ts.Map();
102595
+ var watchedPackageJsonScopes = [];
102596
+ var packageJsonsToCloseWatcherOn;
102597
+ var resolutionsToCloseWatcherOn;
101728
102598
  var hasChangedAutomaticTypeDirectiveNames = false;
101729
102599
  var affectingPathChecksForFile;
101730
102600
  var affectingPathChecks;
@@ -101733,13 +102603,12 @@ var ts;
101733
102603
  var isInDirectoryChecks;
101734
102604
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
101735
102605
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
102606
+ var oldModuleAndTypeRefCache;
102607
+ var oldPackageJsonInfoCache;
101736
102608
  var resolvedModuleNames = new ts.Map();
101737
- var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
101738
- var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
101739
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
102609
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
101740
102610
  var resolvedTypeReferenceDirectives = new ts.Map();
101741
- var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
101742
- var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
102611
+ var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache());
101743
102612
  var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
101744
102613
  var customFailedLookupPaths = new ts.Map();
101745
102614
  var directoryWatchesOfFailedLookups = new ts.Map();
@@ -101749,32 +102618,23 @@ var ts;
101749
102618
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
101750
102619
  var typeRootsWatches = new ts.Map();
101751
102620
  return {
102621
+ resolvedModuleNames: resolvedModuleNames,
102622
+ resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
101752
102623
  getModuleResolutionCache: function () { return moduleResolutionCache; },
102624
+ getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
101753
102625
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
101754
102626
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
101755
102627
  startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
101756
102628
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
101757
102629
  resolveModuleNames: resolveModuleNames,
101758
- getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
101759
102630
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
101760
- removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
101761
- removeResolutionsOfFile: removeResolutionsOfFile,
101762
102631
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
101763
102632
  invalidateResolutionOfFile: invalidateResolutionOfFile,
101764
102633
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
101765
102634
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
101766
102635
  createHasInvalidatedResolution: createHasInvalidatedResolution,
101767
- isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
101768
- updateTypeRootsWatch: updateTypeRootsWatch,
101769
- closeTypeRootsWatch: closeTypeRootsWatch,
101770
102636
  clear: clear
101771
102637
  };
101772
- function getResolvedModule(resolution) {
101773
- return resolution.resolvedModule;
101774
- }
101775
- function getResolvedTypeReferenceDirective(resolution) {
101776
- return resolution.resolvedTypeReferenceDirective;
101777
- }
101778
102638
  function isInDirectoryPath(dir, file) {
101779
102639
  if (dir === undefined || file.length <= dir.length) {
101780
102640
  return false;
@@ -101785,21 +102645,25 @@ var ts;
101785
102645
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
101786
102646
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
101787
102647
  customFailedLookupPaths.clear();
101788
- nonRelativeExternalModuleResolutions.clear();
101789
102648
  closeTypeRootsWatch();
101790
102649
  resolvedModuleNames.clear();
101791
102650
  resolvedTypeReferenceDirectives.clear();
101792
102651
  resolvedFileToResolution.clear();
101793
102652
  resolutionsWithFailedLookups.length = 0;
101794
102653
  resolutionsWithOnlyAffectingLocations.length = 0;
102654
+ watchedPackageJsonScopes.length = 0;
101795
102655
  failedLookupChecks = undefined;
101796
102656
  startsWithPathChecks = undefined;
101797
102657
  isInDirectoryChecks = undefined;
101798
102658
  affectingPathChecks = undefined;
101799
102659
  affectingPathChecksForFile = undefined;
102660
+ resolutionsToCloseWatcherOn = undefined;
102661
+ packageJsonsToCloseWatcherOn = undefined;
102662
+ oldModuleAndTypeRefCache = undefined;
102663
+ oldPackageJsonInfoCache = undefined;
101800
102664
  moduleResolutionCache.clear();
101801
102665
  typeReferenceDirectiveResolutionCache.clear();
101802
- impliedFormatPackageJsons.clear();
102666
+ perFilePackageJsonScope.clear();
101803
102667
  hasChangedAutomaticTypeDirectiveNames = false;
101804
102668
  }
101805
102669
  function startRecordingFilesWithChangedResolutions() {
@@ -101810,13 +102674,6 @@ var ts;
101810
102674
  filesWithChangedSetOfUnresolvedImports = undefined;
101811
102675
  return collected;
101812
102676
  }
101813
- function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
101814
- if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
101815
- return false;
101816
- }
101817
- var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
101818
- return !!value && !!value.length;
101819
- }
101820
102677
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
101821
102678
  invalidateResolutionsOfFailedLookupLocations();
101822
102679
  if (forceAllFilesAsInvalidated) {
@@ -101825,71 +102682,239 @@ var ts;
101825
102682
  }
101826
102683
  var collected = filesWithInvalidatedResolutions;
101827
102684
  filesWithInvalidatedResolutions = undefined;
101828
- return function (path) { return (!!collected && collected.has(path)) ||
101829
- isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
102685
+ return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
101830
102686
  }
101831
102687
  function startCachingPerDirectoryResolution() {
101832
- moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
101833
- typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
101834
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101835
- nonRelativeExternalModuleResolutions.clear();
102688
+ var packageJsonInfoCache = moduleResolutionCache.getPackageJsonInfoCache();
102689
+ var internalCache = packageJsonInfoCache.getInternalMap();
102690
+ moduleResolutionCache.clear();
102691
+ typeReferenceDirectiveResolutionCache.clear();
102692
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
102693
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
102694
+ if (oldModuleAndTypeRefCache) {
102695
+ oldModuleAndTypeRefCache.clearRedirectsMap();
102696
+ moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
102697
+ typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
102698
+ }
102699
+ packageJsonInfoCache.setInternalMap(internalCache);
102700
+ packageJsonInfoCache.setOldPackageJsonScopeCache(oldPackageJsonInfoCache);
101836
102701
  }
101837
102702
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
101838
- filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
101839
- nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101840
- nonRelativeExternalModuleResolutions.clear();
101841
- if (newProgram !== oldProgram) {
101842
- newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
101843
- var _a, _b, _c;
101844
- var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
101845
- var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
101846
- for (var i = existing.length; i < expected; i++) {
101847
- createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false);
101848
- }
101849
- if (existing.length > expected) {
101850
- for (var i = expected; i < existing.length; i++) {
101851
- fileWatchesOfAffectingLocations.get(existing[i]).files--;
101852
- }
102703
+ hasChangedAutomaticTypeDirectiveNames = false;
102704
+ if (!newProgram) {
102705
+ clear();
102706
+ return;
102707
+ }
102708
+ if (newProgram === oldProgram)
102709
+ return;
102710
+ var needsResolutionUpdate = newProgram.structureIsReused !== 3;
102711
+ var modules;
102712
+ var typeRefs;
102713
+ var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
102714
+ var dirToPackageJsonScope = new ts.Map();
102715
+ for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
102716
+ var newFile = _a[_i];
102717
+ if (needsResolutionUpdate) {
102718
+ modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, newFile.resolvedModules, newFile, getResolvedModuleOfResolution, modules, moduleNameToDirectoryMap);
102719
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newFile.resolvedTypeReferenceDirectiveNames, newFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102720
+ }
102721
+ ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope);
102722
+ }
102723
+ if (needsResolutionUpdate) {
102724
+ var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
102725
+ typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102726
+ if (!modules && !typeRefs) {
102727
+ oldModuleAndTypeRefCache = undefined;
102728
+ }
102729
+ else {
102730
+ oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
102731
+ }
102732
+ if (oldProgram) {
102733
+ for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
102734
+ var f = _c[_b];
102735
+ if (!newProgram.getSourceFileByPath(f.path))
102736
+ removeResolutionsOfFile(f.path);
101853
102737
  }
101854
- if (expected)
101855
- impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
101856
- else
101857
- impliedFormatPackageJsons.delete(newFile.path);
101858
- });
101859
- impliedFormatPackageJsons.forEach(function (existing, path) {
101860
- if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
101861
- existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
101862
- impliedFormatPackageJsons.delete(path);
102738
+ var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
102739
+ if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
102740
+ removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
101863
102741
  }
101864
- });
102742
+ }
101865
102743
  }
101866
- directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
101867
- if (watcher.refCount === 0) {
101868
- directoryWatchesOfFailedLookups.delete(path);
101869
- watcher.watcher.close();
102744
+ perFilePackageJsonScope.forEach(function (existing, path) {
102745
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
102746
+ stopWatchingPackageJsonScope(existing, path);
102747
+ perFilePackageJsonScope.delete(path);
101870
102748
  }
101871
102749
  });
102750
+ if (dirToPackageJsonScope.size) {
102751
+ oldPackageJsonInfoCache = getOldPackageJsonInfoCache(dirToPackageJsonScope);
102752
+ }
102753
+ else {
102754
+ oldPackageJsonInfoCache = undefined;
102755
+ }
102756
+ if (needsResolutionUpdate && (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions()))
102757
+ updateTypeRootsWatch();
102758
+ resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
102759
+ resolutionsToCloseWatcherOn = undefined;
102760
+ packageJsonsToCloseWatcherOn === null || packageJsonsToCloseWatcherOn === void 0 ? void 0 : packageJsonsToCloseWatcherOn.forEach(closeWatchersOfPackageJsonScope);
102761
+ packageJsonsToCloseWatcherOn = undefined;
101872
102762
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
101873
102763
  if (watcher.files === 0 && watcher.resolutions === 0) {
101874
102764
  fileWatchesOfAffectingLocations.delete(path);
101875
102765
  watcher.watcher.close();
101876
102766
  }
101877
102767
  });
101878
- hasChangedAutomaticTypeDirectiveNames = false;
101879
102768
  }
101880
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102769
+ function ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope) {
102770
+ var _a;
102771
+ var existing = perFilePackageJsonScope.get(newFile.path);
102772
+ var scope = ts.isExternalOrCommonJsModule(newFile) ? newFile.packageJsonScope : undefined;
102773
+ if (scope) {
102774
+ ((_a = scope.files) !== null && _a !== void 0 ? _a : (scope.files = new ts.Set())).add(newFile.path);
102775
+ watchPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
102776
+ watchPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
102777
+ perFilePackageJsonScope.set(newFile.path, scope);
102778
+ ts.moduleNameToDirectorySet(dirToPackageJsonScope, ts.getDirectoryPath(newFile.resolvedPath), scope, ts.getPackageJsconLocationFromScope, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102779
+ }
102780
+ if (existing && scope !== existing)
102781
+ stopWatchingPackageJsonScope(existing, newFile.path);
102782
+ }
102783
+ function stopWatchingPackageJsonScope(scope, path) {
102784
+ var _a, _b;
102785
+ (_a = scope.files) === null || _a === void 0 ? void 0 : _a.delete(path);
102786
+ if (!((_b = scope.files) === null || _b === void 0 ? void 0 : _b.size))
102787
+ (packageJsonsToCloseWatcherOn !== null && packageJsonsToCloseWatcherOn !== void 0 ? packageJsonsToCloseWatcherOn : (packageJsonsToCloseWatcherOn = [])).push(scope);
102788
+ }
102789
+ function watchPackageJsonScopeLocations(scope, locations, field) {
101881
102790
  var _a, _b;
102791
+ var locationsLength = (_a = locations === null || locations === void 0 ? void 0 : locations.length) !== null && _a !== void 0 ? _a : 0;
102792
+ if (!locationsLength || scope[field] === locationsLength)
102793
+ return;
102794
+ if (!scope.watchedFailed && !scope.watchedAffected)
102795
+ watchedPackageJsonScopes.push(scope);
102796
+ for (var i = (_b = scope[field]) !== null && _b !== void 0 ? _b : 0; i < locationsLength; i++) {
102797
+ createFileWatcherOfAffectingLocation(locations[i], false);
102798
+ }
102799
+ scope[field] = locationsLength;
102800
+ }
102801
+ function closeWatchersOfPackageJsonScope(scope) {
102802
+ var _a;
102803
+ if (((_a = scope.files) === null || _a === void 0 ? void 0 : _a.size) || !scope.files)
102804
+ return;
102805
+ scope.files = undefined;
102806
+ ts.unorderedRemoveItem(watchedPackageJsonScopes, scope);
102807
+ stopWatchingPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
102808
+ stopWatchingPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
102809
+ }
102810
+ function stopWatchingPackageJsonScopeLocations(scope, locations, field) {
102811
+ if (!scope[field])
102812
+ return;
102813
+ for (var i = 0; i < scope[field]; i++) {
102814
+ fileWatchesOfAffectingLocations.get(locations[i]).files--;
102815
+ }
102816
+ scope[field] = undefined;
102817
+ }
102818
+ function getOldPackageJsonInfoCache(dirToPackageJsonScope) {
102819
+ var packageJsons;
102820
+ return {
102821
+ getPackageJsonScope: function (dir) {
102822
+ var _a;
102823
+ var scope = dirToPackageJsonScope.get(dir);
102824
+ if (!scope)
102825
+ return undefined;
102826
+ if (!scope.isInvalidated)
102827
+ return scope;
102828
+ if (!resolutionHost.getCompilationSettings().cacheResolutions || !scope.info)
102829
+ return undefined;
102830
+ var packageJson = ts.getPackageJsconLocationFromScope(scope);
102831
+ var result = packageJsons === null || packageJsons === void 0 ? void 0 : packageJsons.get(packageJson);
102832
+ if (result !== undefined)
102833
+ return result || undefined;
102834
+ if (resolutionHost.fileExists(packageJson)) {
102835
+ result = {
102836
+ 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())),
102837
+ affectingLocations: [packageJson],
102838
+ };
102839
+ }
102840
+ (packageJsons !== null && packageJsons !== void 0 ? packageJsons : (packageJsons = new ts.Map())).set(packageJson, result || false);
102841
+ return result;
102842
+ }
102843
+ };
102844
+ }
102845
+ function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
102846
+ var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102847
+ var resolutionsInFile = perFileCache.get(path);
102848
+ var seenNamesInFile = ts.createModeAwareCache();
102849
+ perDirCache = toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, function (key) {
102850
+ if (resolutionsInFile && resolutionsInFile.key !== key) {
102851
+ resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102852
+ resolutionsInFile = undefined;
102853
+ }
102854
+ }, function (r, name, mode, key) {
102855
+ seenNamesInFile.set(name, mode, true);
102856
+ var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
102857
+ if (existing && r !== existing)
102858
+ stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
102859
+ watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
102860
+ if (!resolutionsInFile)
102861
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
102862
+ resolutionsInFile.cache.set(name, mode, r);
102863
+ }, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102864
+ if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
102865
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102866
+ if (!seenNamesInFile.has(name, mode)) {
102867
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102868
+ resolutionsInFile.cache.delete(name, mode);
102869
+ }
102870
+ });
102871
+ if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
102872
+ perFileCache.delete(path);
102873
+ }
102874
+ return perDirCache;
102875
+ }
102876
+ function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
102877
+ if (!modules && !typeRefs)
102878
+ return undefined;
102879
+ return {
102880
+ modules: {
102881
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
102882
+ },
102883
+ typeRefs: {
102884
+ getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, undefined); }
102885
+ },
102886
+ clearRedirectsMap: function () {
102887
+ modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
102888
+ typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
102889
+ moduleNameToDirectoryMap.clearRedirectsMap();
102890
+ },
102891
+ };
102892
+ }
102893
+ function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
102894
+ var _a, _b, _c, _d;
102895
+ if (!perDirCache)
102896
+ return undefined;
102897
+ 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)) ||
102898
+ ((_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));
102899
+ return result && !result.isInvalidated ? result : undefined;
102900
+ }
102901
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102902
+ var _a;
101882
102903
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
101883
102904
  if (!resolutionHost.getGlobalCache) {
101884
102905
  return primaryResult;
101885
102906
  }
101886
102907
  var globalCache = resolutionHost.getGlobalCache();
101887
102908
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
101888
- 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;
102909
+ 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;
101889
102910
  if (resolvedModule) {
101890
102911
  primaryResult.resolvedModule = resolvedModule;
101891
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
101892
- (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
102912
+ if (!compilerOptions.cacheResolutions)
102913
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
102914
+ else
102915
+ primaryResult.failedLookupLocations.length = 0;
102916
+ primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102917
+ primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
101893
102918
  return primaryResult;
101894
102919
  }
101895
102920
  }
@@ -101899,68 +102924,35 @@ var ts;
101899
102924
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
101900
102925
  }
101901
102926
  function resolveNamesWithLocalCache(_a) {
101902
- var _b, _c, _d;
101903
- 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;
102927
+ var _b, _c, _d, _e;
102928
+ 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;
101904
102929
  var path = resolutionHost.toPath(containingFile);
101905
- var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
101906
- var dirPath = ts.getDirectoryPath(path);
101907
- var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
101908
- var perDirectoryResolution = perDirectoryCache.get(dirPath);
101909
- if (!perDirectoryResolution) {
101910
- perDirectoryResolution = ts.createModeAwareCache();
101911
- perDirectoryCache.set(dirPath, perDirectoryResolution);
102930
+ var resolutionsInFile = perFileCache.get(path);
102931
+ var compilerOptions = resolutionHost.getCompilationSettings();
102932
+ var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
102933
+ if (!resolutionsInFile || resolutionsInFile.key !== key) {
102934
+ resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102935
+ perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
101912
102936
  }
101913
102937
  var resolvedModules = [];
101914
- var compilerOptions = resolutionHost.getCompilationSettings();
101915
- var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
101916
- var program = resolutionHost.getCurrentProgram();
101917
- var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
101918
- var unmatchedRedirects = oldRedirect ?
101919
- !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
101920
- !!redirectedReference;
101921
102938
  var seenNamesInFile = ts.createModeAwareCache();
101922
102939
  var i = 0;
101923
- for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
101924
- var entry = names_5[_i];
101925
- var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
102940
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
102941
+ var entry = names_4[_i];
102942
+ var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
101926
102943
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
101927
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
102944
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
101928
102945
  i++;
101929
- var resolution = resolutionsInFile.get(name, mode);
101930
- if (!seenNamesInFile.has(name, mode) &&
101931
- unmatchedRedirects || !resolution || resolution.isInvalidated ||
101932
- (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
102946
+ var resolution = resolutionsInFile.cache.get(name, mode);
102947
+ if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
101933
102948
  var existingResolution = resolution;
101934
- var resolutionInDirectory = perDirectoryResolution.get(name, mode);
101935
- if (resolutionInDirectory) {
101936
- resolution = resolutionInDirectory;
101937
- var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
101938
- if (ts.isTraceEnabled(compilerOptions, host)) {
101939
- var resolved = getResolutionWithResolvedFileName(resolution);
101940
- ts.trace(host, loader === resolveModuleName ?
101941
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101942
- resolved.packagetId ?
101943
- 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 :
101944
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101945
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
101946
- (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101947
- resolved.packagetId ?
101948
- 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 :
101949
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101950
- 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));
101951
- }
101952
- }
101953
- else {
101954
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
101955
- perDirectoryResolution.set(name, mode, resolution);
101956
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
101957
- resolutionHost.onDiscoveredSymlink();
101958
- }
102949
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102950
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102951
+ resolutionHost.onDiscoveredSymlink();
101959
102952
  }
101960
- resolutionsInFile.set(name, mode, resolution);
101961
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
102953
+ resolutionsInFile.cache.set(name, mode, resolution);
101962
102954
  if (existingResolution) {
101963
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
102955
+ stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
101964
102956
  }
101965
102957
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
101966
102958
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -101973,27 +102965,33 @@ var ts;
101973
102965
  var resolved = getResolutionWithResolvedFileName(resolution);
101974
102966
  ts.trace(host, loader === resolveModuleName ?
101975
102967
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101976
- resolved.packagetId ?
102968
+ resolved.packageId ?
101977
102969
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101978
102970
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101979
102971
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
101980
102972
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101981
- resolved.packagetId ?
102973
+ resolved.packageId ?
101982
102974
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
101983
102975
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
101984
- 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));
102976
+ 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));
101985
102977
  }
101986
102978
  }
101987
102979
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
101988
102980
  seenNamesInFile.set(name, mode, true);
101989
- resolvedModules.push(getResolutionWithResolvedFileName(resolution));
102981
+ resolvedModules.push(resolution);
101990
102982
  }
101991
- resolutionsInFile.forEach(function (resolution, name, mode) {
101992
- if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
101993
- stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
101994
- resolutionsInFile.delete(name, mode);
101995
- }
102983
+ (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
102984
+ var name = _a.name, mode = _a.mode;
102985
+ return seenNamesInFile.set(name, mode, true);
101996
102986
  });
102987
+ if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
102988
+ resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102989
+ if (!seenNamesInFile.has(name, mode)) {
102990
+ stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102991
+ resolutionsInFile.cache.delete(name, mode);
102992
+ }
102993
+ });
102994
+ }
101997
102995
  return resolvedModules;
101998
102996
  function resolutionIsEqualTo(oldResolution, newResolution) {
101999
102997
  if (oldResolution === newResolution) {
@@ -102013,40 +103011,31 @@ var ts;
102013
103011
  return oldResult.resolvedFileName === newResult.resolvedFileName;
102014
103012
  }
102015
103013
  }
102016
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
103014
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
102017
103015
  return resolveNamesWithLocalCache({
102018
103016
  names: typeDirectiveNames,
102019
103017
  containingFile: containingFile,
102020
103018
  redirectedReference: redirectedReference,
102021
- cache: resolvedTypeReferenceDirectives,
102022
- perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
103019
+ perFileCache: resolvedTypeReferenceDirectives,
102023
103020
  loader: resolveTypeReferenceDirective,
102024
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
102025
- shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
102026
- containingSourceFileMode: containingFileMode
103021
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveOfResolution,
103022
+ containingSourceFileMode: containingFileMode,
103023
+ partialResolutionInfo: partialResolutionInfo,
102027
103024
  });
102028
103025
  }
102029
- function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
103026
+ function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
102030
103027
  return resolveNamesWithLocalCache({
102031
103028
  names: moduleNames,
102032
103029
  containingFile: containingFile,
102033
103030
  redirectedReference: redirectedReference,
102034
- cache: resolvedModuleNames,
102035
- perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
103031
+ perFileCache: resolvedModuleNames,
102036
103032
  loader: resolveModuleName,
102037
- getResolutionWithResolvedFileName: getResolvedModule,
102038
- shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
102039
- reusedNames: reusedNames,
103033
+ getResolutionWithResolvedFileName: getResolvedModuleOfResolution,
103034
+ partialResolutionInfo: partialResolutionInfo,
102040
103035
  logChanges: logChangesWhenResolvingModule,
102041
103036
  containingSourceFile: containingSourceFile,
102042
103037
  });
102043
103038
  }
102044
- function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
102045
- var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
102046
- if (!cache)
102047
- return undefined;
102048
- return cache.get(moduleName, resolutionMode);
102049
- }
102050
103039
  function isNodeModulesAtTypesDirectory(dirPath) {
102051
103040
  return ts.endsWith(dirPath, "/node_modules/@types");
102052
103041
  }
@@ -102100,37 +103089,41 @@ var ts;
102100
103089
  function isPathWithDefaultFailedLookupExtension(path) {
102101
103090
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
102102
103091
  }
102103
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
102104
- if (resolution.refCount) {
102105
- resolution.refCount++;
102106
- ts.Debug.assertIsDefined(resolution.files);
103092
+ function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
103093
+ if (resolution.files) {
103094
+ resolution.files.add(filePath);
103095
+ if (resolution.watchedFailed !== false)
103096
+ watchFailedLookupLocationOfResolution(resolution);
103097
+ watchAffectingLocationsOfResolution(resolution);
103098
+ return;
103099
+ }
103100
+ resolution.files = new ts.Set();
103101
+ resolution.files.add(filePath);
103102
+ var resolved = getResolutionWithResolvedFileName(resolution);
103103
+ if (resolved && resolved.resolvedFileName) {
103104
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
103105
+ }
103106
+ if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
103107
+ watchFailedLookupLocationOfResolution(resolution);
103108
+ watchAffectingLocationsOfResolution(resolution);
102107
103109
  }
102108
103110
  else {
102109
- resolution.refCount = 1;
102110
- ts.Debug.assert(ts.length(resolution.files) === 0);
102111
- if (ts.isExternalModuleNameRelative(name)) {
102112
- watchFailedLookupLocationOfResolution(resolution);
102113
- }
102114
- else {
102115
- nonRelativeExternalModuleResolutions.add(name, resolution);
102116
- }
102117
- var resolved = getResolutionWithResolvedFileName(resolution);
102118
- if (resolved && resolved.resolvedFileName) {
102119
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102120
- }
103111
+ resolution.watchedFailed = false;
103112
+ watchAffectingLocationsOfResolution(resolution);
102121
103113
  }
102122
- (resolution.files || (resolution.files = [])).push(filePath);
102123
103114
  }
102124
103115
  function watchFailedLookupLocationOfResolution(resolution) {
102125
- ts.Debug.assert(!!resolution.refCount);
102126
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102127
- if (!failedLookupLocations.length && !affectingLocations.length)
103116
+ var failedLookupLocations = resolution.failedLookupLocations;
103117
+ if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
102128
103118
  return;
102129
- if (failedLookupLocations.length)
103119
+ if (!resolution.watchedFailed) {
102130
103120
  resolutionsWithFailedLookups.push(resolution);
102131
- var setAtRoot = false;
102132
- for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
102133
- var failedLookupLocation = failedLookupLocations_1[_i];
103121
+ if (resolution.watchedAffected)
103122
+ ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
103123
+ }
103124
+ var setAtRoot = !!resolution.setAtRoot;
103125
+ for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
103126
+ var failedLookupLocation = failedLookupLocations[i];
102134
103127
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102135
103128
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102136
103129
  if (toWatch) {
@@ -102148,22 +103141,22 @@ var ts;
102148
103141
  }
102149
103142
  }
102150
103143
  }
102151
- if (setAtRoot) {
103144
+ if (setAtRoot && !resolution.setAtRoot) {
102152
103145
  setDirectoryWatcher(rootDir, rootPath, true);
102153
103146
  }
102154
- watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
103147
+ resolution.setAtRoot = setAtRoot;
103148
+ resolution.watchedFailed = failedLookupLocations.length;
102155
103149
  }
102156
- function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
102157
- ts.Debug.assert(!!resolution.refCount);
103150
+ function watchAffectingLocationsOfResolution(resolution) {
102158
103151
  var affectingLocations = resolution.affectingLocations;
102159
- if (!affectingLocations.length)
103152
+ if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
102160
103153
  return;
102161
- if (addToResolutionsWithOnlyAffectingLocations)
103154
+ if (!resolution.watchedFailed && !resolution.watchedAffected)
102162
103155
  resolutionsWithOnlyAffectingLocations.push(resolution);
102163
- for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
102164
- var affectingLocation = affectingLocations_1[_i];
102165
- createFileWatcherOfAffectingLocation(affectingLocation, true);
103156
+ for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
103157
+ createFileWatcherOfAffectingLocation(affectingLocations[i], true);
102166
103158
  }
103159
+ resolution.watchedAffected = affectingLocations.length;
102167
103160
  }
102168
103161
  function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
102169
103162
  var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
@@ -102222,15 +103215,6 @@ var ts;
102222
103215
  paths.add(affectingLocation);
102223
103216
  }
102224
103217
  }
102225
- function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
102226
- var program = resolutionHost.getCurrentProgram();
102227
- if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
102228
- resolutions.forEach(watchFailedLookupLocationOfResolution);
102229
- }
102230
- else {
102231
- resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); });
102232
- }
102233
- }
102234
103218
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
102235
103219
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102236
103220
  if (dirWatcher) {
@@ -102241,21 +103225,27 @@ var ts;
102241
103225
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
102242
103226
  }
102243
103227
  }
102244
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102245
- ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
102246
- resolution.refCount--;
102247
- if (resolution.refCount) {
103228
+ function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
103229
+ var _a, _b;
103230
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
103231
+ if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
103232
+ (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
103233
+ }
103234
+ function closeWatchersOfResolution(_a) {
103235
+ var _b;
103236
+ var resolution = _a.resolution, getResolved = _a.getResolved;
103237
+ if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
102248
103238
  return;
102249
- }
102250
- var resolved = getResolutionWithResolvedFileName(resolution);
103239
+ resolution.files = undefined;
103240
+ var resolved = getResolved(resolution);
102251
103241
  if (resolved && resolved.resolvedFileName) {
102252
103242
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102253
103243
  }
102254
- var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102255
- if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
103244
+ if (resolution.watchedFailed) {
103245
+ ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
102256
103246
  var removeAtRoot = false;
102257
- for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
102258
- var failedLookupLocation = failedLookupLocations_2[_i];
103247
+ for (var i = 0; i < resolution.watchedFailed; i++) {
103248
+ var failedLookupLocation = resolution.failedLookupLocations[i];
102259
103249
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102260
103250
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102261
103251
  if (toWatch) {
@@ -102278,22 +103268,28 @@ var ts;
102278
103268
  }
102279
103269
  }
102280
103270
  }
103271
+ ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
102281
103272
  if (removeAtRoot) {
102282
103273
  removeDirectoryWatcher(rootPath);
102283
103274
  }
102284
103275
  }
102285
- else if (affectingLocations.length) {
103276
+ else if (resolution.watchedAffected) {
102286
103277
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102287
103278
  }
102288
- for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
102289
- var affectingLocation = affectingLocations_2[_a];
102290
- var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102291
- watcher.resolutions--;
103279
+ if (resolution.watchedAffected) {
103280
+ for (var i = 0; i < resolution.watchedAffected; i++) {
103281
+ var watcher = fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]);
103282
+ watcher.resolutions--;
103283
+ }
102292
103284
  }
102293
103285
  }
102294
103286
  function removeDirectoryWatcher(dirPath) {
102295
103287
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102296
103288
  dirWatcher.refCount--;
103289
+ if (dirWatcher.refCount === 0) {
103290
+ directoryWatchesOfFailedLookups.delete(dirPath);
103291
+ dirWatcher.watcher.close();
103292
+ }
102297
103293
  }
102298
103294
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
102299
103295
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -102307,26 +103303,16 @@ var ts;
102307
103303
  function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
102308
103304
  var resolutions = cache.get(filePath);
102309
103305
  if (resolutions) {
102310
- resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
103306
+ resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
102311
103307
  cache.delete(filePath);
102312
103308
  }
102313
103309
  }
102314
- function removeResolutionsFromProjectReferenceRedirects(filePath) {
102315
- if (!ts.fileExtensionIs(filePath, ".json"))
102316
- return;
102317
- var program = resolutionHost.getCurrentProgram();
102318
- if (!program)
102319
- return;
102320
- var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
102321
- if (!resolvedProjectReference)
102322
- return;
102323
- resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
102324
- }
102325
103310
  function removeResolutionsOfFile(filePath) {
102326
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
102327
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
103311
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleOfResolution);
103312
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveOfResolution);
102328
103313
  }
102329
103314
  function invalidateResolutions(resolutions, canInvalidate) {
103315
+ var _a;
102330
103316
  if (!resolutions)
102331
103317
  return false;
102332
103318
  var invalidated = false;
@@ -102335,16 +103321,14 @@ var ts;
102335
103321
  if (resolution.isInvalidated || !canInvalidate(resolution))
102336
103322
  continue;
102337
103323
  resolution.isInvalidated = invalidated = true;
102338
- for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102339
- var containingFilePath = _b[_a];
103324
+ (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
102340
103325
  (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102341
103326
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
102342
- }
103327
+ });
102343
103328
  }
102344
103329
  return invalidated;
102345
103330
  }
102346
103331
  function invalidateResolutionOfFile(filePath) {
102347
- removeResolutionsOfFile(filePath);
102348
103332
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
102349
103333
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
102350
103334
  hasChangedAutomaticTypeDirectiveNames &&
@@ -102353,8 +103337,28 @@ var ts;
102353
103337
  }
102354
103338
  }
102355
103339
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
102356
- ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
102357
- filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
103340
+ filesMap.forEach(function (_a, filePath) {
103341
+ var imports = _a.imports;
103342
+ if (!imports.length)
103343
+ return;
103344
+ var resolvedModules = resolvedModuleNames.get(filePath);
103345
+ var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
103346
+ if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
103347
+ return;
103348
+ imports.forEach(function (_a) {
103349
+ var name = _a.name, mode = _a.mode;
103350
+ var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
103351
+ if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
103352
+ resolvedModule.isInvalidated = true;
103353
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103354
+ }
103355
+ var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
103356
+ if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
103357
+ resolvedTypeRef.isInvalidated = true;
103358
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103359
+ }
103360
+ });
103361
+ });
102358
103362
  }
102359
103363
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
102360
103364
  if (isCreatingWatchedDirectory) {
@@ -102393,12 +103397,17 @@ var ts;
102393
103397
  var _a;
102394
103398
  var invalidated = false;
102395
103399
  if (affectingPathChecksForFile) {
102396
- (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
102397
- if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
102398
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
103400
+ for (var _i = 0, watchedPackageJsonScopes_1 = watchedPackageJsonScopes; _i < watchedPackageJsonScopes_1.length; _i++) {
103401
+ var scope = watchedPackageJsonScopes_1[_i];
103402
+ if (scope.isInvalidated)
103403
+ continue;
103404
+ if (ts.some(scope.failedLookupLocations, function (location) { return affectingPathChecksForFile.has(location); }) ||
103405
+ ts.some(scope.affectingLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
103406
+ scope.isInvalidated = true;
102399
103407
  invalidated = true;
103408
+ (_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); });
102400
103409
  }
102401
- });
103410
+ }
102402
103411
  affectingPathChecksForFile = undefined;
102403
103412
  }
102404
103413
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
@@ -102429,7 +103438,8 @@ var ts;
102429
103438
  ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
102430
103439
  }
102431
103440
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102432
- return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
103441
+ var _a;
103442
+ return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) { return affectingPathChecks.has(location); }));
102433
103443
  }
102434
103444
  function closeTypeRootsWatch() {
102435
103445
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -102730,9 +103740,9 @@ var ts;
102730
103740
  var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
102731
103741
  var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
102732
103742
  if (!preferSymlinks) {
102733
- var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
102734
- if (result_16)
102735
- return result_16;
103743
+ var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
103744
+ if (result_17)
103745
+ return result_17;
102736
103746
  }
102737
103747
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
102738
103748
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -102751,10 +103761,10 @@ var ts;
102751
103761
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
102752
103762
  var symlinkDirectory = symlinkDirectories_1[_i];
102753
103763
  var option = ts.resolvePath(symlinkDirectory, relative);
102754
- var result_17 = cb(option, target === referenceRedirect);
103764
+ var result_18 = cb(option, target === referenceRedirect);
102755
103765
  shouldFilterIgnoredPaths = true;
102756
- if (result_17)
102757
- return result_17;
103766
+ if (result_18)
103767
+ return result_18;
102758
103768
  }
102759
103769
  });
102760
103770
  });
@@ -102813,9 +103823,9 @@ var ts;
102813
103823
  };
102814
103824
  var out_directory_1;
102815
103825
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
102816
- var state_11 = _loop_35(directory);
103826
+ var state_12 = _loop_35(directory);
102817
103827
  directory = out_directory_1;
102818
- if (state_11 === "break")
103828
+ if (state_12 === "break")
102819
103829
  break;
102820
103830
  }
102821
103831
  if (allFileNames.size) {
@@ -102905,9 +103915,9 @@ var ts;
102905
103915
  };
102906
103916
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
102907
103917
  var patternText_1 = _a[_i];
102908
- var state_12 = _loop_36(patternText_1);
102909
- if (typeof state_12 === "object")
102910
- return state_12.value;
103918
+ var state_13 = _loop_36(patternText_1);
103919
+ if (typeof state_13 === "object")
103920
+ return state_13.value;
102911
103921
  }
102912
103922
  }
102913
103923
  function validateEnding(_a) {
@@ -103360,7 +104370,7 @@ var ts;
103360
104370
  }
103361
104371
  ts.explainFiles = explainFiles;
103362
104372
  function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
103363
- var _a;
104373
+ var _a, _b;
103364
104374
  var result;
103365
104375
  if (file.path !== file.resolvedPath) {
103366
104376
  (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)));
@@ -103371,17 +104381,17 @@ var ts;
103371
104381
  if (ts.isExternalOrCommonJsModule(file)) {
103372
104382
  switch (file.impliedNodeFormat) {
103373
104383
  case ts.ModuleKind.ESNext:
103374
- if (file.packageJsonScope) {
103375
- (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)));
104384
+ if ((_a = file.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
104385
+ (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)));
103376
104386
  }
103377
104387
  break;
103378
104388
  case ts.ModuleKind.CommonJS:
103379
- if (file.packageJsonScope) {
103380
- (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.packageJsonContent.type ?
104389
+ if ((_b = file.packageJsonScope) === null || _b === void 0 ? void 0 : _b.info) {
104390
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.info.packageJsonContent.type ?
103381
104391
  ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
103382
- ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
104392
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
103383
104393
  }
103384
- else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
104394
+ else if (file.packageJsonScope) {
103385
104395
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
103386
104396
  }
103387
104397
  break;
@@ -103725,7 +104735,7 @@ var ts;
103725
104735
  })(ts || (ts = {}));
103726
104736
  var ts;
103727
104737
  (function (ts) {
103728
- function readBuilderProgram(compilerOptions, host) {
104738
+ function readBuildInfoForProgram(compilerOptions, host) {
103729
104739
  var _a;
103730
104740
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
103731
104741
  if (!buildInfoPath)
@@ -103743,7 +104753,12 @@ var ts;
103743
104753
  }
103744
104754
  if (!buildInfo || buildInfo.version !== ts.version || !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();
@@ -103987,7 +105005,6 @@ var ts;
103987
105005
  writeLog(" options: " + JSON.stringify(compilerOptions));
103988
105006
  if (projectReferences)
103989
105007
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
103990
- var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
103991
105008
  hasChangedCompilerOptions = false;
103992
105009
  hasChangedConfigFileParsingErrors = false;
103993
105010
  resolutionCache.startCachingPerDirectoryResolution();
@@ -103997,9 +105014,6 @@ var ts;
103997
105014
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
103998
105015
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
103999
105016
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
104000
- if (needsUpdateInTypeRootWatch) {
104001
- resolutionCache.updateTypeRootsWatch();
104002
- }
104003
105017
  if (missingFilePathsRequestedForRelease) {
104004
105018
  for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
104005
105019
  var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
@@ -104084,7 +105098,7 @@ var ts;
104084
105098
  var hostSourceFile = sourceFilesCache.get(path);
104085
105099
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
104086
105100
  }
104087
- function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
105101
+ function onReleaseOldSourceFile(oldSourceFile) {
104088
105102
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
104089
105103
  if (hostSourceFileInfo !== undefined) {
104090
105104
  if (isFileMissingOnHost(hostSourceFileInfo)) {
@@ -104095,9 +105109,6 @@ var ts;
104095
105109
  hostSourceFileInfo.fileWatcher.close();
104096
105110
  }
104097
105111
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
104098
- if (!hasSourceFileByPath) {
104099
- resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
104100
- }
104101
105112
  }
104102
105113
  }
104103
105114
  }
@@ -104332,7 +105343,6 @@ var ts;
104332
105343
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
104333
105344
  if (config)
104334
105345
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104335
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
104336
105346
  }
104337
105347
  scheduleProgramUpdate();
104338
105348
  });
@@ -104345,7 +105355,6 @@ var ts;
104345
105355
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
104346
105356
  if (config)
104347
105357
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104348
- resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
104349
105358
  scheduleProgramUpdate();
104350
105359
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
104351
105360
  if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) {
@@ -104519,20 +105528,22 @@ var ts;
104519
105528
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
104520
105529
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
104521
105530
  compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
105531
+ compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
104522
105532
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
104523
105533
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
104524
105534
  if (!compilerHost.resolveModuleNames) {
104525
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
104526
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
104527
- return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
105535
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
105536
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
105537
+ return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
104528
105538
  };
104529
105539
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
104530
105540
  }
104531
105541
  if (!compilerHost.resolveTypeReferenceDirectives) {
104532
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
105542
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
104533
105543
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
104534
- return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
105544
+ return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
104535
105545
  };
105546
+ compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
104536
105547
  }
104537
105548
  compilerHost.getBuildInfo = function (fileName, options) { return getBuildInfo(state, fileName, options, toResolvedConfigFilePath(state, options.configFilePath), undefined); };
104538
105549
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -105495,7 +106506,7 @@ var ts;
105495
106506
  if (buildInfoTime && buildInfoTime < inputTime) {
105496
106507
  var version_3 = void 0;
105497
106508
  var currentVersion = void 0;
105498
- if (buildInfoProgram) {
106509
+ if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
105499
106510
  if (!buildInfoVersionMap)
105500
106511
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
105501
106512
  version_3 = buildInfoVersionMap.get(toPath(state, inputFile));