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