@typescript-deploys/pr-build 4.9.0-pr-50247-13 → 4.9.0-pr-50293-5

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
@@ -6678,8 +6678,6 @@ var ts;
6678
6678
  Found_1_error_in_1: diag(6259, ts.DiagnosticCategory.Message, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
6679
6679
  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}"),
6680
6680
  Found_0_errors_in_1_files: diag(6261, ts.DiagnosticCategory.Message, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
6681
- 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."),
6682
- 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."),
6683
6681
  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."),
6684
6682
  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}'."),
6685
6683
  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."),
@@ -6864,7 +6862,6 @@ var ts;
6864
6862
  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."),
6865
6863
  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."),
6866
6864
  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."),
6867
- 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."),
6868
6865
  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'."),
6869
6866
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
6870
6867
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -11002,8 +10999,7 @@ var ts;
11002
10999
  }
11003
11000
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
11004
11001
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
11005
- return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
11006
- optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
11002
+ return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
11007
11003
  }
11008
11004
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
11009
11005
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -11075,20 +11071,21 @@ var ts;
11075
11071
  }
11076
11072
  ts.getFullWidth = getFullWidth;
11077
11073
  function getResolvedModule(sourceFile, moduleNameText, mode) {
11078
- var _a, _b;
11079
- 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;
11074
+ return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
11080
11075
  }
11081
11076
  ts.getResolvedModule = getResolvedModule;
11082
11077
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
11083
- var _a;
11084
- (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
11078
+ if (!sourceFile.resolvedModules) {
11079
+ sourceFile.resolvedModules = ts.createModeAwareCache();
11080
+ }
11085
11081
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
11086
11082
  }
11087
11083
  ts.setResolvedModule = setResolvedModule;
11088
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
11089
- var _a;
11090
- (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
11091
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
11084
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
11085
+ if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
11086
+ sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
11087
+ }
11088
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, undefined, resolvedTypeReferenceDirective);
11092
11089
  }
11093
11090
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
11094
11091
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -11098,15 +11095,11 @@ var ts;
11098
11095
  }
11099
11096
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
11100
11097
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
11101
- return oldResolution === newResolution ||
11102
- oldResolution.resolvedModule === newResolution.resolvedModule ||
11103
- !!oldResolution.resolvedModule &&
11104
- !!newResolution.resolvedModule &&
11105
- oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
11106
- oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
11107
- oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
11108
- oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
11109
- packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
11098
+ return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
11099
+ oldResolution.extension === newResolution.extension &&
11100
+ oldResolution.resolvedFileName === newResolution.resolvedFileName &&
11101
+ oldResolution.originalPath === newResolution.originalPath &&
11102
+ packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
11110
11103
  }
11111
11104
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
11112
11105
  function packageIdIsEqual(a, b) {
@@ -11122,13 +11115,9 @@ var ts;
11122
11115
  }
11123
11116
  ts.packageIdToString = packageIdToString;
11124
11117
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
11125
- return oldResolution === newResolution ||
11126
- oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
11127
- !!oldResolution.resolvedTypeReferenceDirective &&
11128
- !!newResolution.resolvedTypeReferenceDirective &&
11129
- oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
11130
- !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
11131
- oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
11118
+ return oldResolution.resolvedFileName === newResolution.resolvedFileName
11119
+ && oldResolution.primary === newResolution.primary
11120
+ && oldResolution.originalPath === newResolution.originalPath;
11132
11121
  }
11133
11122
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
11134
11123
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -15328,15 +15317,15 @@ var ts;
15328
15317
  }
15329
15318
  ts.base64decode = base64decode;
15330
15319
  function readJsonOrUndefined(path, hostOrText) {
15331
- var jsonText = ts.isString(hostOrText) || hostOrText === undefined ? hostOrText : hostOrText.readFile(path);
15320
+ var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
15332
15321
  if (!jsonText)
15333
15322
  return undefined;
15334
15323
  var result = ts.parseConfigFileTextToJson(path, jsonText);
15335
15324
  return !result.error ? result.config : undefined;
15336
15325
  }
15337
15326
  ts.readJsonOrUndefined = readJsonOrUndefined;
15338
- function readJson(path, hostOrText) {
15339
- return readJsonOrUndefined(path, hostOrText) || {};
15327
+ function readJson(path, host) {
15328
+ return readJsonOrUndefined(path, host) || {};
15340
15329
  }
15341
15330
  ts.readJson = readJson;
15342
15331
  function directoryProbablyExists(directoryName, host) {
@@ -16316,15 +16305,14 @@ var ts;
16316
16305
  },
16317
16306
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
16318
16307
  var _this = this;
16319
- var _a, _b;
16308
+ var _a;
16320
16309
  ts.Debug.assert(!hasProcessedResolutions);
16321
16310
  hasProcessedResolutions = true;
16322
16311
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
16323
16312
  var file = files_1[_i];
16324
- (_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); });
16325
- (_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); });
16313
+ (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
16326
16314
  }
16327
- typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
16315
+ typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
16328
16316
  },
16329
16317
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
16330
16318
  };
@@ -32403,17 +32391,6 @@ var ts;
32403
32391
  transpileOptionValue: undefined,
32404
32392
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
32405
32393
  },
32406
- {
32407
- name: "cacheResolutions",
32408
- type: "boolean",
32409
- category: ts.Diagnostics.Projects,
32410
- description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
32411
- affectsModuleResolution: true,
32412
- affectsMultiFileEmitBuildInfo: true,
32413
- affectsBundleEmitBuildInfo: true,
32414
- transpileOptionValue: undefined,
32415
- defaultValueDescription: false,
32416
- },
32417
32394
  {
32418
32395
  name: "assumeChangesOnlyAffectDirectDependencies",
32419
32396
  type: "boolean",
@@ -34370,9 +34347,6 @@ var ts;
34370
34347
  if (result.configFilePath) {
34371
34348
  result.configFilePath = toAbsolutePath(result.configFilePath);
34372
34349
  }
34373
- if (result.pathsBasePath) {
34374
- result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
34375
- }
34376
34350
  return result;
34377
34351
  }
34378
34352
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -34779,7 +34753,7 @@ var ts;
34779
34753
  function getDefaultCompilerOptions(configFileName) {
34780
34754
  var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
34781
34755
  ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
34782
- : { cacheResolutions: true };
34756
+ : {};
34783
34757
  return options;
34784
34758
  }
34785
34759
  function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
@@ -35198,35 +35172,20 @@ var ts;
35198
35172
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
35199
35173
  return { fileName: resolved.path, packageId: resolved.packageId };
35200
35174
  }
35201
- function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
35202
- var _a;
35203
- var _b;
35175
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
35176
+ var _a, _b;
35204
35177
  if (resultFromCache) {
35205
- if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
35206
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
35207
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
35208
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
35178
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
35179
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
35209
35180
  return resultFromCache;
35210
35181
  }
35211
35182
  return {
35212
35183
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
35213
- failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
35214
- affectingLocations: initializeResolutionField(affectingLocations),
35215
- resolutionDiagnostics: initializeResolutionField(diagnostics),
35184
+ failedLookupLocations: failedLookupLocations,
35185
+ affectingLocations: affectingLocations,
35186
+ resolutionDiagnostics: diagnostics,
35216
35187
  };
35217
35188
  }
35218
- function initializeResolutionField(value) {
35219
- return value.length ? value : undefined;
35220
- }
35221
- function updateResolutionField(to, value) {
35222
- if (!(value === null || value === void 0 ? void 0 : value.length))
35223
- return to;
35224
- if (!(to === null || to === void 0 ? void 0 : to.length))
35225
- return value;
35226
- to.push.apply(to, value);
35227
- return to;
35228
- }
35229
- ts.updateResolutionField = updateResolutionField;
35230
35189
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
35231
35190
  if (!ts.hasProperty(jsonContent, fieldName)) {
35232
35191
  if (state.traceEnabled) {
@@ -35365,7 +35324,8 @@ var ts;
35365
35324
  options = redirectedReference.commandLine.options;
35366
35325
  }
35367
35326
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
35368
- var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, resolutionMode, redirectedReference) : undefined;
35327
+ var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
35328
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35369
35329
  if (result) {
35370
35330
  if (traceEnabled) {
35371
35331
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35416,7 +35376,7 @@ var ts;
35416
35376
  features: features,
35417
35377
  conditions: conditions,
35418
35378
  requestContainingDirectory: containingDirectory,
35419
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35379
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35420
35380
  };
35421
35381
  var resolved = primaryLookup();
35422
35382
  var primary = true;
@@ -35437,15 +35397,8 @@ var ts;
35437
35397
  isExternalLibraryImport: pathContainsNodeModules(fileName),
35438
35398
  };
35439
35399
  }
35440
- result = {
35441
- resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
35442
- failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
35443
- affectingLocations: initializeResolutionField(affectingLocations),
35444
- resolutionDiagnostics: initializeResolutionField(diagnostics),
35445
- };
35446
- if (containingDirectory && cache) {
35447
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35448
- }
35400
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
35401
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35449
35402
  if (traceEnabled)
35450
35403
  traceResult(result);
35451
35404
  return result;
@@ -35455,10 +35408,10 @@ var ts;
35455
35408
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
35456
35409
  }
35457
35410
  else if (result.resolvedTypeReferenceDirective.packageId) {
35458
- 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);
35411
+ 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);
35459
35412
  }
35460
35413
  else {
35461
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
35414
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
35462
35415
  }
35463
35416
  }
35464
35417
  function primaryLookup() {
@@ -35553,181 +35506,62 @@ var ts;
35553
35506
  return result;
35554
35507
  }
35555
35508
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
35556
- function getPackageJsconLocationFromScope(scope) {
35557
- return ts.lastOrUndefined(scope.affectingLocations);
35558
- }
35559
- ts.getPackageJsconLocationFromScope = getPackageJsconLocationFromScope;
35560
- function compilerOptionValueToString(value) {
35561
- var _a;
35562
- if (value === null || typeof value !== "object") {
35563
- return "" + value;
35564
- }
35565
- if (ts.isArray(value)) {
35566
- return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
35567
- }
35568
- var str = "{";
35569
- for (var key in value) {
35570
- if (ts.hasProperty(value, key)) {
35571
- str += key + ": " + compilerOptionValueToString(value[key]);
35572
- }
35573
- }
35574
- return str + "}";
35575
- }
35576
- function getKeyForCompilationSettings(settings, options) {
35577
- return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
35578
- }
35579
- ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
35580
- function getRedirectsCacheKey(options) {
35581
- return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
35582
- }
35583
- ts.getRedirectsCacheKey = getRedirectsCacheKey;
35584
- function createCacheWithRedirects(ownOptions) {
35585
- var ownMap;
35586
- var ownKey;
35587
- var redirectsKeyToCache = new ts.Map();
35509
+ function createCacheWithRedirects(options) {
35510
+ var ownMap = new ts.Map();
35588
35511
  var redirectsMap = new ts.Map();
35589
35512
  return {
35590
35513
  getOwnMap: getOwnMap,
35591
- redirectsKeyToCache: redirectsKeyToCache,
35592
- createMapForCompilerOptions: createMapForCompilerOptions,
35593
- getMapOfCacheRedirects: getMapOfCacheRedirects,
35514
+ redirectsMap: redirectsMap,
35594
35515
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
35595
35516
  clear: clear,
35596
- update: update,
35597
- clearRedirectsMap: function () { return redirectsMap.clear(); },
35517
+ setOwnOptions: setOwnOptions,
35518
+ setOwnMap: setOwnMap
35598
35519
  };
35599
- function ensureOwnKeyCached() {
35600
- ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
35601
- if (ownKey && !redirectsKeyToCache.has(ownKey))
35602
- redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
35603
- }
35604
- function createMapForCompilerOptions(options, optionsKey) {
35605
- if (options === ownOptions)
35606
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35607
- return getOrCreateRedirectMapAndKey(options, undefined, optionsKey);
35608
- }
35609
- function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
35610
- var _a;
35611
- if (path || options.configFile) {
35612
- var redirects = redirectsMap.get(path || options.configFile.path);
35613
- if (redirects)
35614
- return redirects;
35615
- }
35616
- var key = optionsKey || getRedirectsCacheKey(options);
35617
- var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
35618
- if (!map) {
35619
- ensureOwnKeyCached();
35620
- if (ownKey === key) {
35621
- map = ownMap;
35622
- }
35623
- else {
35624
- redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
35625
- }
35626
- }
35627
- if (path || options.configFile)
35628
- redirectsMap.set(path || options.configFile.path, map);
35629
- return map;
35630
- }
35631
35520
  function getOwnMap() {
35632
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35521
+ return ownMap;
35633
35522
  }
35634
- function update(newOwnOptions) {
35635
- if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
35636
- ensureOwnKeyCached();
35637
- if (!redirectsMap.has(ownOptions.configFile.path)) {
35638
- redirectsMap.set(ownOptions.configFile.path, ownMap);
35639
- }
35640
- }
35641
- if (newOwnOptions.configFile) {
35642
- var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
35643
- if (existing_1) {
35644
- ownMap = existing_1;
35645
- ownOptions = newOwnOptions;
35646
- return;
35647
- }
35648
- }
35649
- var key = getRedirectsCacheKey(newOwnOptions);
35650
- var existing = redirectsKeyToCache.get(key);
35651
- ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
35652
- ownKey = key;
35653
- ownOptions = newOwnOptions;
35654
- if (newOwnOptions.configFile)
35655
- redirectsMap.set(newOwnOptions.configFile.path, ownMap);
35523
+ function setOwnOptions(newOptions) {
35524
+ options = newOptions;
35656
35525
  }
35657
- function getMapOfCacheRedirects(redirectedReference) {
35658
- if (!redirectedReference)
35659
- return ownMap;
35660
- var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
35661
- if (directResult)
35662
- return directResult;
35663
- var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
35664
- var fromKey = redirectsKeyToCache.get(key);
35665
- if (fromKey) {
35666
- redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
35667
- return fromKey.map;
35668
- }
35669
- if (ownMap)
35670
- ensureOwnKeyCached();
35671
- if (ownKey === key) {
35672
- redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
35673
- return ownMap;
35674
- }
35675
- return undefined;
35526
+ function setOwnMap(newOwnMap) {
35527
+ ownMap = newOwnMap;
35676
35528
  }
35677
35529
  function getOrCreateMapOfCacheRedirects(redirectedReference) {
35678
- return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
35679
- getOwnMap() :
35680
- getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, undefined);
35530
+ if (!redirectedReference) {
35531
+ return ownMap;
35532
+ }
35533
+ var path = redirectedReference.sourceFile.path;
35534
+ var redirects = redirectsMap.get(path);
35535
+ if (!redirects) {
35536
+ redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
35537
+ redirectsMap.set(path, redirects);
35538
+ }
35539
+ return redirects;
35681
35540
  }
35682
35541
  function clear() {
35683
- ownKey = undefined;
35684
- ownMap = undefined;
35542
+ ownMap.clear();
35685
35543
  redirectsMap.clear();
35686
- redirectsKeyToCache.clear();
35687
35544
  }
35688
35545
  }
35689
35546
  ts.createCacheWithRedirects = createCacheWithRedirects;
35690
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
35691
- var dirToPackageJsonScope = new ts.Map();
35692
- var oldPackageJsonInfoCache;
35693
- return {
35694
- getPackageJsonInfo: getPackageJsonInfo,
35695
- setPackageJsonInfo: setPackageJsonInfo,
35696
- clear: clear,
35697
- entries: entries,
35698
- getInternalMap: function () { return cache; },
35699
- setInternalMap: function (value) { return cache = value; },
35700
- clone: clone,
35701
- getPackageJsonScope: getPackageJsonScope,
35702
- setPackageJsonScope: setPackageJsonScope,
35703
- setOldPackageJsonScopeCache: function (cache) { return oldPackageJsonInfoCache = cache; },
35704
- };
35547
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35548
+ var cache;
35549
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
35705
35550
  function getPackageJsonInfo(packageJsonPath) {
35706
- return cache === null || cache === void 0 ? void 0 : cache.get(toPath(packageJsonPath));
35551
+ return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35707
35552
  }
35708
35553
  function setPackageJsonInfo(packageJsonPath, info) {
35709
- (cache || (cache = new ts.Map())).set(toPath(packageJsonPath), info);
35554
+ (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info);
35710
35555
  }
35711
35556
  function clear() {
35712
- oldPackageJsonInfoCache = undefined;
35713
35557
  cache = undefined;
35714
- dirToPackageJsonScope.clear();
35715
35558
  }
35716
35559
  function entries() {
35717
35560
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35718
35561
  return iter ? ts.arrayFrom(iter) : [];
35719
35562
  }
35720
- function clone() {
35721
- return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
35722
- }
35723
- function getPackageJsonScope(dir) {
35724
- return dirToPackageJsonScope.get(dir) || (oldPackageJsonInfoCache === null || oldPackageJsonInfoCache === void 0 ? void 0 : oldPackageJsonInfoCache.getPackageJsonScope(dir));
35725
- }
35726
- function setPackageJsonScope(dir, scope) {
35727
- moduleNameToDirectorySet(dirToPackageJsonScope, dir, scope, getPackageJsconLocationFromScope, toPath, ts.noop);
35728
- }
35729
- function toPath(file) {
35730
- return ts.toPath(file, currentDirectory, getCanonicalFileName);
35563
+ function getInternalMap() {
35564
+ return cache;
35731
35565
  }
35732
35566
  }
35733
35567
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
@@ -35739,43 +35573,45 @@ var ts;
35739
35573
  }
35740
35574
  return result;
35741
35575
  }
35742
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options) {
35743
- var directoryToModuleNameMap = createCacheWithRedirects(options);
35744
- var oldResolutionCache;
35576
+ function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35577
+ if (!options.configFile)
35578
+ return;
35579
+ if (directoryToModuleNameMap.redirectsMap.size === 0) {
35580
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35581
+ ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35582
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35583
+ directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35584
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35585
+ }
35586
+ else {
35587
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35588
+ var ref = {
35589
+ sourceFile: options.configFile,
35590
+ commandLine: { options: options }
35591
+ };
35592
+ directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35593
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35594
+ }
35595
+ directoryToModuleNameMap.setOwnOptions(options);
35596
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35597
+ }
35598
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35745
35599
  return {
35746
- getFromCache: getFromCache,
35747
35600
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
35748
35601
  clear: clear,
35749
35602
  update: update,
35750
- setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
35751
35603
  };
35752
35604
  function clear() {
35753
- oldResolutionCache = undefined;
35754
35605
  directoryToModuleNameMap.clear();
35755
35606
  }
35756
35607
  function update(options) {
35757
- directoryToModuleNameMap.update(options);
35608
+ updateRedirectsMap(options, directoryToModuleNameMap);
35758
35609
  }
35759
35610
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35760
35611
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35761
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
35762
- }
35763
- function getFromCache(directoryName, name, mode, redirectedReference) {
35764
- var _a, _b;
35765
- var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35766
- 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);
35767
- if (result)
35768
- return result;
35769
- var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
35770
- if (resultFromOld)
35771
- getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
35772
- return resultFromOld;
35612
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
35773
35613
  }
35774
35614
  }
35775
- function getModeAwareCacheKey(specifier, mode) {
35776
- return (mode === undefined ? specifier : mode + "|" + specifier);
35777
- }
35778
- ts.getModeAwareCacheKey = getModeAwareCacheKey;
35779
35615
  function createModeAwareCache() {
35780
35616
  var underlying = new ts.Map();
35781
35617
  var memoizedReverseKeys = new ts.Map();
@@ -35800,22 +35636,13 @@ var ts;
35800
35636
  return cb(elem, specifier, mode);
35801
35637
  });
35802
35638
  },
35803
- entries: function () {
35804
- var keys = underlying.entries();
35805
- return {
35806
- next: function () {
35807
- var next = keys.next();
35808
- return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
35809
- },
35810
- };
35811
- },
35812
35639
  size: function () {
35813
35640
  return underlying.size;
35814
- },
35641
+ }
35815
35642
  };
35816
35643
  return cache;
35817
35644
  function getUnderlyingCacheKey(specifier, mode) {
35818
- var result = getModeAwareCacheKey(specifier, mode);
35645
+ var result = mode === undefined ? specifier : mode + "|" + specifier;
35819
35646
  memoizedReverseKeys.set(result, [specifier, mode]);
35820
35647
  return result;
35821
35648
  }
@@ -35826,122 +35653,100 @@ var ts;
35826
35653
  var map = createModeAwareCache();
35827
35654
  for (var i = 0; i < keys.length; ++i) {
35828
35655
  var entry = keys[i];
35829
- var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
35656
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
35830
35657
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
35831
35658
  map.set(name, mode, values[i]);
35832
35659
  }
35833
35660
  return map;
35834
35661
  }
35835
35662
  ts.zipToModeAwareCache = zipToModeAwareCache;
35836
- function getCommonPrefix(directory, resolution, toPath) {
35837
- var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
35838
- var i = 0;
35839
- var limit = Math.min(directory.length, resolutionDirectory.length);
35840
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35841
- i++;
35842
- }
35843
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35844
- return directory;
35845
- }
35846
- var rootLength = ts.getRootLength(directory);
35847
- if (i < rootLength) {
35848
- return undefined;
35849
- }
35850
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35851
- if (sep === -1) {
35852
- return undefined;
35853
- }
35854
- return directory.substr(0, Math.max(sep, rootLength));
35855
- }
35856
- function getResolvedFileNameForModuleNameToDirectorySet(result) {
35857
- return result.resolvedModule &&
35858
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35859
- }
35860
- ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
35861
- function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
35862
- if (directoryPathMap.has(directory))
35863
- return;
35864
- directoryPathMap.set(directory, result);
35865
- var resolvedFileName = getResolvedFileName(result);
35866
- var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
35867
- var current = directory;
35868
- while (current !== commonPrefix) {
35869
- var parent = ts.getDirectoryPath(current);
35870
- if (parent === current)
35871
- break;
35872
- if (directoryPathMap.has(parent)) {
35873
- ancestoryWorker(parent);
35874
- break;
35875
- }
35876
- directoryPathMap.set(parent, result);
35877
- ancestoryWorker(parent);
35878
- current = parent;
35879
- }
35880
- }
35881
- ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
35882
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35883
- var moduleNameToDirectoryMap = createCacheWithRedirects(options);
35884
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35663
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35664
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35665
+ moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35885
35666
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35886
- var oldResolutionCache;
35887
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
35667
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35888
35668
  function clear() {
35889
- oldResolutionCache = undefined;
35669
+ clearAllExceptPackageJsonInfoCache();
35670
+ packageJsonInfoCache.clear();
35671
+ }
35672
+ function clearAllExceptPackageJsonInfoCache() {
35890
35673
  perDirectoryResolutionCache.clear();
35891
35674
  moduleNameToDirectoryMap.clear();
35892
- packageJsonInfoCache.clear();
35893
35675
  }
35894
35676
  function update(options) {
35895
- perDirectoryResolutionCache.update(options);
35896
- moduleNameToDirectoryMap.update(options);
35897
- }
35898
- function setOldResolutionCache(cache) {
35899
- oldResolutionCache = cache;
35900
- perDirectoryResolutionCache.setOldResolutionCache(cache);
35901
- }
35902
- function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
35903
- var _a, _b;
35904
- ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35905
- 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);
35906
- if (result)
35907
- return result;
35908
- var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
35909
- if (fromOld)
35910
- getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
35911
- return fromOld;
35677
+ updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35912
35678
  }
35913
35679
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35914
35680
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35915
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35681
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
35916
35682
  }
35917
35683
  function createPerModuleNameCache() {
35918
35684
  var directoryPathMap = new ts.Map();
35919
35685
  return { get: get, set: set };
35920
35686
  function get(directory) {
35921
- return directoryPathMap.get(toPath(directory));
35687
+ return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
35922
35688
  }
35923
35689
  function set(directory, result) {
35924
- return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
35690
+ var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
35691
+ if (directoryPathMap.has(path)) {
35692
+ return;
35693
+ }
35694
+ directoryPathMap.set(path, result);
35695
+ var resolvedFileName = result.resolvedModule &&
35696
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35697
+ var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35698
+ var current = path;
35699
+ while (current !== commonPrefix) {
35700
+ var parent = ts.getDirectoryPath(current);
35701
+ if (parent === current || directoryPathMap.has(parent)) {
35702
+ break;
35703
+ }
35704
+ directoryPathMap.set(parent, result);
35705
+ current = parent;
35706
+ }
35707
+ }
35708
+ function getCommonPrefix(directory, resolution) {
35709
+ var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
35710
+ var i = 0;
35711
+ var limit = Math.min(directory.length, resolutionDirectory.length);
35712
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35713
+ i++;
35714
+ }
35715
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35716
+ return directory;
35717
+ }
35718
+ var rootLength = ts.getRootLength(directory);
35719
+ if (i < rootLength) {
35720
+ return undefined;
35721
+ }
35722
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35723
+ if (sep === -1) {
35724
+ return undefined;
35725
+ }
35726
+ return directory.substr(0, Math.max(sep, rootLength));
35925
35727
  }
35926
- }
35927
- function toPath(fileName) {
35928
- return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
35929
35728
  }
35930
35729
  }
35931
35730
  ts.createModuleResolutionCache = createModuleResolutionCache;
35932
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35933
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options);
35731
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35732
+ var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35934
35733
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35935
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear });
35734
+ return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
35936
35735
  function clear() {
35937
- perDirectoryResolutionCache.clear();
35736
+ clearAllExceptPackageJsonInfoCache();
35938
35737
  packageJsonInfoCache.clear();
35939
35738
  }
35739
+ function clearAllExceptPackageJsonInfoCache() {
35740
+ perDirectoryResolutionCache.clear();
35741
+ }
35940
35742
  }
35941
35743
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35942
35744
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35943
35745
  var containingDirectory = ts.getDirectoryPath(containingFile);
35944
- return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
35746
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35747
+ if (!perFolderCache)
35748
+ return undefined;
35749
+ return perFolderCache.get(moduleName, mode);
35945
35750
  }
35946
35751
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
35947
35752
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -35956,7 +35761,8 @@ var ts;
35956
35761
  }
35957
35762
  }
35958
35763
  var containingDirectory = ts.getDirectoryPath(containingFile);
35959
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
35764
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35765
+ var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35960
35766
  if (result) {
35961
35767
  if (traceEnabled) {
35962
35768
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36008,8 +35814,8 @@ var ts;
36008
35814
  if (result && result.resolvedModule)
36009
35815
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
36010
35816
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
36011
- if (cache) {
36012
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35817
+ if (perFolderCache) {
35818
+ perFolderCache.set(moduleName, resolutionMode, result);
36013
35819
  if (!ts.isExternalModuleNameRelative(moduleName)) {
36014
35820
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
36015
35821
  }
@@ -36213,10 +36019,10 @@ var ts;
36213
36019
  features: features,
36214
36020
  conditions: conditions,
36215
36021
  requestContainingDirectory: containingDirectory,
36216
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36022
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
36217
36023
  };
36218
36024
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
36219
- 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);
36025
+ 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);
36220
36026
  function tryResolve(extensions) {
36221
36027
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
36222
36028
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -36553,42 +36359,21 @@ var ts;
36553
36359
  features: NodeResolutionFeatures.None,
36554
36360
  conditions: ts.emptyArray,
36555
36361
  requestContainingDirectory: undefined,
36556
- reportResolutionDiagnostic: ts.noop
36362
+ reportDiagnostic: ts.noop
36557
36363
  };
36558
36364
  }
36559
36365
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
36560
- function getPackageScope(dir, packageJsonInfoCache, host, options) {
36561
- var state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
36562
- var failedLookupLocations = [];
36563
- var affectingLocations = [];
36564
- state.failedLookupLocations = failedLookupLocations;
36565
- state.affectingLocations = affectingLocations;
36566
- var result = ts.forEachAncestorDirectory(dir, function (directory) {
36567
- var _a;
36568
- var fromCache = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonScope(directory);
36569
- if (fromCache) {
36570
- var host_2 = state.host, traceEnabled = state.traceEnabled;
36571
- if (traceEnabled) {
36572
- trace(host_2, fromCache.info ?
36573
- ts.Diagnostics.Directory_0_resolves_to_1_scope_according_to_cache :
36574
- ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_according_to_cache, directory, getPackageJsconLocationFromScope(fromCache));
36575
- }
36576
- return fromCache;
36577
- }
36578
- var info = getPackageJsonInfo(directory, false, state);
36579
- if (info)
36580
- return { info: info };
36581
- }) || { info: undefined };
36582
- result.failedLookupLocations = updateResolutionField(result.failedLookupLocations, !options.cacheResolutions || !result.info ? failedLookupLocations : undefined);
36583
- result.affectingLocations = updateResolutionField(result.affectingLocations, affectingLocations);
36584
- packageJsonInfoCache === null || packageJsonInfoCache === void 0 ? void 0 : packageJsonInfoCache.setPackageJsonScope(dir, result);
36585
- return result;
36586
- }
36587
- ts.getPackageScope = getPackageScope;
36588
- function getPackageScopeForPath(dir, state) {
36589
- return ts.forEachAncestorDirectory(dir, function (directory) {
36590
- return getPackageJsonInfo(directory, false, state);
36591
- });
36366
+ function getPackageScopeForPath(fileName, state) {
36367
+ var parts = ts.getPathComponents(fileName);
36368
+ parts.pop();
36369
+ while (parts.length > 0) {
36370
+ var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), false, state);
36371
+ if (pkg) {
36372
+ return pkg;
36373
+ }
36374
+ parts.pop();
36375
+ }
36376
+ return undefined;
36592
36377
  }
36593
36378
  ts.getPackageScopeForPath = getPackageScopeForPath;
36594
36379
  function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
@@ -36616,13 +36401,12 @@ var ts;
36616
36401
  }
36617
36402
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
36618
36403
  if (directoryExists && host.fileExists(packageJsonPath)) {
36619
- var packageJsonText = host.readFile(packageJsonPath);
36620
- var packageJsonContent = ts.readJson(packageJsonPath, packageJsonText);
36404
+ var packageJsonContent = ts.readJson(packageJsonPath, host);
36621
36405
  if (traceEnabled) {
36622
36406
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
36623
36407
  }
36624
36408
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
36625
- var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36409
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36626
36410
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
36627
36411
  state.affectingLocations.push(packageJsonPath);
36628
36412
  return result;
@@ -36735,7 +36519,7 @@ var ts;
36735
36519
  function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
36736
36520
  var _a, _b;
36737
36521
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36738
- 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));
36522
+ 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));
36739
36523
  var scope = getPackageScopeForPath(directoryPath, state);
36740
36524
  if (!scope || !scope.packageJsonContent.exports) {
36741
36525
  return undefined;
@@ -36794,7 +36578,7 @@ var ts;
36794
36578
  return toSearchResult(undefined);
36795
36579
  }
36796
36580
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
36797
- 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));
36581
+ 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));
36798
36582
  var scope = getPackageScopeForPath(directoryPath, state);
36799
36583
  if (!scope) {
36800
36584
  if (state.traceEnabled) {
@@ -36994,8 +36778,11 @@ var ts;
36994
36778
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
36995
36779
  }
36996
36780
  }
36997
- if (commonSourceDirGuesses.length > 1)
36998
- state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
36781
+ if (commonSourceDirGuesses.length > 1) {
36782
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
36783
+ ? 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
36784
+ : 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));
36785
+ }
36999
36786
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
37000
36787
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
37001
36788
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -37060,10 +36847,10 @@ var ts;
37060
36847
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
37061
36848
  }
37062
36849
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
37063
- var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
36850
+ var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
37064
36851
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
37065
36852
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
37066
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36853
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
37067
36854
  if (resolutionFromCache) {
37068
36855
  return resolutionFromCache;
37069
36856
  }
@@ -37200,8 +36987,8 @@ var ts;
37200
36987
  typesPackageName;
37201
36988
  }
37202
36989
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
37203
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
37204
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
36990
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36991
+ var result = cache && cache.get(containingDirectory);
37205
36992
  if (result) {
37206
36993
  if (state.traceEnabled) {
37207
36994
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -37226,18 +37013,19 @@ var ts;
37226
37013
  features: NodeResolutionFeatures.None,
37227
37014
  conditions: [],
37228
37015
  requestContainingDirectory: containingDirectory,
37229
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
37016
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37230
37017
  };
37231
37018
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
37232
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37019
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37233
37020
  function tryResolve(extensions) {
37234
37021
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
37235
37022
  if (resolvedUsingSettings) {
37236
37023
  return { value: resolvedUsingSettings };
37237
37024
  }
37238
37025
  if (!ts.isExternalModuleNameRelative(moduleName)) {
37026
+ var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, undefined, redirectedReference);
37239
37027
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
37240
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, undefined, directory, redirectedReference, state);
37028
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
37241
37029
  if (resolutionFromCache) {
37242
37030
  return resolutionFromCache;
37243
37031
  }
@@ -37276,10 +37064,10 @@ var ts;
37276
37064
  features: NodeResolutionFeatures.None,
37277
37065
  conditions: [],
37278
37066
  requestContainingDirectory: undefined,
37279
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
37067
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37280
37068
  };
37281
37069
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
37282
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37070
+ return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37283
37071
  }
37284
37072
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
37285
37073
  function toSearchResult(value) {
@@ -40292,10 +40080,9 @@ var ts;
40292
40080
  host.getSourceFiles().forEach(function (sf) {
40293
40081
  if (!sf.resolvedModules)
40294
40082
  return;
40295
- sf.resolvedModules.forEach(function (_a) {
40296
- var resolvedModule = _a.resolvedModule;
40297
- if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
40298
- map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" || !!map.get(resolvedModule.packageId.name));
40083
+ sf.resolvedModules.forEach(function (r) {
40084
+ if (r && r.packageId)
40085
+ map.set(r.packageId.name, r.extension === ".d.ts" || !!map.get(r.packageId.name));
40299
40086
  });
40300
40087
  });
40301
40088
  return map;
@@ -42928,7 +42715,7 @@ var ts;
42928
42715
  : undefined;
42929
42716
  }
42930
42717
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
42931
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
42718
+ var _a, _b, _c, _d, _e, _f, _g, _h;
42932
42719
  if (isForAugmentation === void 0) { isForAugmentation = false; }
42933
42720
  if (ts.startsWith(moduleReference, "@types/")) {
42934
42721
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -42974,7 +42761,7 @@ var ts;
42974
42761
  var diagnosticDetails = void 0;
42975
42762
  var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName);
42976
42763
  if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") {
42977
- var scope = (_h = currentSourceFile.packageJsonScope) === null || _h === void 0 ? void 0 : _h.info;
42764
+ var scope = currentSourceFile.packageJsonScope;
42978
42765
  var targetExt = ext === ".ts" ? ".mts" : ext === ".js" ? ".mjs" : undefined;
42979
42766
  if (scope && !scope.packageJsonContent.type) {
42980
42767
  if (targetExt) {
@@ -43058,10 +42845,10 @@ var ts;
43058
42845
  }
43059
42846
  else if (mode === ts.ModuleKind.ESNext && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
43060
42847
  var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
43061
- var suggestedExt = (_j = suggestedExtensions.find(function (_a) {
42848
+ var suggestedExt = (_h = suggestedExtensions.find(function (_a) {
43062
42849
  var actualExt = _a[0], _importExt = _a[1];
43063
42850
  return host.fileExists(absoluteRef_1 + actualExt);
43064
- })) === null || _j === void 0 ? void 0 : _j[1];
42851
+ })) === null || _h === void 0 ? void 0 : _h[1];
43065
42852
  if (suggestedExt) {
43066
42853
  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);
43067
42854
  }
@@ -73411,12 +73198,12 @@ var ts;
73411
73198
  var parent = node.parent;
73412
73199
  var paramTag = node.parent.parent;
73413
73200
  if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
73414
- var host_3 = ts.getHostSignatureFromJSDoc(paramTag);
73201
+ var host_2 = ts.getHostSignatureFromJSDoc(paramTag);
73415
73202
  var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent);
73416
- if (host_3 || isCallbackTag) {
73203
+ if (host_2 || isCallbackTag) {
73417
73204
  var lastParamDeclaration = isCallbackTag
73418
73205
  ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters)
73419
- : ts.lastOrUndefined(host_3.parameters);
73206
+ : ts.lastOrUndefined(host_2.parameters);
73420
73207
  var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
73421
73208
  if (!lastParamDeclaration ||
73422
73209
  symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
@@ -74651,12 +74438,11 @@ var ts;
74651
74438
  var fileToDirective;
74652
74439
  if (resolvedTypeReferenceDirectives) {
74653
74440
  fileToDirective = new ts.Map();
74654
- resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
74655
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
74656
- if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
74441
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
74442
+ if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
74657
74443
  return;
74658
74444
  }
74659
- var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
74445
+ var file = host.getSourceFile(resolvedDirective.resolvedFileName);
74660
74446
  if (file) {
74661
74447
  addReferencedFilesToTypeDirective(file, key, mode);
74662
74448
  }
@@ -75933,9 +75719,9 @@ var ts;
75933
75719
  }
75934
75720
  var parent = ts.walkUpParenthesizedTypes(node.parent);
75935
75721
  if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
75936
- var host_4 = ts.getJSDocHost(parent);
75937
- if (host_4) {
75938
- parent = ts.getSingleVariableOfVariableStatement(host_4) || host_4;
75722
+ var host_3 = ts.getJSDocHost(parent);
75723
+ if (host_3) {
75724
+ parent = ts.getSingleVariableOfVariableStatement(host_3) || host_3;
75939
75725
  }
75940
75726
  }
75941
75727
  switch (parent.kind) {
@@ -92448,7 +92234,7 @@ var ts;
92448
92234
  var sourceMap = sourceMapGenerator.toString();
92449
92235
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
92450
92236
  if (printer.bundleFileInfo)
92451
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
92237
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
92452
92238
  }
92453
92239
  }
92454
92240
  else {
@@ -92457,7 +92243,7 @@ var ts;
92457
92243
  var text = writer.getText();
92458
92244
  ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
92459
92245
  if (printer.bundleFileInfo)
92460
- printer.bundleFileInfo.hash = ts.computeSignature(text, host);
92246
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
92461
92247
  writer.clear();
92462
92248
  }
92463
92249
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92592,6 +92378,7 @@ var ts;
92592
92378
  }
92593
92379
  ts.emitUsingBuildInfo = emitUsingBuildInfo;
92594
92380
  function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransformers) {
92381
+ var createHash = ts.maybeBind(host, host.createHash);
92595
92382
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
92596
92383
  var buildInfo = host.getBuildInfo(buildInfoPath, config.options);
92597
92384
  if (!buildInfo)
@@ -92601,22 +92388,22 @@ var ts;
92601
92388
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
92602
92389
  if (!jsFileText)
92603
92390
  return jsFilePath;
92604
- if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
92391
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92605
92392
  return jsFilePath;
92606
92393
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92607
92394
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
92608
92395
  return sourceMapFilePath || "inline sourcemap decoding";
92609
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
92396
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92610
92397
  return sourceMapFilePath;
92611
92398
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
92612
92399
  if (declarationFilePath && !declarationText)
92613
92400
  return declarationFilePath;
92614
- if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
92401
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92615
92402
  return declarationFilePath;
92616
92403
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92617
92404
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
92618
92405
  return declarationMapPath || "inline sourcemap decoding";
92619
- if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
92406
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92620
92407
  return declarationMapPath;
92621
92408
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92622
92409
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
@@ -92654,7 +92441,7 @@ var ts;
92654
92441
  var newBuildInfo = data.buildInfo;
92655
92442
  newBuildInfo.program = buildInfo.program;
92656
92443
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
92657
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
92444
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
92658
92445
  }
92659
92446
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
92660
92447
  newBuildInfo.bundle.js.sources = js.sources;
@@ -92688,7 +92475,7 @@ var ts;
92688
92475
  getSourceFileFromReference: ts.returnUndefined,
92689
92476
  redirectTargetsMap: ts.createMultiMap(),
92690
92477
  getFileIncludeReasons: ts.notImplemented,
92691
- createHash: ts.maybeBind(host, host.createHash),
92478
+ createHash: createHash,
92692
92479
  buildInfoCallbacks: host.buildInfoCallbacks,
92693
92480
  };
92694
92481
  emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
@@ -97692,7 +97479,7 @@ var ts;
97692
97479
  var name = names_2[_i];
97693
97480
  var result = void 0;
97694
97481
  var mode = getModeForFileReference(name, containingFileMode);
97695
- var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
97482
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
97696
97483
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
97697
97484
  if (cache.has(cacheKey)) {
97698
97485
  result = cache.get(cacheKey);
@@ -97776,21 +97563,7 @@ var ts;
97776
97563
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97777
97564
  }
97778
97565
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
97779
- var emptyResolution = {
97780
- resolvedModule: undefined,
97781
- resolvedTypeReferenceDirective: undefined,
97782
- failedLookupLocations: [],
97783
- affectingLocations: [],
97784
- resolutionDiagnostics: [],
97785
- };
97786
- function isResolvedModuleWithFailedLookupLocation(resolved) {
97787
- return !!resolved && !!resolved.failedLookupLocations;
97788
- }
97789
- function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
97790
- return !!resolved && !!resolved.failedLookupLocations;
97791
- }
97792
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
97793
- var _a;
97566
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
97794
97567
  if (names.length === 0) {
97795
97568
  return [];
97796
97569
  }
@@ -97800,7 +97573,7 @@ var ts;
97800
97573
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
97801
97574
  var name = names_3[_i];
97802
97575
  var result = void 0;
97803
- var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
97576
+ var mode = getModeForResolutionAtIndex(containingFile, i);
97804
97577
  i++;
97805
97578
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
97806
97579
  if (cache.has(cacheKey)) {
@@ -97858,14 +97631,14 @@ var ts;
97858
97631
  ts.isReferenceFileLocation = isReferenceFileLocation;
97859
97632
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97860
97633
  var _a, _b, _c;
97861
- var _d, _e, _f, _g, _h, _j;
97634
+ var _d, _e, _f, _g;
97862
97635
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
97863
97636
  var kind = ref.kind, index = ref.index;
97864
97637
  var pos, end, packageId, resolutionMode;
97865
97638
  switch (kind) {
97866
97639
  case ts.FileIncludeKind.Import:
97867
97640
  var importLiteral = getModuleNameStringLiteralAt(file, index);
97868
- 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;
97641
+ 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;
97869
97642
  if (importLiteral.pos === -1)
97870
97643
  return { file: file, packageId: packageId, text: importLiteral.text };
97871
97644
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -97876,7 +97649,7 @@ var ts;
97876
97649
  break;
97877
97650
  case ts.FileIncludeKind.TypeReferenceDirective:
97878
97651
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
97879
- 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;
97652
+ 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;
97880
97653
  break;
97881
97654
  case ts.FileIncludeKind.LibReferenceDirective:
97882
97655
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -97960,13 +97733,13 @@ var ts;
97960
97733
  return undefined;
97961
97734
  }
97962
97735
  function lookupFromPackageJson() {
97963
- var _a;
97964
- var packageJsonScope = ts.getPackageScope(ts.getDirectoryPath(fileName), packageJsonInfoCache, host, options);
97965
- var impliedNodeFormat = ((_a = packageJsonScope.info) === null || _a === void 0 ? void 0 : _a.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97966
- return {
97967
- impliedNodeFormat: impliedNodeFormat,
97968
- packageJsonScope: packageJsonScope,
97969
- };
97736
+ var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
97737
+ var packageJsonLocations = [];
97738
+ state.failedLookupLocations = packageJsonLocations;
97739
+ state.affectingLocations = packageJsonLocations;
97740
+ var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
97741
+ var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97742
+ return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
97970
97743
  }
97971
97744
  }
97972
97745
  ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
@@ -98078,10 +97851,10 @@ var ts;
98078
97851
  };
98079
97852
  }
98080
97853
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
98081
- var _a, _b, _c, _d, _e;
97854
+ var _a, _b, _c, _d;
98082
97855
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
98083
97856
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
98084
- var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
97857
+ var oldProgram = createProgramOptions.oldProgram;
98085
97858
  var processingDefaultLibFiles;
98086
97859
  var processingOtherFiles;
98087
97860
  var files;
@@ -98095,8 +97868,6 @@ var ts;
98095
97868
  var cachedDeclarationDiagnosticsForFile = {};
98096
97869
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
98097
97870
  var fileProcessingDiagnostics;
98098
- var automaticTypeDirectiveNames;
98099
- var automaticTypeDirectiveResolutions;
98100
97871
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
98101
97872
  var currentNodeModulesDepth = 0;
98102
97873
  var modulesWithElidedImports = new ts.Map();
@@ -98119,72 +97890,29 @@ var ts;
98119
97890
  var actualResolveModuleNamesWorker;
98120
97891
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
98121
97892
  if (host.resolveModuleNames) {
98122
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
98123
- var _a;
98124
- 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) {
98125
- var name = _a.name;
98126
- return name;
98127
- }), redirectedReference, options, containingFile, partialResolutionInfo);
98128
- return result.some(isResolvedModuleWithFailedLookupLocation) ?
98129
- result :
98130
- result.map(function (resolved) { return resolved ?
98131
- resolved.extension !== undefined ?
98132
- { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
98133
- { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
98134
- emptyResolution; });
98135
- };
97893
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
97894
+ if (!resolved || resolved.extension !== undefined) {
97895
+ return resolved;
97896
+ }
97897
+ var withExtension = ts.clone(resolved);
97898
+ withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
97899
+ return withExtension;
97900
+ }); };
98136
97901
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
98137
97902
  }
98138
97903
  else {
98139
97904
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
98140
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
98141
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
98142
- return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
98143
- };
97905
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
97906
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
98144
97907
  }
98145
97908
  var actualResolveTypeReferenceDirectiveNamesWorker;
98146
97909
  if (host.resolveTypeReferenceDirectives) {
98147
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
98148
- var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
98149
- return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
98150
- result :
98151
- result.map(function (resolved) { return resolved ?
98152
- { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
98153
- emptyResolution; });
98154
- };
98155
- typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
97910
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
98156
97911
  }
98157
97912
  else {
98158
97913
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
98159
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
98160
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
98161
- return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
98162
- };
98163
- }
98164
- var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
98165
- var oldBuildInfoProgram;
98166
- if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
98167
- var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
98168
- oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
98169
- fileExists: function (fileName) { return host.fileExists(fileName); },
98170
- createHash: ts.maybeBind(host, host.createHash),
98171
- getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), false, state_11); },
98172
- });
98173
- if (oldBuildInfoProgram) {
98174
- moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
98175
- getResolved: function (dirPath, name, mode, redirectedReference) {
98176
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
98177
- }
98178
- });
98179
- typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
98180
- getResolved: function (dirPath, name, mode, redirectedReference) {
98181
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
98182
- }
98183
- });
98184
- moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache().setOldPackageJsonScopeCache({
98185
- getPackageJsonScope: function (dirPath) { return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getPackageJsonScope(dirPath); }
98186
- });
98187
- }
97914
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
97915
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
98188
97916
  }
98189
97917
  var packageIdToSourceFile = new ts.Map();
98190
97918
  var sourceFileToPackageName = new ts.Map();
@@ -98197,9 +97925,9 @@ var ts;
98197
97925
  var projectReferenceRedirects;
98198
97926
  var mapFromFileToProjectReferenceRedirects;
98199
97927
  var mapFromToProjectReferenceRedirectSource;
98200
- var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
97928
+ var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
98201
97929
  !options.disableSourceOfProjectReferenceRedirect;
98202
- var _f = updateHostForUseSourceOfProjectReferenceRedirect({
97930
+ var _e = updateHostForUseSourceOfProjectReferenceRedirect({
98203
97931
  compilerHost: host,
98204
97932
  getSymlinkCache: getSymlinkCache,
98205
97933
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -98207,7 +97935,7 @@ var ts;
98207
97935
  getResolvedProjectReferences: getResolvedProjectReferences,
98208
97936
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
98209
97937
  forEachResolvedProjectReference: forEachResolvedProjectReference
98210
- }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
97938
+ }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
98211
97939
  var readFile = host.readFile.bind(host);
98212
97940
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
98213
97941
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -98216,7 +97944,7 @@ var ts;
98216
97944
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
98217
97945
  structureIsReused = tryReuseStructureFromOldProgram();
98218
97946
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
98219
- if (structureIsReused !== 3) {
97947
+ if (structureIsReused !== 2) {
98220
97948
  processingDefaultLibFiles = [];
98221
97949
  processingOtherFiles = [];
98222
97950
  if (projectReferences) {
@@ -98256,14 +97984,14 @@ var ts;
98256
97984
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
98257
97985
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
98258
97986
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
98259
- automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
98260
- automaticTypeDirectiveResolutions = ts.createModeAwareCache();
98261
- if (automaticTypeDirectiveNames.length) {
98262
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: automaticTypeDirectiveNames.length });
98263
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
98264
- for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
98265
- automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], undefined, resolutions[i]);
98266
- 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 });
97987
+ var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
97988
+ if (typeReferences.length) {
97989
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
97990
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97991
+ var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97992
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
97993
+ for (var i = 0; i < typeReferences.length; i++) {
97994
+ 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 });
98267
97995
  }
98268
97996
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
98269
97997
  }
@@ -98294,13 +98022,13 @@ var ts;
98294
98022
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
98295
98023
  if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
98296
98024
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
98297
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
98025
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
98298
98026
  }
98299
98027
  }
98300
98028
  if (!host.getParsedCommandLine) {
98301
98029
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
98302
98030
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
98303
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
98031
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
98304
98032
  }
98305
98033
  });
98306
98034
  }
@@ -98316,8 +98044,6 @@ var ts;
98316
98044
  }
98317
98045
  typeReferenceDirectiveResolutionCache = undefined;
98318
98046
  oldProgram = undefined;
98319
- oldBuildInfoProgram = undefined;
98320
- oldProgramOrOldBuildInfoProgramConstructor = undefined;
98321
98047
  var program = {
98322
98048
  getRootFileNames: function () { return rootNames; },
98323
98049
  getSourceFile: getSourceFile,
@@ -98325,7 +98051,6 @@ var ts;
98325
98051
  getSourceFiles: function () { return files; },
98326
98052
  getMissingFilePaths: function () { return missingFilePaths; },
98327
98053
  getModuleResolutionCache: function () { return moduleResolutionCache; },
98328
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
98329
98054
  getFilesByNameMap: function () { return filesByName; },
98330
98055
  getCompilerOptions: function () { return options; },
98331
98056
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -98350,9 +98075,6 @@ var ts;
98350
98075
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
98351
98076
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
98352
98077
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
98353
- getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
98354
- getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
98355
- getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
98356
98078
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
98357
98079
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
98358
98080
  getSourceFileFromReference: getSourceFileFromReference,
@@ -98362,12 +98084,12 @@ var ts;
98362
98084
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
98363
98085
  isEmittedFile: isEmittedFile,
98364
98086
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
98087
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
98365
98088
  getProjectReferences: getProjectReferences,
98366
98089
  getResolvedProjectReferences: getResolvedProjectReferences,
98367
98090
  getProjectReferenceRedirect: getProjectReferenceRedirect,
98368
98091
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
98369
98092
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
98370
- getRedirectReferenceForResolution: getRedirectReferenceForResolution,
98371
98093
  forEachResolvedProjectReference: forEachResolvedProjectReference,
98372
98094
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
98373
98095
  emitBuildInfo: emitBuildInfo,
@@ -98375,7 +98097,7 @@ var ts;
98375
98097
  readFile: readFile,
98376
98098
  directoryExists: directoryExists,
98377
98099
  getSymlinkCache: getSymlinkCache,
98378
- realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
98100
+ realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
98379
98101
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
98380
98102
  getFileIncludeReasons: function () { return fileReasons; },
98381
98103
  structureIsReused: structureIsReused,
@@ -98389,8 +98111,6 @@ var ts;
98389
98111
  case 0:
98390
98112
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
98391
98113
  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)));
98392
- case 2:
98393
- return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
98394
98114
  default:
98395
98115
  ts.Debug.assertNever(diagnostic);
98396
98116
  }
@@ -98400,44 +98120,57 @@ var ts;
98400
98120
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
98401
98121
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
98402
98122
  return program;
98403
- function getAutomaticTypeDirectiveContainingFile() {
98404
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
98405
- return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
98123
+ function addResolutionDiagnostics(list) {
98124
+ if (!list)
98125
+ return;
98126
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
98127
+ var elem = list_3[_i];
98128
+ programDiagnostics.add(elem);
98129
+ }
98406
98130
  }
98407
- function addResolutionDiagnostics(resolution) {
98408
- if (!resolution.resolutionDiagnostics)
98131
+ function pullDiagnosticsFromCache(names, containingFile) {
98132
+ var _a;
98133
+ if (!moduleResolutionCache)
98409
98134
  return;
98410
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
98411
- kind: 2,
98412
- diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
98413
- ? 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
98414
- : 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); })
98415
- });
98135
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
98136
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
98137
+ var containingDir = ts.getDirectoryPath(containingFileName);
98138
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
98139
+ var i = 0;
98140
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
98141
+ var n = names_4[_i];
98142
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
98143
+ var name = typeof n === "string" ? n : n.fileName;
98144
+ i++;
98145
+ if (ts.isExternalModuleNameRelative(name))
98146
+ continue;
98147
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
98148
+ addResolutionDiagnostics(diags);
98149
+ }
98416
98150
  }
98417
- function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
98151
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
98418
98152
  if (!moduleNames.length)
98419
98153
  return ts.emptyArray;
98420
98154
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
98421
- if (redirectedReference === undefined)
98422
- redirectedReference = getRedirectReferenceForResolution(containingFile);
98155
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
98423
98156
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
98424
98157
  ts.performance.mark("beforeResolveModule");
98425
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
98158
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
98426
98159
  ts.performance.mark("afterResolveModule");
98427
98160
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
98428
98161
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
98162
+ pullDiagnosticsFromCache(moduleNames, containingFile);
98429
98163
  return result;
98430
98164
  }
98431
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
98165
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
98432
98166
  if (!typeDirectiveNames.length)
98433
98167
  return [];
98434
98168
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
98435
- if (redirectedReference === undefined && !ts.isString(containingFile))
98436
- redirectedReference = getRedirectReferenceForResolution(containingFile);
98169
+ var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
98437
98170
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
98438
98171
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
98439
98172
  ts.performance.mark("beforeResolveTypeReference");
98440
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
98173
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
98441
98174
  ts.performance.mark("afterResolveTypeReference");
98442
98175
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
98443
98176
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -98483,6 +98216,9 @@ var ts;
98483
98216
  }
98484
98217
  return ts.libs.length + 2;
98485
98218
  }
98219
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
98220
+ return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
98221
+ }
98486
98222
  function toPath(fileName) {
98487
98223
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
98488
98224
  }
@@ -98506,9 +98242,8 @@ var ts;
98506
98242
  return classifiableNames;
98507
98243
  }
98508
98244
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98509
- var _a;
98510
98245
  if (structureIsReused === 0 && !file.ambientModuleNames.length) {
98511
- return resolveModuleNamesWorker(moduleNames, file, undefined, undefined);
98246
+ return resolveModuleNamesWorker(moduleNames, file, undefined);
98512
98247
  }
98513
98248
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
98514
98249
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -98523,34 +98258,21 @@ var ts;
98523
98258
  return result_14;
98524
98259
  }
98525
98260
  var unknownModuleNames;
98526
- var unknownModuleNamesIndex;
98527
- var reusedNames;
98528
98261
  var result;
98529
- var predictedToResolveToAmbientModuleMarker = true;
98530
- var redirectedReference;
98262
+ var reusedNames;
98263
+ var predictedToResolveToAmbientModuleMarker = {};
98531
98264
  for (var i = 0; i < moduleNames.length; i++) {
98532
98265
  var moduleName = moduleNames[i];
98533
- if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98534
- var mode = getModeForResolutionAtIndex(file, i);
98535
- var oldResolution = !oldBuildInfoProgram ?
98536
- (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
98537
- oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
98538
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
98266
+ if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98267
+ var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
98268
+ if (oldResolvedModule) {
98539
98269
  if (ts.isTraceEnabled(options, host)) {
98540
- var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
98541
- if (!oldBuildInfoProgram) {
98542
- ts.trace(host, oldResolution.resolvedModule.packageId ?
98543
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98544
- 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));
98545
- }
98546
- else {
98547
- ts.trace(host, oldResolution.resolvedModule.packageId ?
98548
- 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 :
98549
- 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));
98550
- }
98270
+ ts.trace(host, oldResolvedModule.packageId ?
98271
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98272
+ 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));
98551
98273
  }
98552
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
98553
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
98274
+ (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
98275
+ (reusedNames || (reusedNames = [])).push(moduleName);
98554
98276
  continue;
98555
98277
  }
98556
98278
  }
@@ -98565,15 +98287,14 @@ var ts;
98565
98287
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
98566
98288
  }
98567
98289
  if (resolvesToAmbientModuleInNonModifiedFile) {
98568
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98290
+ (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98569
98291
  }
98570
98292
  else {
98571
- (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
98572
- (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
98293
+ (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
98573
98294
  }
98574
98295
  }
98575
98296
  var resolutions = unknownModuleNames && unknownModuleNames.length
98576
- ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
98297
+ ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
98577
98298
  : ts.emptyArray;
98578
98299
  if (!result) {
98579
98300
  ts.Debug.assert(resolutions.length === moduleNames.length);
@@ -98583,7 +98304,7 @@ var ts;
98583
98304
  for (var i = 0; i < result.length; i++) {
98584
98305
  if (result[i]) {
98585
98306
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
98586
- result[i] = emptyResolution;
98307
+ result[i] = undefined;
98587
98308
  }
98588
98309
  }
98589
98310
  else {
@@ -98611,78 +98332,6 @@ var ts;
98611
98332
  return true;
98612
98333
  }
98613
98334
  }
98614
- function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98615
- var _a;
98616
- if (structureIsReused === 0) {
98617
- return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, undefined, undefined);
98618
- }
98619
- var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
98620
- var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
98621
- var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
98622
- if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
98623
- var result_15 = [];
98624
- for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
98625
- var typeDirectiveName = _b[_i];
98626
- var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
98627
- result_15.push(resolvedTypeReferenceDirective);
98628
- }
98629
- return result_15;
98630
- }
98631
- var unknownTypeReferenceDirectiveNames;
98632
- var unknownTypeReferenceDirectiveNamesIndex;
98633
- var result;
98634
- var reusedNames;
98635
- var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
98636
- containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
98637
- !hasInvalidatedResolution(toPath(inferredTypeFile)));
98638
- var redirectedReference;
98639
- for (var i = 0; i < typeDirectiveNames.length; i++) {
98640
- var entry = typeDirectiveNames[i];
98641
- if (canReuseResolutions) {
98642
- var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
98643
- var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
98644
- var oldResolution = !oldBuildInfoProgram ?
98645
- (_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) :
98646
- oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
98647
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98648
- if (ts.isTraceEnabled(options, host)) {
98649
- var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
98650
- if (!oldBuildInfoProgram) {
98651
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98652
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98653
- 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));
98654
- }
98655
- else {
98656
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98657
- 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 :
98658
- 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));
98659
- }
98660
- }
98661
- (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
98662
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
98663
- continue;
98664
- }
98665
- }
98666
- (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
98667
- (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
98668
- }
98669
- if (!unknownTypeReferenceDirectiveNames)
98670
- return result || ts.emptyArray;
98671
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
98672
- if (!result) {
98673
- ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
98674
- return resolutions;
98675
- }
98676
- var j = 0;
98677
- for (var i = 0; i < result.length; i++) {
98678
- if (!result[i]) {
98679
- result[i] = resolutions[j];
98680
- j++;
98681
- }
98682
- }
98683
- ts.Debug.assert(j === resolutions.length);
98684
- return result;
98685
- }
98686
98335
  function canReuseProjectReferences() {
98687
98336
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
98688
98337
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -98701,17 +98350,12 @@ var ts;
98701
98350
  });
98702
98351
  }
98703
98352
  function tryReuseStructureFromOldProgram() {
98704
- var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
98705
- if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
98353
+ var _a, _b;
98354
+ if (!oldProgram) {
98706
98355
  return 0;
98707
98356
  }
98708
- var result = tryReuseStructureFromOldProgramWorker();
98709
- return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 ?
98710
- 1 :
98711
- result;
98712
- }
98713
- function tryReuseStructureFromOldProgramWorker() {
98714
- if (!oldProgram) {
98357
+ var oldOptions = oldProgram.getCompilerOptions();
98358
+ if (ts.changesAffectModuleResolution(oldOptions, options)) {
98715
98359
  return 0;
98716
98360
  }
98717
98361
  var oldRootNames = oldProgram.getRootFileNames();
@@ -98726,7 +98370,7 @@ var ts;
98726
98370
  }
98727
98371
  var newSourceFiles = [];
98728
98372
  var modifiedSourceFiles = [];
98729
- structureIsReused = 3;
98373
+ structureIsReused = 2;
98730
98374
  if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
98731
98375
  return 0;
98732
98376
  }
@@ -98734,13 +98378,14 @@ var ts;
98734
98378
  var seenPackageNames = new ts.Map();
98735
98379
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
98736
98380
  var oldSourceFile = oldSourceFiles_2[_i];
98737
- var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName);
98381
+ var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
98738
98382
  var newSourceFile = host.getSourceFileByPath
98739
98383
  ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
98740
98384
  : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat);
98741
98385
  if (!newSourceFile) {
98742
98386
  return 0;
98743
98387
  }
98388
+ newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
98744
98389
  newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
98745
98390
  ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
98746
98391
  var fileChanged = void 0;
@@ -98775,95 +98420,86 @@ var ts;
98775
98420
  }
98776
98421
  if (fileChanged) {
98777
98422
  if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
98778
- structureIsReused = 2;
98423
+ structureIsReused = 1;
98779
98424
  }
98780
98425
  else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
98781
- structureIsReused = 2;
98426
+ structureIsReused = 1;
98782
98427
  }
98783
98428
  else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
98784
- structureIsReused = 2;
98429
+ structureIsReused = 1;
98785
98430
  }
98786
98431
  else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
98787
- structureIsReused = 2;
98432
+ structureIsReused = 1;
98788
98433
  }
98789
98434
  else {
98790
98435
  collectExternalModuleReferences(newSourceFile);
98791
98436
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98792
- structureIsReused = 2;
98437
+ structureIsReused = 1;
98793
98438
  }
98794
98439
  else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98795
- structureIsReused = 2;
98440
+ structureIsReused = 1;
98796
98441
  }
98797
98442
  else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98798
- structureIsReused = 2;
98443
+ structureIsReused = 1;
98799
98444
  }
98800
98445
  else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
98801
- structureIsReused = 2;
98446
+ structureIsReused = 1;
98802
98447
  }
98803
98448
  }
98804
98449
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98805
98450
  }
98806
98451
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
98807
- structureIsReused = 2;
98452
+ structureIsReused = 1;
98808
98453
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98809
98454
  }
98810
98455
  newSourceFiles.push(newSourceFile);
98811
98456
  }
98812
- if (structureIsReused !== 3) {
98457
+ if (structureIsReused !== 2) {
98813
98458
  return structureIsReused;
98814
98459
  }
98815
98460
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98816
- for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
98817
- var oldFile = oldSourceFiles_3[_a];
98461
+ for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
98462
+ var oldFile = oldSourceFiles_3[_c];
98818
98463
  if (!ts.contains(modifiedFiles, oldFile)) {
98819
- for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
98820
- var moduleName = _c[_b];
98464
+ for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
98465
+ var moduleName = _e[_d];
98821
98466
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98822
98467
  }
98823
98468
  }
98824
98469
  }
98825
- for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
98826
- var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
98470
+ for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
98471
+ var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
98827
98472
  var moduleNames = getModuleNames(newSourceFile);
98828
98473
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98829
98474
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
98830
98475
  if (resolutionsChanged) {
98831
- structureIsReused = 2;
98476
+ structureIsReused = 1;
98832
98477
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98833
98478
  }
98834
98479
  else {
98835
98480
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98836
98481
  }
98837
98482
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98838
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98483
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
98839
98484
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
98840
98485
  if (typeReferenceResolutionsChanged) {
98841
- structureIsReused = 2;
98486
+ structureIsReused = 1;
98842
98487
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98843
98488
  }
98844
98489
  else {
98845
98490
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98846
98491
  }
98847
98492
  }
98848
- if (structureIsReused !== 3) {
98493
+ if (structureIsReused !== 2) {
98849
98494
  return structureIsReused;
98850
98495
  }
98851
- if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
98852
- return 2;
98853
- }
98854
- if (host.hasChangedAutomaticTypeDirectiveNames) {
98855
- if (host.hasChangedAutomaticTypeDirectiveNames())
98856
- return 2;
98857
- }
98858
- else {
98859
- automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
98860
- if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98861
- return 2;
98496
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
98497
+ return 1;
98862
98498
  }
98863
98499
  missingFilePaths = oldProgram.getMissingFilePaths();
98864
98500
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98865
- for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
98866
- var newSourceFile = newSourceFiles_1[_f];
98501
+ for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
98502
+ var newSourceFile = newSourceFiles_1[_h];
98867
98503
  filesByName.set(newSourceFile.path, newSourceFile);
98868
98504
  }
98869
98505
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98884,12 +98520,10 @@ var ts;
98884
98520
  fileReasons = oldProgram.getFileIncludeReasons();
98885
98521
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98886
98522
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98887
- automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98888
- automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98889
98523
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98890
98524
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98891
98525
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
98892
- return 3;
98526
+ return 2;
98893
98527
  }
98894
98528
  function getEmitHost(writeFileCallback) {
98895
98529
  return {
@@ -99567,12 +99201,14 @@ var ts;
99567
99201
  }
99568
99202
  }
99569
99203
  function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
99204
+ var _a;
99570
99205
  var redirect = Object.create(redirectTarget);
99571
99206
  redirect.fileName = fileName;
99572
99207
  redirect.path = path;
99573
99208
  redirect.resolvedPath = resolvedPath;
99574
99209
  redirect.originalFileName = originalFileName;
99575
99210
  redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
99211
+ redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
99576
99212
  redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
99577
99213
  sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
99578
99214
  Object.defineProperties(redirect, {
@@ -99597,7 +99233,7 @@ var ts;
99597
99233
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99598
99234
  return result;
99599
99235
  }
99600
- function getCreateSourceFileOptions(fileName) {
99236
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
99601
99237
  var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
99602
99238
  var languageVersion = ts.getEmitScriptTarget(options);
99603
99239
  var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
@@ -99605,7 +99241,7 @@ var ts;
99605
99241
  { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
99606
99242
  }
99607
99243
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
99608
- var _a;
99244
+ var _a, _b;
99609
99245
  var path = toPath(fileName);
99610
99246
  if (useSourceOfProjectReferenceRedirect) {
99611
99247
  var source = getSourceOfProjectReferenceRedirect(path);
@@ -99675,7 +99311,7 @@ var ts;
99675
99311
  redirectedPath = toPath(redirect);
99676
99312
  }
99677
99313
  }
99678
- var sourceFileOptions = getCreateSourceFileOptions(fileName);
99314
+ var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
99679
99315
  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));
99680
99316
  if (packageId) {
99681
99317
  var packageIdKey = ts.packageIdToString(packageId);
@@ -99701,6 +99337,7 @@ var ts;
99701
99337
  file.path = path;
99702
99338
  file.resolvedPath = toPath(fileName);
99703
99339
  file.originalFileName = originalFileName;
99340
+ file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
99704
99341
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
99705
99342
  addFileIncludeReason(file, reason);
99706
99343
  if (host.useCaseSensitiveFileNames()) {
@@ -99817,40 +99454,33 @@ var ts;
99817
99454
  }
99818
99455
  function processTypeReferenceDirectives(file) {
99819
99456
  var typeDirectives = file.typeReferenceDirectives;
99820
- if (!typeDirectives.length) {
99821
- file.resolvedTypeReferenceDirectiveNames = undefined;
99457
+ if (!typeDirectives) {
99822
99458
  return;
99823
99459
  }
99824
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
99460
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
99825
99461
  for (var index = 0; index < typeDirectives.length; index++) {
99826
99462
  var ref = file.typeReferenceDirectives[index];
99827
99463
  var resolvedTypeReferenceDirective = resolutions[index];
99828
99464
  var fileName = ts.toFileNameLowerCase(ref.fileName);
99829
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
99465
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
99830
99466
  var mode = ref.resolutionMode || file.impliedNodeFormat;
99831
99467
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
99832
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99833
- kind: 2,
99834
- diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
99835
- });
99468
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99836
99469
  }
99837
99470
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
99838
99471
  }
99839
99472
  }
99840
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99841
- 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 });
99842
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99473
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99474
+ 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 });
99475
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99843
99476
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99844
99477
  }
99845
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99846
- var _a;
99847
- addResolutionDiagnostics(resolution);
99848
- var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
99478
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99479
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99849
99480
  if (previousResolution && previousResolution.primary) {
99850
99481
  return;
99851
99482
  }
99852
99483
  var saveResolution = true;
99853
- var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
99854
99484
  if (resolvedTypeReferenceDirective) {
99855
99485
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99856
99486
  currentNodeModulesDepth++;
@@ -99879,7 +99509,7 @@ var ts;
99879
99509
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99880
99510
  }
99881
99511
  if (saveResolution) {
99882
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99512
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99883
99513
  }
99884
99514
  }
99885
99515
  function pathForLibFile(libFileName) {
@@ -99908,7 +99538,7 @@ var ts;
99908
99538
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
99909
99539
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
99910
99540
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
99911
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99541
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99912
99542
  kind: 0,
99913
99543
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
99914
99544
  diagnostic: diagnostic,
@@ -99931,20 +99561,19 @@ var ts;
99931
99561
  for (var index = 0; index < moduleNames.length; index++) {
99932
99562
  var resolution = resolutions[index];
99933
99563
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
99934
- addResolutionDiagnostics(resolution);
99935
- if (!resolution.resolvedModule) {
99564
+ if (!resolution) {
99936
99565
  continue;
99937
99566
  }
99938
- var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
99939
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
99567
+ var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
99568
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
99940
99569
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
99941
- var resolvedFileName = resolution.resolvedModule.resolvedFileName;
99570
+ var resolvedFileName = resolution.resolvedFileName;
99942
99571
  if (isFromNodeModulesSearch) {
99943
99572
  currentNodeModulesDepth++;
99944
99573
  }
99945
99574
  var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
99946
99575
  var shouldAddFile = resolvedFileName
99947
- && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
99576
+ && !getResolutionDiagnostic(optionsForFile, resolution)
99948
99577
  && !optionsForFile.noResolve
99949
99578
  && index < file.imports.length
99950
99579
  && !elideImport
@@ -99954,7 +99583,7 @@ var ts;
99954
99583
  modulesWithElidedImports.set(file.path, true);
99955
99584
  }
99956
99585
  else if (shouldAddFile) {
99957
- findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
99586
+ findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
99958
99587
  }
99959
99588
  if (isFromNodeModulesSearch) {
99960
99589
  currentNodeModulesDepth--;
@@ -100304,7 +99933,7 @@ var ts;
100304
99933
  }
100305
99934
  }
100306
99935
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
100307
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99936
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
100308
99937
  kind: 1,
100309
99938
  file: file && file.path,
100310
99939
  fileProcessingReason: fileProcessingReason,
@@ -100565,8 +100194,8 @@ var ts;
100565
100194
  if (!symlinks) {
100566
100195
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
100567
100196
  }
100568
- if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100569
- symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
100197
+ if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
100198
+ symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100570
100199
  }
100571
100200
  return symlinks;
100572
100201
  }
@@ -100925,8 +100554,7 @@ var ts;
100925
100554
  }
100926
100555
  }
100927
100556
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100928
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
100929
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
100557
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
100930
100558
  if (!resolvedTypeReferenceDirective) {
100931
100559
  return;
100932
100560
  }
@@ -100975,13 +100603,12 @@ var ts;
100975
100603
  return oldState && !oldState.referencedMap === !newReferencedMap;
100976
100604
  }
100977
100605
  BuilderState.canReuseOldState = canReuseOldState;
100978
- function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100606
+ function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100979
100607
  var _a, _b, _c;
100980
100608
  var fileInfos = new ts.Map();
100981
100609
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
100982
100610
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
100983
100611
  var useOldState = canReuseOldState(referencedMap, oldState);
100984
- var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100985
100612
  newProgram.getTypeChecker();
100986
100613
  for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
100987
100614
  var sourceFile = _d[_i];
@@ -101025,23 +100652,23 @@ var ts;
101025
100652
  state.allFileNames = undefined;
101026
100653
  }
101027
100654
  BuilderState.releaseCache = releaseCache;
101028
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100655
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
101029
100656
  var _a, _b;
101030
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
100657
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
101031
100658
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
101032
100659
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
101033
100660
  return result;
101034
100661
  }
101035
100662
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
101036
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100663
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
101037
100664
  var sourceFile = programOfThisState.getSourceFileByPath(path);
101038
100665
  if (!sourceFile) {
101039
100666
  return ts.emptyArray;
101040
100667
  }
101041
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100668
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
101042
100669
  return [sourceFile];
101043
100670
  }
101044
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100671
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
101045
100672
  }
101046
100673
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
101047
100674
  function updateSignatureOfFile(state, signature, path) {
@@ -101049,7 +100676,7 @@ var ts;
101049
100676
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
101050
100677
  }
101051
100678
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
101052
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
100679
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
101053
100680
  var _a;
101054
100681
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
101055
100682
  if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
@@ -101060,7 +100687,7 @@ var ts;
101060
100687
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
101061
100688
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
101062
100689
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
101063
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
100690
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
101064
100691
  if (latestSignature !== prevSignature) {
101065
100692
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
101066
100693
  }
@@ -101194,7 +100821,7 @@ var ts;
101194
100821
  }
101195
100822
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
101196
100823
  }
101197
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100824
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
101198
100825
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
101199
100826
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
101200
100827
  }
@@ -101210,7 +100837,7 @@ var ts;
101210
100837
  if (!seenFileNamesMap.has(currentPath)) {
101211
100838
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
101212
100839
  seenFileNamesMap.set(currentPath, currentSourceFile);
101213
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100840
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
101214
100841
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
101215
100842
  }
101216
100843
  }
@@ -101224,9 +100851,9 @@ var ts;
101224
100851
  function hasSameKeys(map1, map2) {
101225
100852
  return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
101226
100853
  }
101227
- function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100854
+ function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
101228
100855
  var _a, _b;
101229
- var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100856
+ var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
101230
100857
  state.program = newProgram;
101231
100858
  var compilerOptions = newProgram.getCompilerOptions();
101232
100859
  state.compilerOptions = compilerOptions;
@@ -101279,7 +100906,7 @@ var ts;
101279
100906
  return;
101280
100907
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
101281
100908
  if (diagnostics) {
101282
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100909
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
101283
100910
  if (!state.semanticDiagnosticsFromOldState) {
101284
100911
  state.semanticDiagnosticsFromOldState = new ts.Set();
101285
100912
  }
@@ -101301,16 +100928,13 @@ var ts;
101301
100928
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
101302
100929
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
101303
100930
  }
101304
- state.buildInfoEmitPending = !useOldState ||
101305
- state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
101306
- state.fileInfos.size !== oldState.fileInfos.size;
100931
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
101307
100932
  return state;
101308
100933
  }
101309
- function convertToDiagnostics(diagnostics, newProgram) {
100934
+ function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
101310
100935
  if (!diagnostics.length)
101311
100936
  return ts.emptyArray;
101312
- var buildInfoDirectory;
101313
- var getCanonicalFileName;
100937
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
101314
100938
  return diagnostics.map(function (diagnostic) {
101315
100939
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
101316
100940
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -101326,8 +100950,7 @@ var ts;
101326
100950
  return result;
101327
100951
  });
101328
100952
  function toPath(path) {
101329
- buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
101330
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
100953
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101331
100954
  }
101332
100955
  }
101333
100956
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -101336,8 +100959,6 @@ var ts;
101336
100959
  }
101337
100960
  function releaseCache(state) {
101338
100961
  ts.BuilderState.releaseCache(state);
101339
- if (!state.resuableCacheResolutions)
101340
- getCacheResolutions(state);
101341
100962
  state.program = undefined;
101342
100963
  }
101343
100964
  function backupBuilderProgramEmitState(state) {
@@ -101372,7 +100993,7 @@ var ts;
101372
100993
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
101373
100994
  ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
101374
100995
  }
101375
- function getNextAffectedFile(state, cancellationToken, host) {
100996
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
101376
100997
  var _a, _b;
101377
100998
  while (true) {
101378
100999
  var affectedFiles = state.affectedFiles;
@@ -101383,7 +101004,7 @@ var ts;
101383
101004
  var affectedFile = affectedFiles[affectedFilesIndex];
101384
101005
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
101385
101006
  state.affectedFilesIndex = affectedFilesIndex;
101386
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
101007
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101387
101008
  return affectedFile;
101388
101009
  }
101389
101010
  affectedFilesIndex++;
@@ -101404,7 +101025,7 @@ var ts;
101404
101025
  ts.Debug.assert(!state.semanticDiagnosticsPerFile);
101405
101026
  return program;
101406
101027
  }
101407
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
101028
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
101408
101029
  state.currentChangedFilePath = nextKey.value;
101409
101030
  state.affectedFilesIndex = 0;
101410
101031
  if (!state.seenAffectedFiles)
@@ -101447,24 +101068,24 @@ var ts;
101447
101068
  });
101448
101069
  }
101449
101070
  }
101450
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
101071
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101451
101072
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
101452
101073
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
101453
101074
  removeDiagnosticsOfLibraryFiles(state);
101454
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
101075
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
101455
101076
  return;
101456
101077
  }
101457
101078
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
101458
101079
  return;
101459
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
101080
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
101460
101081
  }
101461
- function handleDtsMayChangeOf(state, path, cancellationToken, host) {
101082
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
101462
101083
  removeSemanticDiagnosticsOf(state, path);
101463
101084
  if (!state.changedFilesSet.has(path)) {
101464
101085
  var program = ts.Debug.checkDefined(state.program);
101465
101086
  var sourceFile = program.getSourceFileByPath(path);
101466
101087
  if (sourceFile) {
101467
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
101088
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
101468
101089
  if (ts.getEmitDeclarations(state.compilerOptions)) {
101469
101090
  addToAffectedFilesPendingEmit(state, path, 0);
101470
101091
  }
@@ -101484,16 +101105,16 @@ var ts;
101484
101105
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
101485
101106
  return newSignature !== oldSignature;
101486
101107
  }
101487
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
101108
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
101488
101109
  var _a;
101489
101110
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
101490
101111
  return false;
101491
101112
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
101492
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
101113
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
101493
101114
  removeDiagnosticsOfLibraryFiles(state);
101494
101115
  return true;
101495
101116
  }
101496
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
101117
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101497
101118
  var _a;
101498
101119
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
101499
101120
  return;
@@ -101507,9 +101128,9 @@ var ts;
101507
101128
  var currentPath = queue.pop();
101508
101129
  if (!seenFileNamesMap.has(currentPath)) {
101509
101130
  seenFileNamesMap.set(currentPath, true);
101510
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
101131
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101511
101132
  return;
101512
- handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
101133
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101513
101134
  if (isChangedSignature(state, currentPath)) {
101514
101135
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
101515
101136
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -101519,27 +101140,27 @@ var ts;
101519
101140
  }
101520
101141
  var seenFileAndExportsOfFile = new ts.Set();
101521
101142
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
101522
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
101143
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101523
101144
  return true;
101524
101145
  var references = state.referencedMap.getKeys(exportedFromPath);
101525
101146
  return references && ts.forEachKey(references, function (filePath) {
101526
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
101147
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101527
101148
  });
101528
101149
  });
101529
101150
  }
101530
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
101151
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101531
101152
  var _a, _b;
101532
101153
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
101533
101154
  return undefined;
101534
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
101155
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101535
101156
  return true;
101536
- handleDtsMayChangeOf(state, filePath, cancellationToken, host);
101157
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101537
101158
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
101538
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
101159
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101539
101160
  });
101540
101161
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
101541
101162
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
101542
- handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, host);
101163
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
101543
101164
  });
101544
101165
  return undefined;
101545
101166
  }
@@ -101594,51 +101215,40 @@ var ts;
101594
101215
  return !!ts.outFile(info.options || {});
101595
101216
  }
101596
101217
  ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
101597
- function getProgramBuildInfo(state, host) {
101598
- if (ts.outFile(state.compilerOptions) && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
101218
+ function getProgramBuildInfo(state, getCanonicalFileName) {
101219
+ if (ts.outFile(state.compilerOptions) && !state.compilerOptions.composite)
101599
101220
  return;
101600
101221
  ts.performance.mark("beforeGetProgramBuildInfo");
101601
- var result = getProgramBuildInfoWorker(state, host);
101222
+ var result = getProgramBuildInfoWorker(state, getCanonicalFileName);
101602
101223
  ts.performance.mark("afterGetProgramBuildInfo");
101603
101224
  ts.performance.measure("BuildInfo generation", "beforeGetProgramBuildInfo", "afterGetProgramBuildInfo");
101604
101225
  return result;
101605
101226
  }
101606
- function getProgramBuildInfoWorker(state, host) {
101227
+ function getProgramBuildInfoWorker(state, getCanonicalFileName) {
101607
101228
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
101608
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101609
- var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
101610
- var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
101229
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101611
101230
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
101612
- var fileNames = [];
101613
- var fileNameToFileId = new ts.Map();
101614
- var resolutions;
101615
- var names;
101616
- var resolutionNameToResolutionNameId;
101617
- var resolutionEntries;
101618
- var resolutionEntryToResolutionEntryId;
101619
- var affectedFilesHash;
101620
101231
  if (ts.outFile(state.compilerOptions)) {
101621
- var fileInfos_1;
101622
- if (state.compilerOptions.composite) {
101623
- state.program.getRootFileNames().forEach(function (f) {
101624
- var sourceFile = state.program.getSourceFile(f);
101625
- if (!sourceFile)
101626
- return;
101627
- var fileId = toFileId(sourceFile.resolvedPath);
101628
- (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
101629
- });
101630
- }
101631
- var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
101632
- var result_16 = {
101633
- fileNames: fileNames,
101232
+ var fileNames_1 = [];
101233
+ var fileInfos_1 = [];
101234
+ state.program.getRootFileNames().forEach(function (f) {
101235
+ var sourceFile = state.program.getSourceFile(f);
101236
+ if (!sourceFile)
101237
+ return;
101238
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
101239
+ fileInfos_1.push(sourceFile.version);
101240
+ });
101241
+ var result_15 = {
101242
+ fileNames: fileNames_1,
101634
101243
  fileInfos: fileInfos_1,
101635
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101244
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
101636
101245
  outSignature: state.outSignature,
101637
101246
  latestChangedDtsFile: latestChangedDtsFile,
101638
- cacheResolutions: cacheResolutions_1,
101639
101247
  };
101640
- return result_16;
101248
+ return result_15;
101641
101249
  }
101250
+ var fileNames = [];
101251
+ var fileNameToFileId = new ts.Map();
101642
101252
  var fileIdsList;
101643
101253
  var fileNamesToFileIdListId;
101644
101254
  var emitSignatures;
@@ -101695,7 +101305,7 @@ var ts;
101695
101305
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
101696
101306
  [
101697
101307
  toFileId(key),
101698
- value.map(toReusableDiagnostic)
101308
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
101699
101309
  ] :
101700
101310
  toFileId(key));
101701
101311
  }
@@ -101717,11 +101327,10 @@ var ts;
101717
101327
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
101718
101328
  }
101719
101329
  }
101720
- var cacheResolutions = toProgramBuildInfoCacheResolutions();
101721
101330
  var result = {
101722
101331
  fileNames: fileNames,
101723
101332
  fileInfos: fileInfos,
101724
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
101333
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
101725
101334
  fileIdsList: fileIdsList,
101726
101335
  referencedMap: referencedMap,
101727
101336
  exportedModulesMap: exportedModulesMap,
@@ -101730,7 +101339,6 @@ var ts;
101730
101339
  changeFileSet: changeFileSet,
101731
101340
  emitSignatures: emitSignatures,
101732
101341
  latestChangedDtsFile: latestChangedDtsFile,
101733
- cacheResolutions: cacheResolutions,
101734
101342
  };
101735
101343
  return result;
101736
101344
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -101739,7 +101347,7 @@ var ts;
101739
101347
  function relativeToBuildInfo(path) {
101740
101348
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
101741
101349
  }
101742
- function toFileAndAbsoluteFileId(path) {
101350
+ function toFileId(path) {
101743
101351
  var fileId = fileNameToFileId.get(path);
101744
101352
  if (fileId === undefined) {
101745
101353
  fileNames.push(relativeToBuildInfo(path));
@@ -101747,12 +101355,6 @@ var ts;
101747
101355
  }
101748
101356
  return fileId;
101749
101357
  }
101750
- function toFileId(path) {
101751
- return toFileAndAbsoluteFileId(path);
101752
- }
101753
- function toAbsoluteFileId(path) {
101754
- return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
101755
- }
101756
101358
  function toFileIdListId(set) {
101757
101359
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
101758
101360
  var key = fileIds.join();
@@ -101763,232 +101365,53 @@ var ts;
101763
101365
  }
101764
101366
  return fileIdListId;
101765
101367
  }
101766
- function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
101368
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
101767
101369
  var result;
101768
101370
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
101769
101371
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
101770
101372
  var name = _a[_i];
101771
101373
  var optionInfo = optionsNameMap.get(name.toLowerCase());
101772
- if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
101773
- (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
101774
- }
101775
- else if (affectsModuleResolution && name === "pathsBasePath") {
101776
- (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
101777
- continue;
101374
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
101375
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
101778
101376
  }
101779
101377
  }
101780
101378
  return result;
101781
101379
  }
101782
- function toReusableCompilerOptionValue(option, value) {
101783
- if (option) {
101784
- if (option.type === "list") {
101785
- var values = value;
101786
- if (option.element.isFilePath && values.length) {
101787
- return values.map(relativeToBuildInfoEnsuringAbsolutePath);
101788
- }
101789
- }
101790
- else if (option.isFilePath) {
101791
- return relativeToBuildInfoEnsuringAbsolutePath(value);
101380
+ }
101381
+ function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
101382
+ if (option) {
101383
+ if (option.type === "list") {
101384
+ var values = value;
101385
+ if (option.element.isFilePath && values.length) {
101386
+ return values.map(relativeToBuildInfo);
101792
101387
  }
101793
101388
  }
101794
- return value;
101795
- }
101796
- function toReadonlyArrayOrUndefined(array, map) {
101797
- return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
101389
+ else if (option.isFilePath) {
101390
+ return relativeToBuildInfo(value);
101391
+ }
101798
101392
  }
101799
- function toReusableDiagnostic(diagnostic) {
101800
- var result = toReusableDiagnosticRelatedInformation(diagnostic);
101393
+ return value;
101394
+ }
101395
+ function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
101396
+ ts.Debug.assert(!!diagnostics.length);
101397
+ return diagnostics.map(function (diagnostic) {
101398
+ var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
101801
101399
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
101802
101400
  result.reportDeprecated = diagnostic.reportsDeprecated;
101803
101401
  result.source = diagnostic.source;
101804
101402
  result.skippedOn = diagnostic.skippedOn;
101805
101403
  var relatedInformation = diagnostic.relatedInformation;
101806
- result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
101807
- return result;
101808
- }
101809
- function toReusableDiagnosticRelatedInformation(diagnostic) {
101810
- var file = diagnostic.file;
101811
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101812
- }
101813
- function toProgramBuildInfoCacheResolutions() {
101814
- var cacheResolutions = getCacheResolutions(state);
101815
- var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
101816
- var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
101817
- var packageJsons = toProgramBuildInfoPackageJsons(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.perDirPackageJsonMap);
101818
- if (!resolutions)
101819
- return;
101820
- ts.Debug.assertIsDefined(names);
101821
- ts.Debug.assertIsDefined(resolutionEntries);
101822
- state.resuableCacheResolutions = {
101823
- cache: {
101824
- resolutions: resolutions.map(toProgramBuildInfoResolution),
101825
- names: names,
101826
- hash: toProgramBuildInfoHashes(),
101827
- resolutionEntries: resolutionEntries,
101828
- modules: modules,
101829
- typeRefs: typeRefs,
101830
- packageJsons: packageJsons,
101831
- },
101832
- getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
101833
- };
101834
- return state.resuableCacheResolutions.cache;
101835
- }
101836
- function toProgramBuildInfoPackageJsons(cache) {
101837
- var result;
101838
- cache === null || cache === void 0 ? void 0 : cache.forEach(function (packageJson, dirPath) {
101839
- var packageJsonDirPath = ts.getDirectoryPath(ts.toPath(packageJson, currentDirectory, getCanonicalFileName));
101840
- if (packageJsonDirPath !== dirPath) {
101841
- (result !== null && result !== void 0 ? result : (result = [])).push([
101842
- toFileId(dirPath),
101843
- toAbsoluteFileId(packageJson),
101844
- ]);
101845
- }
101846
- });
101847
- return result;
101848
- }
101849
- function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
101850
- if (!cache)
101851
- return undefined;
101852
- var ownMap = cache.getOwnMap();
101853
- var own = toProgramBuildInfoResolutionCache(ownMap);
101854
- var redirects;
101855
- cache.redirectsKeyToCache.forEach(function (_a) {
101856
- var map = _a.map, options = _a.options;
101857
- if (map === ownMap)
101858
- return;
101859
- var redirectCache = toProgramBuildInfoResolutionCache(map);
101860
- if (redirectCache) {
101861
- (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
101862
- options: toProgramBuildInfoCompilerOptions(options, undefined, true),
101863
- cache: redirectCache
101864
- });
101865
- }
101866
- });
101867
- return !redirects ? own : { own: own, redirects: redirects };
101868
- }
101869
- function toProgramBuildInfoResolutionCache(cache) {
101870
- var result;
101871
- cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
101872
- (result !== null && result !== void 0 ? result : (result = [])).push([
101873
- toFileId(dirPath),
101874
- ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
101875
- ]) :
101876
- undefined; });
101404
+ result.relatedInformation = relatedInformation ?
101405
+ relatedInformation.length ?
101406
+ relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
101407
+ [] :
101408
+ undefined;
101877
101409
  return result;
101878
- }
101879
- function toProgramBuildInfoResolutionEntryId(_a) {
101880
- var name = _a[0], mode = _a[1], resolution = _a[2];
101881
- var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
101882
- var resolutionId = toProgramBuildInfoResolutionId(resolution);
101883
- var key = resolutionNameId + "," + mode + "," + resolutionId;
101884
- var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
101885
- if (resolutionEntryId === undefined) {
101886
- (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
101887
- (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
101888
- }
101889
- return resolutionEntryId;
101890
- }
101891
- function toProgramBuildInfoResolutionNameId(name) {
101892
- var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
101893
- if (resolutionNameId === undefined) {
101894
- (names !== null && names !== void 0 ? names : (names = [])).push(name);
101895
- (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
101896
- }
101897
- return resolutionNameId;
101898
- }
101899
- function toProgramBuildInfoResolutionId(resolution) {
101900
- if (resolution.serializationIndex === undefined) {
101901
- (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
101902
- resolution.serializationIndex = resolutions.length;
101903
- }
101904
- return resolution.serializationIndex;
101905
- }
101906
- function toProgramBuildInfoResolution(resolution) {
101907
- resolution.serializationIndex = undefined;
101908
- return {
101909
- resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
101910
- resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
101911
- affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
101912
- resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
101913
- };
101914
- }
101915
- function toProgramBuildInfoHashes() {
101916
- if (!affectedFilesHash)
101917
- return undefined;
101918
- var hashes = [];
101919
- for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
101920
- var key = _a[_i];
101921
- var value = affectedFilesHash.get(key);
101922
- hashes.push(value ? [key, value] : key);
101923
- }
101924
- return hashes;
101925
- }
101926
- function toAffectedFileId(file) {
101927
- var _a;
101928
- var fileId = toAbsoluteFileId(file);
101929
- if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
101930
- var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
101931
- var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101932
- (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
101933
- }
101934
- return fileId;
101935
- }
101936
- function toProgramBuildInfoResolved(resolved) {
101937
- 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;
101938
- }
101939
- function toProgramBuildInfoResolutionDiagnostic(d) {
101940
- return {
101941
- isImports: d.isImports || undefined,
101942
- entry: d.entry || undefined,
101943
- packagePath: toAbsoluteFileId(d.packagePath),
101944
- };
101945
- }
101946
- }
101947
- function getCacheResolutions(state) {
101948
- var _a;
101949
- if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
101950
- return state.cacheResolutions;
101951
- var modules;
101952
- var typeRefs;
101953
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
101954
- var dirToPackageJsonScope = new ts.Map();
101955
- var perDirPackageJsonMap;
101956
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101957
- state.program.getSourceFiles().forEach(function (f) {
101958
- var _a;
101959
- modules = toPerDirectoryCache(state, getCanonicalFileName, modules, ts.getResolvedModuleOfResolution, f, f.resolvedModules, moduleNameToDirectoryMap);
101960
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, f, f.resolvedTypeReferenceDirectiveNames);
101961
- if ((_a = f.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
101962
- var dirPath = ts.getDirectoryPath(f.resolvedPath);
101963
- if (!(dirToPackageJsonScope === null || dirToPackageJsonScope === void 0 ? void 0 : dirToPackageJsonScope.has(dirPath))) {
101964
- (perDirPackageJsonMap !== null && perDirPackageJsonMap !== void 0 ? perDirPackageJsonMap : (perDirPackageJsonMap = new ts.Map())).set(dirPath, ts.getPackageJsconLocationFromScope(f.packageJsonScope));
101965
- 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); });
101966
- }
101967
- }
101968
101410
  });
101969
- var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
101970
- if (automaticTypeDirectiveNames.length) {
101971
- var currentDirectory = state.program.getCurrentDirectory();
101972
- var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
101973
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, ts.getResolvedTypeReferenceDirectiveOfResolution, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
101974
- }
101975
- return state.cacheResolutions = {
101976
- modules: modules,
101977
- typeRefs: typeRefs,
101978
- moduleNameToDirectoryMap: moduleNameToDirectoryMap,
101979
- dirToPackageJsonScope: dirToPackageJsonScope,
101980
- perDirPackageJsonMap: perDirPackageJsonMap,
101981
- packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
101982
- };
101983
101411
  }
101984
- function toPerDirectoryCache(state, getCanonicalFileName, perDirCache, getResolutionWithResolvedFileName, sourceFileOrPath, fileCacheFromProgram, moduleNameToDirectoryMap) {
101985
- return ts.toPerDirectoryResolution(state.program, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, ts.noop, function (r, name, mode, _key, redirectedReference, dirPath) {
101986
- var _a, _b, _c;
101987
- return !((_a = getResolutionWithResolvedFileName(r)) === null || _a === void 0 ? void 0 : _a.resolvedFileName) ||
101988
- (moduleNameToDirectoryMap &&
101989
- !ts.isExternalModuleNameRelative(name) &&
101990
- ((_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)));
101991
- }, 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); });
101412
+ function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
101413
+ var file = diagnostic.file;
101414
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101992
101415
  }
101993
101416
  var BuilderProgramKind;
101994
101417
  (function (BuilderProgramKind) {
@@ -102012,7 +101435,7 @@ var ts;
102012
101435
  rootNames: newProgramOrRootNames,
102013
101436
  options: hostOrOptions,
102014
101437
  host: oldProgramOrHost,
102015
- oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
101438
+ oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
102016
101439
  configFileParsingDiagnostics: configFileParsingDiagnostics,
102017
101440
  projectReferences: projectReferences
102018
101441
  });
@@ -102030,8 +101453,8 @@ var ts;
102030
101453
  function getTextHandlingSourceMapForSignature(text, data) {
102031
101454
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
102032
101455
  }
102033
- function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
102034
- var _a, _b;
101456
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
101457
+ var _a;
102035
101458
  text = getTextHandlingSourceMapForSignature(text, data);
102036
101459
  var sourceFileDirectory;
102037
101460
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -102039,7 +101462,7 @@ var ts;
102039
101462
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
102040
101463
  }).join("\n");
102041
101464
  }
102042
- return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
101465
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
102043
101466
  function flattenDiagnosticMessageText(diagnostic) {
102044
101467
  return ts.isString(diagnostic) ?
102045
101468
  diagnostic :
@@ -102058,9 +101481,8 @@ var ts;
102058
101481
  }
102059
101482
  }
102060
101483
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
102061
- function computeSignature(text, host, data) {
102062
- var _a;
102063
- return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101484
+ function computeSignature(text, computeHash, data) {
101485
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
102064
101486
  }
102065
101487
  ts.computeSignature = computeSignature;
102066
101488
  function createBuilderProgram(kind, _a) {
@@ -102071,8 +101493,10 @@ var ts;
102071
101493
  oldState = undefined;
102072
101494
  return oldProgram;
102073
101495
  }
102074
- var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
102075
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
101496
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101497
+ var computeHash = ts.maybeBind(host, host.createHash);
101498
+ var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101499
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
102076
101500
  newProgram = undefined;
102077
101501
  oldProgram = undefined;
102078
101502
  oldState = undefined;
@@ -102086,7 +101510,6 @@ var ts;
102086
101510
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
102087
101511
  builderProgram.emit = emit;
102088
101512
  builderProgram.releaseProgram = function () { return releaseCache(state); };
102089
- builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
102090
101513
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
102091
101514
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
102092
101515
  }
@@ -102108,7 +101531,7 @@ var ts;
102108
101531
  return ts.emitSkippedWithNoDiagnostics;
102109
101532
  }
102110
101533
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
102111
- var affected = getNextAffectedFile(state, cancellationToken, host);
101534
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
102112
101535
  var emitKind = 1;
102113
101536
  var isPendingEmitFile = false;
102114
101537
  if (!affected) {
@@ -102146,7 +101569,7 @@ var ts;
102146
101569
  var file = sourceFiles[0];
102147
101570
  var info = state.fileInfos.get(file.resolvedPath);
102148
101571
  if (info.signature === file.version) {
102149
- var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
101572
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
102150
101573
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
102151
101574
  emitSignature = signature;
102152
101575
  if (signature !== file.version) {
@@ -102170,7 +101593,7 @@ var ts;
102170
101593
  if (state.compilerOptions.composite) {
102171
101594
  var filePath = sourceFiles[0].resolvedPath;
102172
101595
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
102173
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
101596
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
102174
101597
  if (emitSignature === oldSignature)
102175
101598
  return;
102176
101599
  ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
@@ -102179,7 +101602,7 @@ var ts;
102179
101602
  }
102180
101603
  }
102181
101604
  else if (state.compilerOptions.composite) {
102182
- var newSignature = computeSignature(text, host, data);
101605
+ var newSignature = computeSignature(text, computeHash, data);
102183
101606
  if (newSignature === state.outSignature)
102184
101607
  return;
102185
101608
  state.outSignature = newSignature;
@@ -102240,7 +101663,7 @@ var ts;
102240
101663
  }
102241
101664
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
102242
101665
  while (true) {
102243
- var affected = getNextAffectedFile(state, cancellationToken, host);
101666
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
102244
101667
  if (!affected) {
102245
101668
  return undefined;
102246
101669
  }
@@ -102298,32 +101721,12 @@ var ts;
102298
101721
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
102299
101722
  }
102300
101723
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
102301
- function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
102302
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
102303
- var filePaths;
102304
- var fileAbsolutePaths;
102305
- return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
102306
- function toPath(path) {
102307
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
102308
- }
102309
- function toAbsolutePath(path) {
102310
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
102311
- }
102312
- function toFilePath(fileId) {
102313
- var _a;
102314
- 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]));
102315
- }
102316
- function toFileAbsolutePath(fileId) {
102317
- var _a;
102318
- 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]));
102319
- }
102320
- }
102321
- ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
102322
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
102323
- var _a, _b, _c;
102324
- var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
102325
- var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
101724
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
101725
+ var _a, _b, _c, _d;
101726
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101727
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
102326
101728
  var state;
101729
+ var filePaths;
102327
101730
  var filePathsSetList;
102328
101731
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
102329
101732
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -102332,13 +101735,13 @@ var ts;
102332
101735
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
102333
101736
  latestChangedDtsFile: latestChangedDtsFile,
102334
101737
  outSignature: program.outSignature,
102335
- resuableCacheResolutions: toResuableCacheResolutions(),
102336
101738
  };
102337
101739
  }
102338
101740
  else {
102339
- filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101741
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
101742
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
102340
101743
  var fileInfos_2 = new ts.Map();
102341
- var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101744
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
102342
101745
  program.fileInfos.forEach(function (fileInfo, index) {
102343
101746
  var path = toFilePath(index + 1);
102344
101747
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -102346,7 +101749,7 @@ var ts;
102346
101749
  if (emitSignatures_1 && stateFileInfo.signature)
102347
101750
  emitSignatures_1.set(path, stateFileInfo.signature);
102348
101751
  });
102349
- (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
101752
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
102350
101753
  if (ts.isNumber(value))
102351
101754
  emitSignatures_1.delete(toFilePath(value));
102352
101755
  else
@@ -102365,17 +101768,14 @@ var ts;
102365
101768
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
102366
101769
  latestChangedDtsFile: latestChangedDtsFile,
102367
101770
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
102368
- resuableCacheResolutions: toResuableCacheResolutions(),
102369
101771
  };
102370
101772
  }
102371
- state.compilerOptions.configFilePath = configFilePath;
102372
101773
  return {
102373
101774
  getState: function () { return state; },
102374
101775
  saveEmitState: ts.noop,
102375
101776
  restoreEmitState: ts.noop,
102376
101777
  getProgram: ts.notImplemented,
102377
101778
  getProgramOrUndefined: ts.returnUndefined,
102378
- getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
102379
101779
  releaseProgram: ts.noop,
102380
101780
  getCompilerOptions: function () { return state.compilerOptions; },
102381
101781
  getSourceFile: ts.notImplemented,
@@ -102395,6 +101795,15 @@ var ts;
102395
101795
  close: ts.noop,
102396
101796
  hasChangedEmitSignature: ts.returnFalse,
102397
101797
  };
101798
+ function toPath(path) {
101799
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101800
+ }
101801
+ function toAbsolutePath(path) {
101802
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101803
+ }
101804
+ function toFilePath(fileId) {
101805
+ return filePaths[fileId - 1];
101806
+ }
102398
101807
  function toFilePathsSet(fileIdsListId) {
102399
101808
  return filePathsSetList[fileIdsListId - 1];
102400
101809
  }
@@ -102409,241 +101818,8 @@ var ts;
102409
101818
  });
102410
101819
  return map;
102411
101820
  }
102412
- function toResuableCacheResolutions() {
102413
- return program.cacheResolutions && {
102414
- cache: program.cacheResolutions,
102415
- getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
102416
- };
102417
- }
102418
101821
  }
102419
101822
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
102420
- function createGetProgramOrOldBuildInfoProgramUndefined(state) {
102421
- return function () {
102422
- var _a;
102423
- return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
102424
- (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions, !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
102425
- undefined);
102426
- };
102427
- }
102428
- function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
102429
- if (!cacheResolutions && !resuableCacheResolutions)
102430
- return undefined;
102431
- var fileExistsMap = new ts.Map();
102432
- var packageJsonInfoMap = new ts.Map();
102433
- var affectingLoationsSameMap = new ts.Map();
102434
- var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
102435
- var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
102436
- var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
102437
- var decodedPackageJsonMap;
102438
- var packageJsonScopes;
102439
- var decodedHashes;
102440
- var resolutions;
102441
- var originalPathOrResolvedFileNames;
102442
- var resolutionEntries;
102443
- return {
102444
- getCompilerOptions: function () { return compilerOptions; },
102445
- 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); },
102446
- 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); },
102447
- getPackageJsonScope: getPackageJsonScope,
102448
- };
102449
- function fileExists(fileName) {
102450
- var result = fileExistsMap.get(fileName);
102451
- if (result === undefined)
102452
- fileExistsMap.set(fileName, result = host.fileExists(fileName));
102453
- return result;
102454
- }
102455
- function getPackageJsonInfo(fileName) {
102456
- var result = packageJsonInfoMap.get(fileName);
102457
- if (result === undefined)
102458
- packageJsonInfoMap.set(fileName, result = host.getPackageJsonInfo(fileName) || false);
102459
- return result || undefined;
102460
- }
102461
- function affectingLocationsSame(fileName, expected) {
102462
- var _a;
102463
- var result = affectingLoationsSameMap.get(fileName);
102464
- if (result !== undefined)
102465
- return result;
102466
- var packageJsonInfo = getPackageJsonInfo(fileName);
102467
- var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
102468
- if (ts.isString(expected)) {
102469
- result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
102470
- }
102471
- else {
102472
- var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
102473
- result = currentText === expectedText;
102474
- }
102475
- affectingLoationsSameMap.set(fileName, result);
102476
- return result;
102477
- }
102478
- function getPackageJsonScope(dirPath) {
102479
- var _a;
102480
- var fromCache = (_a = cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.dirToPackageJsonScope) === null || _a === void 0 ? void 0 : _a.get(dirPath);
102481
- if (fromCache) {
102482
- var packageJson = ts.getPackageJsconLocationFromScope(fromCache);
102483
- var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(packageJson);
102484
- if (result === undefined) {
102485
- (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map())).set(packageJson, result = affectingLocationsSame(packageJson, fromCache.info) ?
102486
- fromCache :
102487
- fileExists(packageJson) ?
102488
- { info: getPackageJsonInfo(packageJson), affectingLocations: [packageJson] } :
102489
- false);
102490
- }
102491
- return result || undefined;
102492
- }
102493
- if (!(resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.packageJsons))
102494
- return;
102495
- if (!decodedPackageJsonMap) {
102496
- decodedPackageJsonMap = new ts.Map();
102497
- var filePathDecoder_1 = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder();
102498
- for (var _i = 0, _b = resuableCacheResolutions.cache.packageJsons; _i < _b.length; _i++) {
102499
- var dirIdOrDirAndPackageJson = _b[_i];
102500
- var dirPath_1 = filePathDecoder_1.toFilePath(dirIdOrDirAndPackageJson[0]);
102501
- var packageJson = filePathDecoder_1.toFileAbsolutePath(dirIdOrDirAndPackageJson[1]);
102502
- ts.moduleNameToDirectorySet(decodedPackageJsonMap, dirPath_1, packageJson, ts.identity, function (fileName) { return ts.toPath(fileName, filePathDecoder_1.currentDirectory, filePathDecoder_1.getCanonicalFileName); }, ts.noop);
102503
- }
102504
- }
102505
- return toPackageJsonScope(decodedPackageJsonMap.get(dirPath));
102506
- }
102507
- function toPackageJsonScope(file) {
102508
- if (!file)
102509
- return undefined;
102510
- var result = packageJsonScopes === null || packageJsonScopes === void 0 ? void 0 : packageJsonScopes.get(file);
102511
- if (result !== undefined)
102512
- return result || undefined;
102513
- (packageJsonScopes !== null && packageJsonScopes !== void 0 ? packageJsonScopes : (packageJsonScopes = new ts.Map()));
102514
- if (fileExists(file)) {
102515
- result = {
102516
- info: getPackageJsonInfo(file),
102517
- affectingLocations: [file]
102518
- };
102519
- }
102520
- packageJsonScopes.set(file, result || false);
102521
- return result;
102522
- }
102523
- function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
102524
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
102525
- 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)) ||
102526
- ((_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));
102527
- if (fromCache) {
102528
- return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
102529
- 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;
102530
- }
102531
- if (!reusableCache)
102532
- return undefined;
102533
- if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
102534
- if (ts.isArray(reusableCache)) {
102535
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache, decodedModuleNameToDirectoryMap);
102536
- }
102537
- else {
102538
- if (reusableCache.own)
102539
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
102540
- reusableCache.redirects.forEach(function (_a) {
102541
- var options = _a.options, cache = _a.cache;
102542
- var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
102543
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
102544
- });
102545
- }
102546
- decodedReusableCache.clearRedirectsMap();
102547
- decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
102548
- }
102549
- 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)) ||
102550
- ((_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));
102551
- return resolutionId ? toResolution(resolutionId) : undefined;
102552
- }
102553
- function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
102554
- var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
102555
- reusableCache.forEach(function (_a) {
102556
- var dirId = _a[0], entryId = _a[1];
102557
- var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
102558
- map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
102559
- });
102560
- }
102561
- function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
102562
- var modeAwareCache = ts.createModeAwareCache();
102563
- entries.forEach(function (entryId) {
102564
- var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
102565
- modeAwareCache.set(name, mode, resolutionId);
102566
- if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102567
- return;
102568
- var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
102569
- var key = ts.getModeAwareCacheKey(name, mode);
102570
- var moduleNameMap = mapForOptions.get(key);
102571
- ;
102572
- if (!moduleNameMap)
102573
- mapForOptions.set(key, moduleNameMap = new ts.Map());
102574
- ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
102575
- });
102576
- return modeAwareCache;
102577
- }
102578
- function toResolutionEntry(entryId) {
102579
- var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
102580
- if (existing)
102581
- return existing;
102582
- resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
102583
- var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
102584
- return resolutionEntries[entryId - 1] = [
102585
- toName(nameId),
102586
- resolutionId,
102587
- mode
102588
- ];
102589
- }
102590
- function toName(nameId) {
102591
- return resuableCacheResolutions.cache.names[nameId - 1];
102592
- }
102593
- function toOriginalPathOrResolvedFileName(resolutionId) {
102594
- var _a;
102595
- 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 ||
102596
- resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
102597
- }
102598
- function toAffectingFileLocation(fileId) {
102599
- if (!decodedHashes && resuableCacheResolutions.cache.hash) {
102600
- decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
102601
- }
102602
- var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
102603
- var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
102604
- return affectingLocationsSame(file, hash) ? file : undefined;
102605
- }
102606
- function toResolution(resolutionId) {
102607
- var _a, _b;
102608
- var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
102609
- if (existing !== undefined)
102610
- return existing || undefined;
102611
- resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
102612
- var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
102613
- var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
102614
- var affectingLocations;
102615
- if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
102616
- var file = toAffectingFileLocation(fileId);
102617
- if (file)
102618
- (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
102619
- return !!file;
102620
- })) {
102621
- var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
102622
- return resolutions[resolutionId - 1] = {
102623
- resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
102624
- resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
102625
- failedLookupLocations: ts.emptyArray,
102626
- affectingLocations: affectingLocations,
102627
- resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
102628
- };
102629
- }
102630
- resolutions[resolutionId - 1] = false;
102631
- return undefined;
102632
- }
102633
- function toResolved(resolved, resolvedFileName, extension) {
102634
- if (!resolved)
102635
- return undefined;
102636
- return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
102637
- }
102638
- function toResolutionDiagnostic(d) {
102639
- return {
102640
- isImports: !!d.isImports,
102641
- entry: d.entry || "",
102642
- packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
102643
- };
102644
- }
102645
- }
102646
- ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
102647
101823
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
102648
101824
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
102649
101825
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -102663,7 +101839,6 @@ var ts;
102663
101839
  restoreEmitState: ts.noop,
102664
101840
  getProgram: getProgram,
102665
101841
  getProgramOrUndefined: function () { return getState().program; },
102666
- getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
102667
101842
  releaseProgram: function () { return getState().program = undefined; },
102668
101843
  getCompilerOptions: function () { return getState().compilerOptions; },
102669
101844
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -102746,57 +101921,15 @@ var ts;
102746
101921
  return true;
102747
101922
  }
102748
101923
  ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
102749
- function getResolvedModuleOfResolution(resolution) {
102750
- return resolution.resolvedModule;
102751
- }
102752
- ts.getResolvedModuleOfResolution = getResolvedModuleOfResolution;
102753
- function getResolvedTypeReferenceDirectiveOfResolution(resolution) {
102754
- return resolution.resolvedTypeReferenceDirective;
102755
- }
102756
- ts.getResolvedTypeReferenceDirectiveOfResolution = getResolvedTypeReferenceDirectiveOfResolution;
102757
- function toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, onRedirectedReferenceKey, forEachResolution, toPath, ancestoryWorker) {
102758
- if (!(fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()))
102759
- return perDirCache;
102760
- var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102761
- var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
102762
- var options = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
102763
- var key = ts.getRedirectsCacheKey(options);
102764
- onRedirectedReferenceKey(key);
102765
- var dirPath = ts.getDirectoryPath(path);
102766
- var perDirResolutionCache = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
102767
- var cacheForDir = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
102768
- fileCacheFromProgram.forEach(function (r, name, mode) {
102769
- if (forEachResolution(r, name, mode, key, redirectedReference, dirPath))
102770
- return;
102771
- if (cacheForDir === null || cacheForDir === void 0 ? void 0 : cacheForDir.has(name, mode))
102772
- return;
102773
- if (!cacheForDir) {
102774
- perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options, key));
102775
- perDirResolutionCache.set(dirPath, cacheForDir = ts.createModeAwareCache());
102776
- }
102777
- cacheForDir.set(name, mode, r);
102778
- if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102779
- return;
102780
- var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options, key);
102781
- var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
102782
- var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
102783
- if (!directoryPathMap)
102784
- actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
102785
- ts.moduleNameToDirectorySet(directoryPathMap, dirPath, r, ts.getResolvedFileNameForModuleNameToDirectorySet, toPath, function (ancestorPath) { return ancestoryWorker(ancestorPath, name, mode, perDirResolutionCache); });
102786
- });
102787
- return perDirCache;
102788
- }
102789
- ts.toPerDirectoryResolution = toPerDirectoryResolution;
102790
101924
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
102791
101925
  var filesWithChangedSetOfUnresolvedImports;
102792
101926
  var filesWithInvalidatedResolutions;
101927
+ var filesWithInvalidatedNonRelativeUnresolvedImports;
101928
+ var nonRelativeExternalModuleResolutions = ts.createMultiMap();
102793
101929
  var resolutionsWithFailedLookups = [];
102794
101930
  var resolutionsWithOnlyAffectingLocations = [];
102795
101931
  var resolvedFileToResolution = ts.createMultiMap();
102796
- var perFilePackageJsonScope = new ts.Map();
102797
- var watchedPackageJsonScopes = [];
102798
- var packageJsonsToCloseWatcherOn;
102799
- var resolutionsToCloseWatcherOn;
101932
+ var impliedFormatPackageJsons = new ts.Map();
102800
101933
  var hasChangedAutomaticTypeDirectiveNames = false;
102801
101934
  var affectingPathChecksForFile;
102802
101935
  var affectingPathChecks;
@@ -102805,12 +101938,13 @@ var ts;
102805
101938
  var isInDirectoryChecks;
102806
101939
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
102807
101940
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
102808
- var oldModuleAndTypeRefCache;
102809
- var oldPackageJsonInfoCache;
102810
101941
  var resolvedModuleNames = new ts.Map();
102811
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
101942
+ var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
101943
+ var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
101944
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
102812
101945
  var resolvedTypeReferenceDirectives = new ts.Map();
102813
- var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache());
101946
+ var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
101947
+ var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
102814
101948
  var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
102815
101949
  var customFailedLookupPaths = new ts.Map();
102816
101950
  var directoryWatchesOfFailedLookups = new ts.Map();
@@ -102820,23 +101954,32 @@ var ts;
102820
101954
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
102821
101955
  var typeRootsWatches = new ts.Map();
102822
101956
  return {
102823
- resolvedModuleNames: resolvedModuleNames,
102824
- resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
102825
101957
  getModuleResolutionCache: function () { return moduleResolutionCache; },
102826
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
102827
101958
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
102828
101959
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
102829
101960
  startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
102830
101961
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
102831
101962
  resolveModuleNames: resolveModuleNames,
101963
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
102832
101964
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
101965
+ removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
101966
+ removeResolutionsOfFile: removeResolutionsOfFile,
102833
101967
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
102834
101968
  invalidateResolutionOfFile: invalidateResolutionOfFile,
102835
101969
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
102836
101970
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
102837
101971
  createHasInvalidatedResolution: createHasInvalidatedResolution,
101972
+ isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
101973
+ updateTypeRootsWatch: updateTypeRootsWatch,
101974
+ closeTypeRootsWatch: closeTypeRootsWatch,
102838
101975
  clear: clear
102839
101976
  };
101977
+ function getResolvedModule(resolution) {
101978
+ return resolution.resolvedModule;
101979
+ }
101980
+ function getResolvedTypeReferenceDirective(resolution) {
101981
+ return resolution.resolvedTypeReferenceDirective;
101982
+ }
102840
101983
  function isInDirectoryPath(dir, file) {
102841
101984
  if (dir === undefined || file.length <= dir.length) {
102842
101985
  return false;
@@ -102847,25 +101990,21 @@ var ts;
102847
101990
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
102848
101991
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
102849
101992
  customFailedLookupPaths.clear();
101993
+ nonRelativeExternalModuleResolutions.clear();
102850
101994
  closeTypeRootsWatch();
102851
101995
  resolvedModuleNames.clear();
102852
101996
  resolvedTypeReferenceDirectives.clear();
102853
101997
  resolvedFileToResolution.clear();
102854
101998
  resolutionsWithFailedLookups.length = 0;
102855
101999
  resolutionsWithOnlyAffectingLocations.length = 0;
102856
- watchedPackageJsonScopes.length = 0;
102857
102000
  failedLookupChecks = undefined;
102858
102001
  startsWithPathChecks = undefined;
102859
102002
  isInDirectoryChecks = undefined;
102860
102003
  affectingPathChecks = undefined;
102861
102004
  affectingPathChecksForFile = undefined;
102862
- resolutionsToCloseWatcherOn = undefined;
102863
- packageJsonsToCloseWatcherOn = undefined;
102864
- oldModuleAndTypeRefCache = undefined;
102865
- oldPackageJsonInfoCache = undefined;
102866
102005
  moduleResolutionCache.clear();
102867
102006
  typeReferenceDirectiveResolutionCache.clear();
102868
- perFilePackageJsonScope.clear();
102007
+ impliedFormatPackageJsons.clear();
102869
102008
  hasChangedAutomaticTypeDirectiveNames = false;
102870
102009
  }
102871
102010
  function startRecordingFilesWithChangedResolutions() {
@@ -102876,6 +102015,13 @@ var ts;
102876
102015
  filesWithChangedSetOfUnresolvedImports = undefined;
102877
102016
  return collected;
102878
102017
  }
102018
+ function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
102019
+ if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
102020
+ return false;
102021
+ }
102022
+ var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
102023
+ return !!value && !!value.length;
102024
+ }
102879
102025
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
102880
102026
  invalidateResolutionsOfFailedLookupLocations();
102881
102027
  if (forceAllFilesAsInvalidated) {
@@ -102884,239 +102030,71 @@ var ts;
102884
102030
  }
102885
102031
  var collected = filesWithInvalidatedResolutions;
102886
102032
  filesWithInvalidatedResolutions = undefined;
102887
- return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
102033
+ return function (path) { return (!!collected && collected.has(path)) ||
102034
+ isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
102888
102035
  }
102889
102036
  function startCachingPerDirectoryResolution() {
102890
- var packageJsonInfoCache = moduleResolutionCache.getPackageJsonInfoCache();
102891
- var internalCache = packageJsonInfoCache.getInternalMap();
102892
- moduleResolutionCache.clear();
102893
- typeReferenceDirectiveResolutionCache.clear();
102894
- moduleResolutionCache.update(resolutionHost.getCompilationSettings());
102895
- typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
102896
- if (oldModuleAndTypeRefCache) {
102897
- oldModuleAndTypeRefCache.clearRedirectsMap();
102898
- moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
102899
- typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
102900
- }
102901
- packageJsonInfoCache.setInternalMap(internalCache);
102902
- packageJsonInfoCache.setOldPackageJsonScopeCache(oldPackageJsonInfoCache);
102037
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
102038
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
102039
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
102040
+ nonRelativeExternalModuleResolutions.clear();
102903
102041
  }
102904
102042
  function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
102905
- hasChangedAutomaticTypeDirectiveNames = false;
102906
- if (!newProgram) {
102907
- clear();
102908
- return;
102909
- }
102910
- if (newProgram === oldProgram)
102911
- return;
102912
- var needsResolutionUpdate = newProgram.structureIsReused !== 3;
102913
- var modules;
102914
- var typeRefs;
102915
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
102916
- var dirToPackageJsonScope = new ts.Map();
102917
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
102918
- var newFile = _a[_i];
102919
- if (needsResolutionUpdate) {
102920
- modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, newFile.resolvedModules, newFile, getResolvedModuleOfResolution, modules, moduleNameToDirectoryMap);
102921
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newFile.resolvedTypeReferenceDirectiveNames, newFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102922
- }
102923
- ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope);
102924
- }
102925
- if (needsResolutionUpdate) {
102926
- var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
102927
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirectiveOfResolution, typeRefs, undefined);
102928
- if (!modules && !typeRefs) {
102929
- oldModuleAndTypeRefCache = undefined;
102930
- }
102931
- else {
102932
- oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
102933
- }
102934
- if (oldProgram) {
102935
- for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
102936
- var f = _c[_b];
102937
- if (!newProgram.getSourceFileByPath(f.path))
102938
- removeResolutionsOfFile(f.path);
102043
+ filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
102044
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
102045
+ nonRelativeExternalModuleResolutions.clear();
102046
+ if (newProgram !== oldProgram) {
102047
+ newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
102048
+ var _a, _b, _c;
102049
+ var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
102050
+ var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
102051
+ for (var i = existing.length; i < expected; i++) {
102052
+ createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false);
102939
102053
  }
102940
- var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
102941
- if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
102942
- removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
102054
+ if (existing.length > expected) {
102055
+ for (var i = expected; i < existing.length; i++) {
102056
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
102057
+ }
102943
102058
  }
102944
- }
102059
+ if (expected)
102060
+ impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
102061
+ else
102062
+ impliedFormatPackageJsons.delete(newFile.path);
102063
+ });
102064
+ impliedFormatPackageJsons.forEach(function (existing, path) {
102065
+ if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
102066
+ existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
102067
+ impliedFormatPackageJsons.delete(path);
102068
+ }
102069
+ });
102945
102070
  }
102946
- perFilePackageJsonScope.forEach(function (existing, path) {
102947
- if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
102948
- stopWatchingPackageJsonScope(existing, path);
102949
- perFilePackageJsonScope.delete(path);
102071
+ directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
102072
+ if (watcher.refCount === 0) {
102073
+ directoryWatchesOfFailedLookups.delete(path);
102074
+ watcher.watcher.close();
102950
102075
  }
102951
102076
  });
102952
- if (dirToPackageJsonScope.size) {
102953
- oldPackageJsonInfoCache = getOldPackageJsonInfoCache(dirToPackageJsonScope);
102954
- }
102955
- else {
102956
- oldPackageJsonInfoCache = undefined;
102957
- }
102958
- if (needsResolutionUpdate && (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions()))
102959
- updateTypeRootsWatch();
102960
- resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
102961
- resolutionsToCloseWatcherOn = undefined;
102962
- packageJsonsToCloseWatcherOn === null || packageJsonsToCloseWatcherOn === void 0 ? void 0 : packageJsonsToCloseWatcherOn.forEach(closeWatchersOfPackageJsonScope);
102963
- packageJsonsToCloseWatcherOn = undefined;
102964
102077
  fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
102965
102078
  if (watcher.files === 0 && watcher.resolutions === 0) {
102966
102079
  fileWatchesOfAffectingLocations.delete(path);
102967
102080
  watcher.watcher.close();
102968
102081
  }
102969
102082
  });
102970
- }
102971
- function ensurePackageJsonWatchesForFile(newFile, dirToPackageJsonScope) {
102972
- var _a;
102973
- var existing = perFilePackageJsonScope.get(newFile.path);
102974
- var scope = ts.isExternalOrCommonJsModule(newFile) ? newFile.packageJsonScope : undefined;
102975
- if (scope) {
102976
- ((_a = scope.files) !== null && _a !== void 0 ? _a : (scope.files = new ts.Set())).add(newFile.path);
102977
- watchPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
102978
- watchPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
102979
- perFilePackageJsonScope.set(newFile.path, scope);
102980
- ts.moduleNameToDirectorySet(dirToPackageJsonScope, ts.getDirectoryPath(newFile.resolvedPath), scope, ts.getPackageJsconLocationFromScope, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102981
- }
102982
- if (existing && scope !== existing)
102983
- stopWatchingPackageJsonScope(existing, newFile.path);
102984
- }
102985
- function stopWatchingPackageJsonScope(scope, path) {
102986
- var _a, _b;
102987
- (_a = scope.files) === null || _a === void 0 ? void 0 : _a.delete(path);
102988
- if (!((_b = scope.files) === null || _b === void 0 ? void 0 : _b.size))
102989
- (packageJsonsToCloseWatcherOn !== null && packageJsonsToCloseWatcherOn !== void 0 ? packageJsonsToCloseWatcherOn : (packageJsonsToCloseWatcherOn = [])).push(scope);
102990
- }
102991
- function watchPackageJsonScopeLocations(scope, locations, field) {
102992
- var _a, _b;
102993
- var locationsLength = (_a = locations === null || locations === void 0 ? void 0 : locations.length) !== null && _a !== void 0 ? _a : 0;
102994
- if (!locationsLength || scope[field] === locationsLength)
102995
- return;
102996
- if (!scope.watchedFailed && !scope.watchedAffected)
102997
- watchedPackageJsonScopes.push(scope);
102998
- for (var i = (_b = scope[field]) !== null && _b !== void 0 ? _b : 0; i < locationsLength; i++) {
102999
- createFileWatcherOfAffectingLocation(locations[i], false);
103000
- }
103001
- scope[field] = locationsLength;
103002
- }
103003
- function closeWatchersOfPackageJsonScope(scope) {
103004
- var _a;
103005
- if (((_a = scope.files) === null || _a === void 0 ? void 0 : _a.size) || !scope.files)
103006
- return;
103007
- scope.files = undefined;
103008
- ts.unorderedRemoveItem(watchedPackageJsonScopes, scope);
103009
- stopWatchingPackageJsonScopeLocations(scope, scope.failedLookupLocations, "watchedFailed");
103010
- stopWatchingPackageJsonScopeLocations(scope, scope.affectingLocations, "watchedAffected");
103011
- }
103012
- function stopWatchingPackageJsonScopeLocations(scope, locations, field) {
103013
- if (!scope[field])
103014
- return;
103015
- for (var i = 0; i < scope[field]; i++) {
103016
- fileWatchesOfAffectingLocations.get(locations[i]).files--;
103017
- }
103018
- scope[field] = undefined;
103019
- }
103020
- function getOldPackageJsonInfoCache(dirToPackageJsonScope) {
103021
- var packageJsons;
103022
- return {
103023
- getPackageJsonScope: function (dir) {
103024
- var _a;
103025
- var scope = dirToPackageJsonScope.get(dir);
103026
- if (!scope)
103027
- return undefined;
103028
- if (!scope.isInvalidated)
103029
- return scope;
103030
- if (!resolutionHost.getCompilationSettings().cacheResolutions || !scope.info)
103031
- return undefined;
103032
- var packageJson = ts.getPackageJsconLocationFromScope(scope);
103033
- var result = packageJsons === null || packageJsons === void 0 ? void 0 : packageJsons.get(packageJson);
103034
- if (result !== undefined)
103035
- return result || undefined;
103036
- if (resolutionHost.fileExists(packageJson)) {
103037
- result = {
103038
- 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())),
103039
- affectingLocations: [packageJson],
103040
- };
103041
- }
103042
- (packageJsons !== null && packageJsons !== void 0 ? packageJsons : (packageJsons = new ts.Map())).set(packageJson, result || false);
103043
- return result;
103044
- }
103045
- };
103046
- }
103047
- function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
103048
- var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
103049
- var resolutionsInFile = perFileCache.get(path);
103050
- var seenNamesInFile = ts.createModeAwareCache();
103051
- perDirCache = toPerDirectoryResolution(newProgram, fileCacheFromProgram, sourceFileOrPath, perDirCache, moduleNameToDirectoryMap, function (key) {
103052
- if (resolutionsInFile && resolutionsInFile.key !== key) {
103053
- resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
103054
- resolutionsInFile = undefined;
103055
- }
103056
- }, function (r, name, mode, key) {
103057
- seenNamesInFile.set(name, mode, true);
103058
- var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
103059
- if (existing && r !== existing)
103060
- stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
103061
- watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
103062
- if (!resolutionsInFile)
103063
- perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
103064
- resolutionsInFile.cache.set(name, mode, r);
103065
- }, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
103066
- if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
103067
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
103068
- if (!seenNamesInFile.has(name, mode)) {
103069
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
103070
- resolutionsInFile.cache.delete(name, mode);
103071
- }
103072
- });
103073
- if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
103074
- perFileCache.delete(path);
103075
- }
103076
- return perDirCache;
103077
- }
103078
- function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
103079
- if (!modules && !typeRefs)
103080
- return undefined;
103081
- return {
103082
- modules: {
103083
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
103084
- },
103085
- typeRefs: {
103086
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, undefined); }
103087
- },
103088
- clearRedirectsMap: function () {
103089
- modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
103090
- typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
103091
- moduleNameToDirectoryMap.clearRedirectsMap();
103092
- },
103093
- };
103094
- }
103095
- function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
103096
- var _a, _b, _c, _d;
103097
- if (!perDirCache)
103098
- return undefined;
103099
- 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)) ||
103100
- ((_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));
103101
- return result && !result.isInvalidated ? result : undefined;
102083
+ hasChangedAutomaticTypeDirectiveNames = false;
103102
102084
  }
103103
102085
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
103104
- var _a;
102086
+ var _a, _b;
103105
102087
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
103106
102088
  if (!resolutionHost.getGlobalCache) {
103107
102089
  return primaryResult;
103108
102090
  }
103109
102091
  var globalCache = resolutionHost.getGlobalCache();
103110
102092
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
103111
- 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;
102093
+ 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;
103112
102094
  if (resolvedModule) {
103113
102095
  primaryResult.resolvedModule = resolvedModule;
103114
- if (!compilerOptions.cacheResolutions)
103115
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
103116
- else
103117
- primaryResult.failedLookupLocations.length = 0;
103118
- primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
103119
- primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
102096
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
102097
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
103120
102098
  return primaryResult;
103121
102099
  }
103122
102100
  }
@@ -103126,35 +102104,68 @@ var ts;
103126
102104
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
103127
102105
  }
103128
102106
  function resolveNamesWithLocalCache(_a) {
103129
- var _b, _c, _d, _e;
103130
- 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;
102107
+ var _b, _c, _d;
102108
+ 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;
103131
102109
  var path = resolutionHost.toPath(containingFile);
103132
- var resolutionsInFile = perFileCache.get(path);
103133
- var compilerOptions = resolutionHost.getCompilationSettings();
103134
- var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
103135
- if (!resolutionsInFile || resolutionsInFile.key !== key) {
103136
- resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
103137
- perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
102110
+ var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
102111
+ var dirPath = ts.getDirectoryPath(path);
102112
+ var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
102113
+ var perDirectoryResolution = perDirectoryCache.get(dirPath);
102114
+ if (!perDirectoryResolution) {
102115
+ perDirectoryResolution = ts.createModeAwareCache();
102116
+ perDirectoryCache.set(dirPath, perDirectoryResolution);
103138
102117
  }
103139
102118
  var resolvedModules = [];
102119
+ var compilerOptions = resolutionHost.getCompilationSettings();
102120
+ var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
102121
+ var program = resolutionHost.getCurrentProgram();
102122
+ var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
102123
+ var unmatchedRedirects = oldRedirect ?
102124
+ !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
102125
+ !!redirectedReference;
103140
102126
  var seenNamesInFile = ts.createModeAwareCache();
103141
102127
  var i = 0;
103142
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
103143
- var entry = names_4[_i];
103144
- var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
102128
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
102129
+ var entry = names_5[_i];
102130
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
103145
102131
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
103146
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
102132
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
103147
102133
  i++;
103148
- var resolution = resolutionsInFile.cache.get(name, mode);
103149
- if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
102134
+ var resolution = resolutionsInFile.get(name, mode);
102135
+ if (!seenNamesInFile.has(name, mode) &&
102136
+ unmatchedRedirects || !resolution || resolution.isInvalidated ||
102137
+ (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
103150
102138
  var existingResolution = resolution;
103151
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
103152
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
103153
- resolutionHost.onDiscoveredSymlink();
102139
+ var resolutionInDirectory = perDirectoryResolution.get(name, mode);
102140
+ if (resolutionInDirectory) {
102141
+ resolution = resolutionInDirectory;
102142
+ var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
102143
+ if (ts.isTraceEnabled(compilerOptions, host)) {
102144
+ var resolved = getResolutionWithResolvedFileName(resolution);
102145
+ ts.trace(host, loader === resolveModuleName ?
102146
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
102147
+ resolved.packagetId ?
102148
+ 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 :
102149
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
102150
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
102151
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
102152
+ resolved.packagetId ?
102153
+ 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 :
102154
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
102155
+ 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));
102156
+ }
102157
+ }
102158
+ else {
102159
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102160
+ perDirectoryResolution.set(name, mode, resolution);
102161
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102162
+ resolutionHost.onDiscoveredSymlink();
102163
+ }
103154
102164
  }
103155
- resolutionsInFile.cache.set(name, mode, resolution);
102165
+ resolutionsInFile.set(name, mode, resolution);
102166
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
103156
102167
  if (existingResolution) {
103157
- stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
102168
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
103158
102169
  }
103159
102170
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
103160
102171
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -103167,33 +102178,27 @@ var ts;
103167
102178
  var resolved = getResolutionWithResolvedFileName(resolution);
103168
102179
  ts.trace(host, loader === resolveModuleName ?
103169
102180
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
103170
- resolved.packageId ?
102181
+ resolved.packagetId ?
103171
102182
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
103172
102183
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
103173
102184
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
103174
102185
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
103175
- resolved.packageId ?
102186
+ resolved.packagetId ?
103176
102187
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
103177
102188
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
103178
- 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));
102189
+ 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));
103179
102190
  }
103180
102191
  }
103181
102192
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
103182
102193
  seenNamesInFile.set(name, mode, true);
103183
- resolvedModules.push(resolution);
102194
+ resolvedModules.push(getResolutionWithResolvedFileName(resolution));
103184
102195
  }
103185
- (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
103186
- var name = _a.name, mode = _a.mode;
103187
- return seenNamesInFile.set(name, mode, true);
102196
+ resolutionsInFile.forEach(function (resolution, name, mode) {
102197
+ if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
102198
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
102199
+ resolutionsInFile.delete(name, mode);
102200
+ }
103188
102201
  });
103189
- if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
103190
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
103191
- if (!seenNamesInFile.has(name, mode)) {
103192
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
103193
- resolutionsInFile.cache.delete(name, mode);
103194
- }
103195
- });
103196
- }
103197
102202
  return resolvedModules;
103198
102203
  function resolutionIsEqualTo(oldResolution, newResolution) {
103199
102204
  if (oldResolution === newResolution) {
@@ -103213,31 +102218,40 @@ var ts;
103213
102218
  return oldResult.resolvedFileName === newResult.resolvedFileName;
103214
102219
  }
103215
102220
  }
103216
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
102221
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
103217
102222
  return resolveNamesWithLocalCache({
103218
102223
  names: typeDirectiveNames,
103219
102224
  containingFile: containingFile,
103220
102225
  redirectedReference: redirectedReference,
103221
- perFileCache: resolvedTypeReferenceDirectives,
102226
+ cache: resolvedTypeReferenceDirectives,
102227
+ perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
103222
102228
  loader: resolveTypeReferenceDirective,
103223
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveOfResolution,
103224
- containingSourceFileMode: containingFileMode,
103225
- partialResolutionInfo: partialResolutionInfo,
102229
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
102230
+ shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
102231
+ containingSourceFileMode: containingFileMode
103226
102232
  });
103227
102233
  }
103228
- function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
102234
+ function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
103229
102235
  return resolveNamesWithLocalCache({
103230
102236
  names: moduleNames,
103231
102237
  containingFile: containingFile,
103232
102238
  redirectedReference: redirectedReference,
103233
- perFileCache: resolvedModuleNames,
102239
+ cache: resolvedModuleNames,
102240
+ perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
103234
102241
  loader: resolveModuleName,
103235
- getResolutionWithResolvedFileName: getResolvedModuleOfResolution,
103236
- partialResolutionInfo: partialResolutionInfo,
102242
+ getResolutionWithResolvedFileName: getResolvedModule,
102243
+ shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
102244
+ reusedNames: reusedNames,
103237
102245
  logChanges: logChangesWhenResolvingModule,
103238
102246
  containingSourceFile: containingSourceFile,
103239
102247
  });
103240
102248
  }
102249
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
102250
+ var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
102251
+ if (!cache)
102252
+ return undefined;
102253
+ return cache.get(moduleName, resolutionMode);
102254
+ }
103241
102255
  function isNodeModulesAtTypesDirectory(dirPath) {
103242
102256
  return ts.endsWith(dirPath, "/node_modules/@types");
103243
102257
  }
@@ -103291,41 +102305,37 @@ var ts;
103291
102305
  function isPathWithDefaultFailedLookupExtension(path) {
103292
102306
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
103293
102307
  }
103294
- function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
103295
- if (resolution.files) {
103296
- resolution.files.add(filePath);
103297
- if (resolution.watchedFailed !== false)
103298
- watchFailedLookupLocationOfResolution(resolution);
103299
- watchAffectingLocationsOfResolution(resolution);
103300
- return;
103301
- }
103302
- resolution.files = new ts.Set();
103303
- resolution.files.add(filePath);
103304
- var resolved = getResolutionWithResolvedFileName(resolution);
103305
- if (resolved && resolved.resolvedFileName) {
103306
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
103307
- }
103308
- if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
103309
- watchFailedLookupLocationOfResolution(resolution);
103310
- watchAffectingLocationsOfResolution(resolution);
102308
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
102309
+ if (resolution.refCount) {
102310
+ resolution.refCount++;
102311
+ ts.Debug.assertIsDefined(resolution.files);
103311
102312
  }
103312
102313
  else {
103313
- resolution.watchedFailed = false;
103314
- watchAffectingLocationsOfResolution(resolution);
102314
+ resolution.refCount = 1;
102315
+ ts.Debug.assert(ts.length(resolution.files) === 0);
102316
+ if (ts.isExternalModuleNameRelative(name)) {
102317
+ watchFailedLookupLocationOfResolution(resolution);
102318
+ }
102319
+ else {
102320
+ nonRelativeExternalModuleResolutions.add(name, resolution);
102321
+ }
102322
+ var resolved = getResolutionWithResolvedFileName(resolution);
102323
+ if (resolved && resolved.resolvedFileName) {
102324
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102325
+ }
103315
102326
  }
102327
+ (resolution.files || (resolution.files = [])).push(filePath);
103316
102328
  }
103317
102329
  function watchFailedLookupLocationOfResolution(resolution) {
103318
- var failedLookupLocations = resolution.failedLookupLocations;
103319
- if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
102330
+ ts.Debug.assert(!!resolution.refCount);
102331
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102332
+ if (!failedLookupLocations.length && !affectingLocations.length)
103320
102333
  return;
103321
- if (!resolution.watchedFailed) {
102334
+ if (failedLookupLocations.length)
103322
102335
  resolutionsWithFailedLookups.push(resolution);
103323
- if (resolution.watchedAffected)
103324
- ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
103325
- }
103326
- var setAtRoot = !!resolution.setAtRoot;
103327
- for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
103328
- var failedLookupLocation = failedLookupLocations[i];
102336
+ var setAtRoot = false;
102337
+ for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
102338
+ var failedLookupLocation = failedLookupLocations_1[_i];
103329
102339
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
103330
102340
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
103331
102341
  if (toWatch) {
@@ -103343,22 +102353,22 @@ var ts;
103343
102353
  }
103344
102354
  }
103345
102355
  }
103346
- if (setAtRoot && !resolution.setAtRoot) {
102356
+ if (setAtRoot) {
103347
102357
  setDirectoryWatcher(rootDir, rootPath, true);
103348
102358
  }
103349
- resolution.setAtRoot = setAtRoot;
103350
- resolution.watchedFailed = failedLookupLocations.length;
102359
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
103351
102360
  }
103352
- function watchAffectingLocationsOfResolution(resolution) {
102361
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
102362
+ ts.Debug.assert(!!resolution.refCount);
103353
102363
  var affectingLocations = resolution.affectingLocations;
103354
- if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
102364
+ if (!affectingLocations.length)
103355
102365
  return;
103356
- if (!resolution.watchedFailed && !resolution.watchedAffected)
102366
+ if (addToResolutionsWithOnlyAffectingLocations)
103357
102367
  resolutionsWithOnlyAffectingLocations.push(resolution);
103358
- for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
103359
- createFileWatcherOfAffectingLocation(affectingLocations[i], true);
102368
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
102369
+ var affectingLocation = affectingLocations_1[_i];
102370
+ createFileWatcherOfAffectingLocation(affectingLocation, true);
103360
102371
  }
103361
- resolution.watchedAffected = affectingLocations.length;
103362
102372
  }
103363
102373
  function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
103364
102374
  var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
@@ -103417,6 +102427,15 @@ var ts;
103417
102427
  paths.add(affectingLocation);
103418
102428
  }
103419
102429
  }
102430
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
102431
+ var program = resolutionHost.getCurrentProgram();
102432
+ if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
102433
+ resolutions.forEach(watchFailedLookupLocationOfResolution);
102434
+ }
102435
+ else {
102436
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); });
102437
+ }
102438
+ }
103420
102439
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
103421
102440
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
103422
102441
  if (dirWatcher) {
@@ -103427,27 +102446,21 @@ var ts;
103427
102446
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
103428
102447
  }
103429
102448
  }
103430
- function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
103431
- var _a, _b;
103432
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
103433
- if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
103434
- (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
103435
- }
103436
- function closeWatchersOfResolution(_a) {
103437
- var _b;
103438
- var resolution = _a.resolution, getResolved = _a.getResolved;
103439
- if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
102449
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102450
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
102451
+ resolution.refCount--;
102452
+ if (resolution.refCount) {
103440
102453
  return;
103441
- resolution.files = undefined;
103442
- var resolved = getResolved(resolution);
102454
+ }
102455
+ var resolved = getResolutionWithResolvedFileName(resolution);
103443
102456
  if (resolved && resolved.resolvedFileName) {
103444
102457
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
103445
102458
  }
103446
- if (resolution.watchedFailed) {
103447
- ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
102459
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
102460
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
103448
102461
  var removeAtRoot = false;
103449
- for (var i = 0; i < resolution.watchedFailed; i++) {
103450
- var failedLookupLocation = resolution.failedLookupLocations[i];
102462
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
102463
+ var failedLookupLocation = failedLookupLocations_2[_i];
103451
102464
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
103452
102465
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
103453
102466
  if (toWatch) {
@@ -103470,28 +102483,22 @@ var ts;
103470
102483
  }
103471
102484
  }
103472
102485
  }
103473
- ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
103474
102486
  if (removeAtRoot) {
103475
102487
  removeDirectoryWatcher(rootPath);
103476
102488
  }
103477
102489
  }
103478
- else if (resolution.watchedAffected) {
102490
+ else if (affectingLocations.length) {
103479
102491
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
103480
102492
  }
103481
- if (resolution.watchedAffected) {
103482
- for (var i = 0; i < resolution.watchedAffected; i++) {
103483
- var watcher = fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]);
103484
- watcher.resolutions--;
103485
- }
102493
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
102494
+ var affectingLocation = affectingLocations_2[_a];
102495
+ var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
102496
+ watcher.resolutions--;
103486
102497
  }
103487
102498
  }
103488
102499
  function removeDirectoryWatcher(dirPath) {
103489
102500
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
103490
102501
  dirWatcher.refCount--;
103491
- if (dirWatcher.refCount === 0) {
103492
- directoryWatchesOfFailedLookups.delete(dirPath);
103493
- dirWatcher.watcher.close();
103494
- }
103495
102502
  }
103496
102503
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
103497
102504
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -103505,16 +102512,26 @@ var ts;
103505
102512
  function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
103506
102513
  var resolutions = cache.get(filePath);
103507
102514
  if (resolutions) {
103508
- resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
102515
+ resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
103509
102516
  cache.delete(filePath);
103510
102517
  }
103511
102518
  }
102519
+ function removeResolutionsFromProjectReferenceRedirects(filePath) {
102520
+ if (!ts.fileExtensionIs(filePath, ".json"))
102521
+ return;
102522
+ var program = resolutionHost.getCurrentProgram();
102523
+ if (!program)
102524
+ return;
102525
+ var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
102526
+ if (!resolvedProjectReference)
102527
+ return;
102528
+ resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
102529
+ }
103512
102530
  function removeResolutionsOfFile(filePath) {
103513
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleOfResolution);
103514
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveOfResolution);
102531
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
102532
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
103515
102533
  }
103516
102534
  function invalidateResolutions(resolutions, canInvalidate) {
103517
- var _a;
103518
102535
  if (!resolutions)
103519
102536
  return false;
103520
102537
  var invalidated = false;
@@ -103523,14 +102540,16 @@ var ts;
103523
102540
  if (resolution.isInvalidated || !canInvalidate(resolution))
103524
102541
  continue;
103525
102542
  resolution.isInvalidated = invalidated = true;
103526
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
102543
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102544
+ var containingFilePath = _b[_a];
103527
102545
  (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
103528
102546
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
103529
- });
102547
+ }
103530
102548
  }
103531
102549
  return invalidated;
103532
102550
  }
103533
102551
  function invalidateResolutionOfFile(filePath) {
102552
+ removeResolutionsOfFile(filePath);
103534
102553
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
103535
102554
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
103536
102555
  hasChangedAutomaticTypeDirectiveNames &&
@@ -103539,28 +102558,8 @@ var ts;
103539
102558
  }
103540
102559
  }
103541
102560
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
103542
- filesMap.forEach(function (_a, filePath) {
103543
- var imports = _a.imports;
103544
- if (!imports.length)
103545
- return;
103546
- var resolvedModules = resolvedModuleNames.get(filePath);
103547
- var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
103548
- if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
103549
- return;
103550
- imports.forEach(function (_a) {
103551
- var name = _a.name, mode = _a.mode;
103552
- var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
103553
- if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
103554
- resolvedModule.isInvalidated = true;
103555
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103556
- }
103557
- var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
103558
- if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
103559
- resolvedTypeRef.isInvalidated = true;
103560
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
103561
- }
103562
- });
103563
- });
102561
+ ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
102562
+ filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
103564
102563
  }
103565
102564
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
103566
102565
  if (isCreatingWatchedDirectory) {
@@ -103599,17 +102598,12 @@ var ts;
103599
102598
  var _a;
103600
102599
  var invalidated = false;
103601
102600
  if (affectingPathChecksForFile) {
103602
- for (var _i = 0, watchedPackageJsonScopes_1 = watchedPackageJsonScopes; _i < watchedPackageJsonScopes_1.length; _i++) {
103603
- var scope = watchedPackageJsonScopes_1[_i];
103604
- if (scope.isInvalidated)
103605
- continue;
103606
- if (ts.some(scope.failedLookupLocations, function (location) { return affectingPathChecksForFile.has(location); }) ||
103607
- ts.some(scope.affectingLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
103608
- scope.isInvalidated = true;
102601
+ (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
102602
+ if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
102603
+ (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
103609
102604
  invalidated = true;
103610
- (_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); });
103611
102605
  }
103612
- }
102606
+ });
103613
102607
  affectingPathChecksForFile = undefined;
103614
102608
  }
103615
102609
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
@@ -103640,8 +102634,7 @@ var ts;
103640
102634
  ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
103641
102635
  }
103642
102636
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
103643
- var _a;
103644
- return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) { return affectingPathChecks.has(location); }));
102637
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
103645
102638
  }
103646
102639
  function closeTypeRootsWatch() {
103647
102640
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -103942,9 +102935,9 @@ var ts;
103942
102935
  var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
103943
102936
  var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
103944
102937
  if (!preferSymlinks) {
103945
- var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
103946
- if (result_17)
103947
- return result_17;
102938
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
102939
+ if (result_16)
102940
+ return result_16;
103948
102941
  }
103949
102942
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
103950
102943
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -103963,10 +102956,10 @@ var ts;
103963
102956
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
103964
102957
  var symlinkDirectory = symlinkDirectories_1[_i];
103965
102958
  var option = ts.resolvePath(symlinkDirectory, relative);
103966
- var result_18 = cb(option, target === referenceRedirect);
102959
+ var result_17 = cb(option, target === referenceRedirect);
103967
102960
  shouldFilterIgnoredPaths = true;
103968
- if (result_18)
103969
- return result_18;
102961
+ if (result_17)
102962
+ return result_17;
103970
102963
  }
103971
102964
  });
103972
102965
  });
@@ -104025,9 +103018,9 @@ var ts;
104025
103018
  };
104026
103019
  var out_directory_1;
104027
103020
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
104028
- var state_12 = _loop_35(directory);
103021
+ var state_11 = _loop_35(directory);
104029
103022
  directory = out_directory_1;
104030
- if (state_12 === "break")
103023
+ if (state_11 === "break")
104031
103024
  break;
104032
103025
  }
104033
103026
  if (allFileNames.size) {
@@ -104117,9 +103110,9 @@ var ts;
104117
103110
  };
104118
103111
  for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
104119
103112
  var patternText_1 = _a[_i];
104120
- var state_13 = _loop_36(patternText_1);
104121
- if (typeof state_13 === "object")
104122
- return state_13.value;
103113
+ var state_12 = _loop_36(patternText_1);
103114
+ if (typeof state_12 === "object")
103115
+ return state_12.value;
104123
103116
  }
104124
103117
  }
104125
103118
  function validateEnding(_a) {
@@ -104572,7 +103565,7 @@ var ts;
104572
103565
  }
104573
103566
  ts.explainFiles = explainFiles;
104574
103567
  function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
104575
- var _a, _b;
103568
+ var _a;
104576
103569
  var result;
104577
103570
  if (file.path !== file.resolvedPath) {
104578
103571
  (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)));
@@ -104583,17 +103576,17 @@ var ts;
104583
103576
  if (ts.isExternalOrCommonJsModule(file)) {
104584
103577
  switch (file.impliedNodeFormat) {
104585
103578
  case ts.ModuleKind.ESNext:
104586
- if ((_a = file.packageJsonScope) === null || _a === void 0 ? void 0 : _a.info) {
104587
- (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)));
103579
+ if (file.packageJsonScope) {
103580
+ (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)));
104588
103581
  }
104589
103582
  break;
104590
103583
  case ts.ModuleKind.CommonJS:
104591
- if ((_b = file.packageJsonScope) === null || _b === void 0 ? void 0 : _b.info) {
104592
- (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.info.packageJsonContent.type ?
103584
+ if (file.packageJsonScope) {
103585
+ (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.packageJsonContent.type ?
104593
103586
  ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
104594
- ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.getPackageJsconLocationFromScope(file.packageJsonScope), fileNameConvertor)));
103587
+ ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
104595
103588
  }
104596
- else if (file.packageJsonScope) {
103589
+ else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
104597
103590
  (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
104598
103591
  }
104599
103592
  break;
@@ -104937,7 +103930,7 @@ var ts;
104937
103930
  })(ts || (ts = {}));
104938
103931
  var ts;
104939
103932
  (function (ts) {
104940
- function readBuildInfoForProgram(compilerOptions, host) {
103933
+ function readBuilderProgram(compilerOptions, host) {
104941
103934
  var _a, _b, _c;
104942
103935
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
104943
103936
  if (!buildInfoPath)
@@ -104955,12 +103948,7 @@ var ts;
104955
103948
  }
104956
103949
  if (!buildInfo || buildInfo.version !== ts.version || !buildInfo.program)
104957
103950
  return undefined;
104958
- return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
104959
- }
104960
- ts.readBuildInfoForProgram = readBuildInfoForProgram;
104961
- function readBuilderProgram(compilerOptions, host) {
104962
- var result = readBuildInfoForProgram(compilerOptions, host);
104963
- return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
103951
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
104964
103952
  }
104965
103953
  ts.readBuilderProgram = readBuilderProgram;
104966
103954
  function createIncrementalCompilerHost(options, system) {
@@ -105093,7 +104081,7 @@ var ts;
105093
104081
  }
105094
104082
  return host.resolveModuleNames.apply(host, args);
105095
104083
  }) :
105096
- (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
104084
+ (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
105097
104085
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
105098
104086
  (function () {
105099
104087
  var args = [];
@@ -105102,13 +104090,10 @@ var ts;
105102
104090
  }
105103
104091
  return host.resolveTypeReferenceDirectives.apply(host, args);
105104
104092
  }) :
105105
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
104093
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
105106
104094
  compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
105107
104095
  ts.maybeBind(host, host.getModuleResolutionCache) :
105108
104096
  (function () { return resolutionCache.getModuleResolutionCache(); });
105109
- compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
105110
- ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
105111
- (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
105112
104097
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
105113
104098
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
105114
104099
  synchronizeProgram();
@@ -105207,6 +104192,7 @@ var ts;
105207
104192
  writeLog(" options: " + JSON.stringify(compilerOptions));
105208
104193
  if (projectReferences)
105209
104194
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
104195
+ var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
105210
104196
  hasChangedCompilerOptions = false;
105211
104197
  hasChangedConfigFileParsingErrors = false;
105212
104198
  resolutionCache.startCachingPerDirectoryResolution();
@@ -105216,6 +104202,9 @@ var ts;
105216
104202
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
105217
104203
  resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
105218
104204
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
104205
+ if (needsUpdateInTypeRootWatch) {
104206
+ resolutionCache.updateTypeRootsWatch();
104207
+ }
105219
104208
  if (missingFilePathsRequestedForRelease) {
105220
104209
  for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
105221
104210
  var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
@@ -105300,7 +104289,7 @@ var ts;
105300
104289
  var hostSourceFile = sourceFilesCache.get(path);
105301
104290
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
105302
104291
  }
105303
- function onReleaseOldSourceFile(oldSourceFile) {
104292
+ function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
105304
104293
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
105305
104294
  if (hostSourceFileInfo !== undefined) {
105306
104295
  if (isFileMissingOnHost(hostSourceFileInfo)) {
@@ -105311,6 +104300,9 @@ var ts;
105311
104300
  hostSourceFileInfo.fileWatcher.close();
105312
104301
  }
105313
104302
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
104303
+ if (!hasSourceFileByPath) {
104304
+ resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
104305
+ }
105314
104306
  }
105315
104307
  }
105316
104308
  }
@@ -105545,6 +104537,7 @@ var ts;
105545
104537
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
105546
104538
  if (config)
105547
104539
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104540
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
105548
104541
  }
105549
104542
  scheduleProgramUpdate();
105550
104543
  });
@@ -105557,6 +104550,7 @@ var ts;
105557
104550
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
105558
104551
  if (config)
105559
104552
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
104553
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
105560
104554
  scheduleProgramUpdate();
105561
104555
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
105562
104556
  if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) {
@@ -105730,22 +104724,20 @@ var ts;
105730
104724
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
105731
104725
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
105732
104726
  compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
105733
- compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
105734
104727
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
105735
104728
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
105736
104729
  if (!compilerHost.resolveModuleNames) {
105737
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
105738
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
105739
- return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
104730
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
104731
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
104732
+ return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
105740
104733
  };
105741
104734
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
105742
104735
  }
105743
104736
  if (!compilerHost.resolveTypeReferenceDirectives) {
105744
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
104737
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
105745
104738
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
105746
- return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
104739
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
105747
104740
  };
105748
- compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
105749
104741
  }
105750
104742
  compilerHost.getBuildInfo = function (fileName, options) { return getBuildInfo(state, fileName, options, toResolvedConfigFilePath(state, options.configFilePath), undefined); };
105751
104743
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -106710,7 +105702,7 @@ var ts;
106710
105702
  if (buildInfoTime && buildInfoTime < inputTime) {
106711
105703
  var version_3 = void 0;
106712
105704
  var currentVersion = void 0;
106713
- if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
105705
+ if (buildInfoProgram) {
106714
105706
  if (!buildInfoVersionMap)
106715
105707
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
106716
105708
  version_3 = buildInfoVersionMap.get(toPath(state, inputFile));