@typescript-deploys/pr-build 4.8.0-pr-50007-2 → 4.8.0-pr-50085-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -6816,7 +6816,6 @@ var ts;
6816
6816
  Specify_how_the_TypeScript_watch_mode_works: diag(6715, ts.DiagnosticCategory.Message, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."),
6817
6817
  Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
6818
6818
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, ts.DiagnosticCategory.Message, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
6819
- Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation: diag(6719, ts.DiagnosticCategory.Message, "Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation_6719", "Save resolutions into .tsbuildinfo file and use them for incremental compilation."),
6820
6819
  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'."),
6821
6820
  one_of_Colon: diag(6900, ts.DiagnosticCategory.Message, "one_of_Colon_6900", "one of:"),
6822
6821
  one_or_more_Colon: diag(6901, ts.DiagnosticCategory.Message, "one_or_more_Colon_6901", "one or more:"),
@@ -10954,8 +10953,7 @@ var ts;
10954
10953
  }
10955
10954
  ts.changesAffectModuleResolution = changesAffectModuleResolution;
10956
10955
  function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
10957
- return oldOptions.pathsBasePath !== newOptions.pathsBasePath ||
10958
- optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10956
+ return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations);
10959
10957
  }
10960
10958
  ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
10961
10959
  function changesAffectingProgramStructure(oldOptions, newOptions) {
@@ -11027,20 +11025,21 @@ var ts;
11027
11025
  }
11028
11026
  ts.getFullWidth = getFullWidth;
11029
11027
  function getResolvedModule(sourceFile, moduleNameText, mode) {
11030
- var _a, _b;
11031
- return (_b = (_a = sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleNameText, mode)) === null || _b === void 0 ? void 0 : _b.resolvedModule;
11028
+ return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
11032
11029
  }
11033
11030
  ts.getResolvedModule = getResolvedModule;
11034
11031
  function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
11035
- var _a;
11036
- (_a = sourceFile.resolvedModules) !== null && _a !== void 0 ? _a : (sourceFile.resolvedModules = ts.createModeAwareCache());
11032
+ if (!sourceFile.resolvedModules) {
11033
+ sourceFile.resolvedModules = ts.createModeAwareCache();
11034
+ }
11037
11035
  sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
11038
11036
  }
11039
11037
  ts.setResolvedModule = setResolvedModule;
11040
- function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective, mode) {
11041
- var _a;
11042
- (_a = sourceFile.resolvedTypeReferenceDirectiveNames) !== null && _a !== void 0 ? _a : (sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache());
11043
- sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, mode, resolvedTypeReferenceDirective);
11038
+ function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
11039
+ if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
11040
+ sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
11041
+ }
11042
+ sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, undefined, resolvedTypeReferenceDirective);
11044
11043
  }
11045
11044
  ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
11046
11045
  function projectReferenceIsEqualTo(oldRef, newRef) {
@@ -11050,15 +11049,11 @@ var ts;
11050
11049
  }
11051
11050
  ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
11052
11051
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
11053
- return oldResolution === newResolution ||
11054
- oldResolution.resolvedModule === newResolution.resolvedModule ||
11055
- !!oldResolution.resolvedModule &&
11056
- !!newResolution.resolvedModule &&
11057
- oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport &&
11058
- oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension &&
11059
- oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName &&
11060
- oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath &&
11061
- packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId);
11052
+ return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
11053
+ oldResolution.extension === newResolution.extension &&
11054
+ oldResolution.resolvedFileName === newResolution.resolvedFileName &&
11055
+ oldResolution.originalPath === newResolution.originalPath &&
11056
+ packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
11062
11057
  }
11063
11058
  ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
11064
11059
  function packageIdIsEqual(a, b) {
@@ -11074,13 +11069,9 @@ var ts;
11074
11069
  }
11075
11070
  ts.packageIdToString = packageIdToString;
11076
11071
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
11077
- return oldResolution === newResolution ||
11078
- oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective ||
11079
- !!oldResolution.resolvedTypeReferenceDirective &&
11080
- !!newResolution.resolvedTypeReferenceDirective &&
11081
- oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName &&
11082
- !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary &&
11083
- oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
11072
+ return oldResolution.resolvedFileName === newResolution.resolvedFileName
11073
+ && oldResolution.primary === newResolution.primary
11074
+ && oldResolution.originalPath === newResolution.originalPath;
11084
11075
  }
11085
11076
  ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
11086
11077
  function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
@@ -15279,20 +15270,22 @@ var ts;
15279
15270
  return getStringFromExpandedCharCodes(expandedCharCodes);
15280
15271
  }
15281
15272
  ts.base64decode = base64decode;
15282
- function readJsonIgnoringErrors(path, host) {
15283
- return readJsonIgnoringErrorsFromText(path, host.readFile(path));
15284
- }
15285
- ts.readJsonIgnoringErrors = readJsonIgnoringErrors;
15286
- function readJsonIgnoringErrorsFromText(path, jsonText) {
15287
- if (!jsonText)
15288
- return {};
15289
- var result = ts.parseConfigFileTextToJson(path, jsonText);
15290
- if (result.error) {
15273
+ function readJson(path, host) {
15274
+ try {
15275
+ var jsonText = host.readFile(path);
15276
+ if (!jsonText)
15277
+ return {};
15278
+ var result = ts.parseConfigFileTextToJson(path, jsonText);
15279
+ if (result.error) {
15280
+ return {};
15281
+ }
15282
+ return result.config;
15283
+ }
15284
+ catch (e) {
15291
15285
  return {};
15292
15286
  }
15293
- return result.config;
15294
15287
  }
15295
- ts.readJsonIgnoringErrorsFromText = readJsonIgnoringErrorsFromText;
15288
+ ts.readJson = readJson;
15296
15289
  function directoryProbablyExists(directoryName, host) {
15297
15290
  return !host.directoryExists || host.directoryExists(directoryName);
15298
15291
  }
@@ -16270,15 +16263,14 @@ var ts;
16270
16263
  },
16271
16264
  setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
16272
16265
  var _this = this;
16273
- var _a, _b;
16266
+ var _a;
16274
16267
  ts.Debug.assert(!hasProcessedResolutions);
16275
16268
  hasProcessedResolutions = true;
16276
16269
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
16277
16270
  var file = files_1[_i];
16278
- (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedModule); });
16279
- (_b = file.resolvedTypeReferenceDirectiveNames) === null || _b === void 0 ? void 0 : _b.forEach(function (resolution) { return processResolution(_this, resolution === null || resolution === void 0 ? void 0 : resolution.resolvedTypeReferenceDirective); });
16271
+ (_a = file.resolvedModules) === null || _a === void 0 ? void 0 : _a.forEach(function (resolution) { return processResolution(_this, resolution); });
16280
16272
  }
16281
- typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution.resolvedTypeReferenceDirective); });
16273
+ typeReferenceDirectives === null || typeReferenceDirectives === void 0 ? void 0 : typeReferenceDirectives.forEach(function (resolution) { return processResolution(_this, resolution); });
16282
16274
  },
16283
16275
  hasProcessedResolutions: function () { return hasProcessedResolutions; },
16284
16276
  };
@@ -32185,17 +32177,6 @@ var ts;
32185
32177
  transpileOptionValue: undefined,
32186
32178
  defaultValueDescription: ts.Diagnostics.false_unless_composite_is_set
32187
32179
  },
32188
- {
32189
- name: "cacheResolutions",
32190
- type: "boolean",
32191
- category: ts.Diagnostics.Projects,
32192
- description: ts.Diagnostics.Save_resolutions_into_tsbuildinfo_file_and_use_them_for_incremental_compilation,
32193
- affectsModuleResolution: true,
32194
- affectsMultiFileEmitBuildInfo: true,
32195
- affectsBundleEmitBuildInfo: true,
32196
- transpileOptionValue: undefined,
32197
- defaultValueDescription: false,
32198
- },
32199
32180
  {
32200
32181
  name: "assumeChangesOnlyAffectDirectDependencies",
32201
32182
  type: "boolean",
@@ -34152,9 +34133,6 @@ var ts;
34152
34133
  if (result.configFilePath) {
34153
34134
  result.configFilePath = toAbsolutePath(result.configFilePath);
34154
34135
  }
34155
- if (result.pathsBasePath) {
34156
- result.pathsBasePath = toAbsolutePath(result.pathsBasePath);
34157
- }
34158
34136
  return result;
34159
34137
  }
34160
34138
  ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
@@ -34980,35 +34958,20 @@ var ts;
34980
34958
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
34981
34959
  return { fileName: resolved.path, packageId: resolved.packageId };
34982
34960
  }
34983
- function createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
34984
- var _a;
34985
- var _b;
34961
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache) {
34962
+ var _a, _b;
34986
34963
  if (resultFromCache) {
34987
- if ((!compilerOptions.cacheResolutions || !((_b = resultFromCache.resolvedModule) === null || _b === void 0 ? void 0 : _b.resolvedFileName)) && failedLookupLocations.length)
34988
- (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
34989
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
34990
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
34964
+ (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
34965
+ (_b = resultFromCache.affectingLocations).push.apply(_b, affectingLocations);
34991
34966
  return resultFromCache;
34992
34967
  }
34993
34968
  return {
34994
34969
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
34995
- failedLookupLocations: !compilerOptions.cacheResolutions || !(resolved === null || resolved === void 0 ? void 0 : resolved.path) ? failedLookupLocations : ts.emptyArray,
34996
- affectingLocations: initializeResolutionField(affectingLocations),
34997
- resolutionDiagnostics: initializeResolutionField(diagnostics),
34970
+ failedLookupLocations: failedLookupLocations,
34971
+ affectingLocations: affectingLocations,
34972
+ resolutionDiagnostics: diagnostics,
34998
34973
  };
34999
34974
  }
35000
- function initializeResolutionField(value) {
35001
- return value.length ? value : undefined;
35002
- }
35003
- function updateResolutionField(to, value) {
35004
- if (!(value === null || value === void 0 ? void 0 : value.length))
35005
- return to;
35006
- if (!(to === null || to === void 0 ? void 0 : to.length))
35007
- return value;
35008
- to.push.apply(to, value);
35009
- return to;
35010
- }
35011
- ts.updateResolutionField = updateResolutionField;
35012
34975
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
35013
34976
  if (!ts.hasProperty(jsonContent, fieldName)) {
35014
34977
  if (state.traceEnabled) {
@@ -35147,7 +35110,8 @@ var ts;
35147
35110
  options = redirectedReference.commandLine.options;
35148
35111
  }
35149
35112
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
35150
- var result = containingDirectory ? cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, typeReferenceDirectiveName, resolutionMode, redirectedReference) : undefined;
35113
+ var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
35114
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
35151
35115
  if (result) {
35152
35116
  if (traceEnabled) {
35153
35117
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -35198,7 +35162,7 @@ var ts;
35198
35162
  features: features,
35199
35163
  conditions: conditions,
35200
35164
  requestContainingDirectory: containingDirectory,
35201
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35165
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35202
35166
  };
35203
35167
  var resolved = primaryLookup();
35204
35168
  var primary = true;
@@ -35218,15 +35182,8 @@ var ts;
35218
35182
  isExternalLibraryImport: pathContainsNodeModules(fileName),
35219
35183
  };
35220
35184
  }
35221
- result = {
35222
- resolvedTypeReferenceDirective: resolvedTypeReferenceDirective,
35223
- failedLookupLocations: !options.cacheResolutions || !(resolvedTypeReferenceDirective === null || resolvedTypeReferenceDirective === void 0 ? void 0 : resolvedTypeReferenceDirective.resolvedFileName) ? failedLookupLocations : ts.emptyArray,
35224
- affectingLocations: initializeResolutionField(affectingLocations),
35225
- resolutionDiagnostics: initializeResolutionField(diagnostics),
35226
- };
35227
- if (containingDirectory && cache) {
35228
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(typeReferenceDirectiveName, resolutionMode, result);
35229
- }
35185
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, affectingLocations: affectingLocations, resolutionDiagnostics: diagnostics };
35186
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
35230
35187
  if (traceEnabled)
35231
35188
  traceResult(result);
35232
35189
  return result;
@@ -35236,10 +35193,10 @@ var ts;
35236
35193
  trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
35237
35194
  }
35238
35195
  else if (result.resolvedTypeReferenceDirective.packageId) {
35239
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), !!result.resolvedTypeReferenceDirective.primary);
35196
+ 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);
35240
35197
  }
35241
35198
  else {
35242
- trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, !!result.resolvedTypeReferenceDirective.primary);
35199
+ trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary);
35243
35200
  }
35244
35201
  }
35245
35202
  function primaryLookup() {
@@ -35319,7 +35276,7 @@ var ts;
35319
35276
  var typeDirectivePath = _b[_a];
35320
35277
  var normalized = ts.normalizePath(typeDirectivePath);
35321
35278
  var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
35322
- var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJsonIgnoringErrors(packageJsonPath, host).typings === null;
35279
+ var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
35323
35280
  if (!isNotNeededPackage) {
35324
35281
  var baseFileName = ts.getBaseFileName(normalized);
35325
35282
  if (baseFileName.charCodeAt(0) !== 46) {
@@ -35334,138 +35291,47 @@ var ts;
35334
35291
  return result;
35335
35292
  }
35336
35293
  ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
35337
- function compilerOptionValueToString(value) {
35338
- var _a;
35339
- if (value === null || typeof value !== "object") {
35340
- return "" + value;
35341
- }
35342
- if (ts.isArray(value)) {
35343
- return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]";
35344
- }
35345
- var str = "{";
35346
- for (var key in value) {
35347
- if (ts.hasProperty(value, key)) {
35348
- str += key + ": " + compilerOptionValueToString(value[key]);
35349
- }
35350
- }
35351
- return str + "}";
35352
- }
35353
- function getKeyForCompilationSettings(settings, options) {
35354
- return options.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + ("|" + settings.pathsBasePath);
35355
- }
35356
- ts.getKeyForCompilationSettings = getKeyForCompilationSettings;
35357
- function getRedirectsCacheKey(options) {
35358
- return getKeyForCompilationSettings(options, ts.moduleResolutionOptionDeclarations);
35359
- }
35360
- ts.getRedirectsCacheKey = getRedirectsCacheKey;
35361
- function createCacheWithRedirects(ownOptions) {
35362
- var ownMap;
35363
- var ownKey;
35364
- var redirectsKeyToCache = new ts.Map();
35294
+ function createCacheWithRedirects(options) {
35295
+ var ownMap = new ts.Map();
35365
35296
  var redirectsMap = new ts.Map();
35366
35297
  return {
35367
35298
  getOwnMap: getOwnMap,
35368
- redirectsKeyToCache: redirectsKeyToCache,
35369
- createMapForCompilerOptions: createMapForCompilerOptions,
35370
- getMapOfCacheRedirects: getMapOfCacheRedirects,
35299
+ redirectsMap: redirectsMap,
35371
35300
  getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
35372
35301
  clear: clear,
35373
- update: update,
35374
- clearRedirectsMap: function () { return redirectsMap.clear(); },
35302
+ setOwnOptions: setOwnOptions,
35303
+ setOwnMap: setOwnMap
35375
35304
  };
35376
- function ensureOwnKeyCached() {
35377
- ownKey !== null && ownKey !== void 0 ? ownKey : (ownKey = ownOptions && getRedirectsCacheKey(ownOptions));
35378
- if (ownKey && !redirectsKeyToCache.has(ownKey))
35379
- redirectsKeyToCache.set(ownKey, { map: ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map()), options: ownOptions });
35380
- }
35381
- function createMapForCompilerOptions(options, optionsKey) {
35382
- if (options === ownOptions)
35383
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35384
- return getOrCreateRedirectMapAndKey(options, undefined, optionsKey);
35385
- }
35386
- function getOrCreateRedirectMapAndKey(options, path, optionsKey) {
35387
- var _a;
35388
- if (path || options.configFile) {
35389
- var redirects = redirectsMap.get(path || options.configFile.path);
35390
- if (redirects)
35391
- return redirects;
35392
- }
35393
- var key = optionsKey || getRedirectsCacheKey(options);
35394
- var map = (_a = redirectsKeyToCache.get(key)) === null || _a === void 0 ? void 0 : _a.map;
35395
- if (!map) {
35396
- ensureOwnKeyCached();
35397
- if (ownKey === key) {
35398
- map = ownMap;
35399
- }
35400
- else {
35401
- redirectsKeyToCache.set(key, { map: map = new ts.Map(), options: options });
35402
- }
35403
- }
35404
- if (path || options.configFile)
35405
- redirectsMap.set(path || options.configFile.path, map);
35406
- return map;
35407
- }
35408
35305
  function getOwnMap() {
35409
- return ownMap !== null && ownMap !== void 0 ? ownMap : (ownMap = new ts.Map());
35306
+ return ownMap;
35410
35307
  }
35411
- function update(newOwnOptions) {
35412
- if (ownMap && (ownOptions === null || ownOptions === void 0 ? void 0 : ownOptions.configFile)) {
35413
- ensureOwnKeyCached();
35414
- if (!redirectsMap.has(ownOptions.configFile.path)) {
35415
- redirectsMap.set(ownOptions.configFile.path, ownMap);
35416
- }
35417
- }
35418
- if (newOwnOptions.configFile) {
35419
- var existing_1 = redirectsMap.get(newOwnOptions.configFile.path);
35420
- if (existing_1) {
35421
- ownMap = existing_1;
35422
- ownOptions = newOwnOptions;
35423
- return;
35424
- }
35425
- }
35426
- var key = getRedirectsCacheKey(newOwnOptions);
35427
- var existing = redirectsKeyToCache.get(key);
35428
- ownMap = (existing === null || existing === void 0 ? void 0 : existing.map) || new ts.Map();
35429
- ownKey = key;
35430
- ownOptions = newOwnOptions;
35431
- if (newOwnOptions.configFile)
35432
- redirectsMap.set(newOwnOptions.configFile.path, ownMap);
35308
+ function setOwnOptions(newOptions) {
35309
+ options = newOptions;
35433
35310
  }
35434
- function getMapOfCacheRedirects(redirectedReference) {
35435
- if (!redirectedReference)
35436
- return ownMap;
35437
- var directResult = redirectsMap.get(redirectedReference.sourceFile.path);
35438
- if (directResult)
35439
- return directResult;
35440
- var key = getRedirectsCacheKey(redirectedReference.commandLine.options);
35441
- var fromKey = redirectsKeyToCache.get(key);
35442
- if (fromKey) {
35443
- redirectsMap.set(redirectedReference.sourceFile.path, fromKey.map);
35444
- return fromKey.map;
35445
- }
35446
- if (ownMap)
35447
- ensureOwnKeyCached();
35448
- if (ownKey === key) {
35449
- redirectsMap.set(redirectedReference.sourceFile.path, ownMap);
35450
- return ownMap;
35451
- }
35452
- return undefined;
35311
+ function setOwnMap(newOwnMap) {
35312
+ ownMap = newOwnMap;
35453
35313
  }
35454
35314
  function getOrCreateMapOfCacheRedirects(redirectedReference) {
35455
- return !redirectedReference || redirectedReference.commandLine.options === ownOptions ?
35456
- getOwnMap() :
35457
- getOrCreateRedirectMapAndKey(redirectedReference.commandLine.options, redirectedReference.sourceFile.path, undefined);
35315
+ if (!redirectedReference) {
35316
+ return ownMap;
35317
+ }
35318
+ var path = redirectedReference.sourceFile.path;
35319
+ var redirects = redirectsMap.get(path);
35320
+ if (!redirects) {
35321
+ redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
35322
+ redirectsMap.set(path, redirects);
35323
+ }
35324
+ return redirects;
35458
35325
  }
35459
35326
  function clear() {
35460
- ownKey = undefined;
35461
- ownMap = undefined;
35327
+ ownMap.clear();
35462
35328
  redirectsMap.clear();
35463
- redirectsKeyToCache.clear();
35464
35329
  }
35465
35330
  }
35466
35331
  ts.createCacheWithRedirects = createCacheWithRedirects;
35467
- function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache) {
35468
- return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, clone: clone };
35332
+ function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
35333
+ var cache;
35334
+ return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
35469
35335
  function getPackageJsonInfo(packageJsonPath) {
35470
35336
  return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
35471
35337
  }
@@ -35479,9 +35345,6 @@ var ts;
35479
35345
  var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
35480
35346
  return iter ? ts.arrayFrom(iter) : [];
35481
35347
  }
35482
- function clone() {
35483
- return createPackageJsonInfoCache(currentDirectory, getCanonicalFileName, cache && new ts.Map(cache));
35484
- }
35485
35348
  }
35486
35349
  function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
35487
35350
  var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
@@ -35492,42 +35355,45 @@ var ts;
35492
35355
  }
35493
35356
  return result;
35494
35357
  }
35358
+ function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35359
+ if (!options.configFile)
35360
+ return;
35361
+ if (directoryToModuleNameMap.redirectsMap.size === 0) {
35362
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
35363
+ ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
35364
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
35365
+ directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
35366
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
35367
+ }
35368
+ else {
35369
+ ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
35370
+ var ref = {
35371
+ sourceFile: options.configFile,
35372
+ commandLine: { options: options }
35373
+ };
35374
+ directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
35375
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
35376
+ }
35377
+ directoryToModuleNameMap.setOwnOptions(options);
35378
+ moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
35379
+ }
35495
35380
  function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
35496
- var oldResolutionCache;
35497
35381
  return {
35498
- getFromCache: getFromCache,
35499
35382
  getOrCreateCacheForDirectory: getOrCreateCacheForDirectory,
35500
35383
  clear: clear,
35501
35384
  update: update,
35502
- setOldResolutionCache: function (cache) { return oldResolutionCache = cache; }
35503
35385
  };
35504
35386
  function clear() {
35505
- oldResolutionCache = undefined;
35506
35387
  directoryToModuleNameMap.clear();
35507
35388
  }
35508
35389
  function update(options) {
35509
- directoryToModuleNameMap.update(options);
35390
+ updateRedirectsMap(options, directoryToModuleNameMap);
35510
35391
  }
35511
35392
  function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
35512
35393
  var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35513
- return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, createModeAwareCache);
35394
+ return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
35514
35395
  }
35515
- function getFromCache(directoryName, name, mode, redirectedReference) {
35516
- var _a, _b;
35517
- var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
35518
- var result = (_b = (_a = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(path)) === null || _b === void 0 ? void 0 : _b.get(name, mode);
35519
- if (result)
35520
- return result;
35521
- var resultFromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(path, name, mode, redirectedReference);
35522
- if (resultFromOld)
35523
- getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, resultFromOld);
35524
- return resultFromOld;
35525
- }
35526
- }
35527
- function getModeAwareCacheKey(specifier, mode) {
35528
- return (mode === undefined ? specifier : mode + "|" + specifier);
35529
35396
  }
35530
- ts.getModeAwareCacheKey = getModeAwareCacheKey;
35531
35397
  function createModeAwareCache() {
35532
35398
  var underlying = new ts.Map();
35533
35399
  var memoizedReverseKeys = new ts.Map();
@@ -35552,22 +35418,13 @@ var ts;
35552
35418
  return cb(elem, specifier, mode);
35553
35419
  });
35554
35420
  },
35555
- entries: function () {
35556
- var keys = underlying.entries();
35557
- return {
35558
- next: function () {
35559
- var next = keys.next();
35560
- return !next.done ? { value: __spreadArray(__spreadArray([], memoizedReverseKeys.get(next.value[0]), true), [next.value[1]], false) } : next;
35561
- },
35562
- };
35563
- },
35564
35421
  size: function () {
35565
35422
  return underlying.size;
35566
- },
35423
+ }
35567
35424
  };
35568
35425
  return cache;
35569
35426
  function getUnderlyingCacheKey(specifier, mode) {
35570
- var result = getModeAwareCacheKey(specifier, mode);
35427
+ var result = mode === undefined ? specifier : mode + "|" + specifier;
35571
35428
  memoizedReverseKeys.set(result, [specifier, mode]);
35572
35429
  return result;
35573
35430
  }
@@ -35578,113 +35435,80 @@ var ts;
35578
35435
  var map = createModeAwareCache();
35579
35436
  for (var i = 0; i < keys.length; ++i) {
35580
35437
  var entry = keys[i];
35581
- var name = !ts.isString(entry) ? ts.toFileNameLowerCase(entry.fileName) : entry;
35438
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
35582
35439
  var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
35583
35440
  map.set(name, mode, values[i]);
35584
35441
  }
35585
35442
  return map;
35586
35443
  }
35587
35444
  ts.zipToModeAwareCache = zipToModeAwareCache;
35588
- function getCommonPrefix(directory, resolution, toPath) {
35589
- var resolutionDirectory = toPath(ts.getDirectoryPath(resolution));
35590
- var i = 0;
35591
- var limit = Math.min(directory.length, resolutionDirectory.length);
35592
- while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35593
- i++;
35594
- }
35595
- if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35596
- return directory;
35597
- }
35598
- var rootLength = ts.getRootLength(directory);
35599
- if (i < rootLength) {
35600
- return undefined;
35601
- }
35602
- var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35603
- if (sep === -1) {
35604
- return undefined;
35605
- }
35606
- return directory.substr(0, Math.max(sep, rootLength));
35607
- }
35608
- function getResolvedFileNameForModuleNameToDirectorySet(result) {
35609
- return result.resolvedModule &&
35610
- (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35611
- }
35612
- ts.getResolvedFileNameForModuleNameToDirectorySet = getResolvedFileNameForModuleNameToDirectorySet;
35613
- function moduleNameToDirectorySet(directoryPathMap, directory, result, getResolvedFileName, toPath, ancestoryWorker) {
35614
- if (directoryPathMap.has(directory))
35615
- return;
35616
- directoryPathMap.set(directory, result);
35617
- var resolvedFileName = getResolvedFileName(result);
35618
- var commonPrefix = resolvedFileName && getCommonPrefix(directory, resolvedFileName, toPath);
35619
- var current = directory;
35620
- while (current !== commonPrefix) {
35621
- var parent = ts.getDirectoryPath(current);
35622
- if (parent === current)
35623
- break;
35624
- if (directoryPathMap.has(parent)) {
35625
- ancestoryWorker(parent);
35626
- break;
35627
- }
35628
- directoryPathMap.set(parent, result);
35629
- ancestoryWorker(parent);
35630
- current = parent;
35631
- }
35632
- }
35633
- ts.moduleNameToDirectorySet = moduleNameToDirectorySet;
35634
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
35635
- var directoryToModuleNameMap = createCacheWithRedirects(options);
35636
- var moduleNameToDirectoryMap = createCacheWithRedirects(options);
35637
- var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35445
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
35446
+ var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35447
+ moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
35638
35448
  var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
35639
- var oldResolutionCache;
35640
- return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, getFromModuleNameCache: getFromModuleNameCache, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, setOldResolutionCache: setOldResolutionCache });
35449
+ return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } });
35641
35450
  function clear() {
35642
- oldResolutionCache = undefined;
35643
- perDirectoryResolutionCache.clear();
35451
+ preDirectoryResolutionCache.clear();
35644
35452
  moduleNameToDirectoryMap.clear();
35645
35453
  packageJsonInfoCache.clear();
35646
35454
  }
35647
35455
  function update(options) {
35648
- directoryToModuleNameMap.update(options);
35649
- moduleNameToDirectoryMap.update(options);
35650
- }
35651
- function setOldResolutionCache(cache) {
35652
- oldResolutionCache = cache;
35653
- perDirectoryResolutionCache.setOldResolutionCache(cache);
35654
- }
35655
- function getFromModuleNameCache(directoryName, nonRelativeModuleName, mode, redirectedReference) {
35656
- var _a, _b;
35657
- ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35658
- var result = (_b = (_a = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(getModeAwareCacheKey(nonRelativeModuleName, mode))) === null || _b === void 0 ? void 0 : _b.get(directoryName);
35659
- if (result)
35660
- return result;
35661
- var fromOld = oldResolutionCache === null || oldResolutionCache === void 0 ? void 0 : oldResolutionCache.getResolved(toPath(directoryName), nonRelativeModuleName, mode, redirectedReference);
35662
- if (fromOld)
35663
- getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference).set(directoryName, fromOld);
35664
- return fromOld;
35456
+ updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
35665
35457
  }
35666
35458
  function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
35667
35459
  ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
35668
- return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, getModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
35460
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
35669
35461
  }
35670
35462
  function createPerModuleNameCache() {
35671
35463
  var directoryPathMap = new ts.Map();
35672
35464
  return { get: get, set: set };
35673
35465
  function get(directory) {
35674
- return directoryPathMap.get(toPath(directory));
35466
+ return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
35675
35467
  }
35676
35468
  function set(directory, result) {
35677
- return moduleNameToDirectorySet(directoryPathMap, toPath(directory), result, getResolvedFileNameForModuleNameToDirectorySet, toPath, ts.noop);
35469
+ var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
35470
+ if (directoryPathMap.has(path)) {
35471
+ return;
35472
+ }
35473
+ directoryPathMap.set(path, result);
35474
+ var resolvedFileName = result.resolvedModule &&
35475
+ (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
35476
+ var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
35477
+ var current = path;
35478
+ while (current !== commonPrefix) {
35479
+ var parent = ts.getDirectoryPath(current);
35480
+ if (parent === current || directoryPathMap.has(parent)) {
35481
+ break;
35482
+ }
35483
+ directoryPathMap.set(parent, result);
35484
+ current = parent;
35485
+ }
35486
+ }
35487
+ function getCommonPrefix(directory, resolution) {
35488
+ var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
35489
+ var i = 0;
35490
+ var limit = Math.min(directory.length, resolutionDirectory.length);
35491
+ while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
35492
+ i++;
35493
+ }
35494
+ if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
35495
+ return directory;
35496
+ }
35497
+ var rootLength = ts.getRootLength(directory);
35498
+ if (i < rootLength) {
35499
+ return undefined;
35500
+ }
35501
+ var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
35502
+ if (sep === -1) {
35503
+ return undefined;
35504
+ }
35505
+ return directory.substr(0, Math.max(sep, rootLength));
35678
35506
  }
35679
- }
35680
- function toPath(fileName) {
35681
- return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
35682
35507
  }
35683
35508
  }
35684
35509
  ts.createModuleResolutionCache = createModuleResolutionCache;
35685
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
35686
- var directoryToModuleNameMap = createCacheWithRedirects(options);
35687
- var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
35510
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
35511
+ var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
35688
35512
  packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
35689
35513
  return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear });
35690
35514
  function clear() {
@@ -35695,7 +35519,10 @@ var ts;
35695
35519
  ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
35696
35520
  function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
35697
35521
  var containingDirectory = ts.getDirectoryPath(containingFile);
35698
- return cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, mode);
35522
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
35523
+ if (!perFolderCache)
35524
+ return undefined;
35525
+ return perFolderCache.get(moduleName, mode);
35699
35526
  }
35700
35527
  ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
35701
35528
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
@@ -35710,7 +35537,8 @@ var ts;
35710
35537
  }
35711
35538
  }
35712
35539
  var containingDirectory = ts.getDirectoryPath(containingFile);
35713
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromCache(containingDirectory, moduleName, resolutionMode, redirectedReference);
35540
+ var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
35541
+ var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
35714
35542
  if (result) {
35715
35543
  if (traceEnabled) {
35716
35544
  trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -35762,8 +35590,8 @@ var ts;
35762
35590
  if (result && result.resolvedModule)
35763
35591
  ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
35764
35592
  ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
35765
- if (cache) {
35766
- cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
35593
+ if (perFolderCache) {
35594
+ perFolderCache.set(moduleName, resolutionMode, result);
35767
35595
  if (!ts.isExternalModuleNameRelative(moduleName)) {
35768
35596
  cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
35769
35597
  }
@@ -35967,10 +35795,10 @@ var ts;
35967
35795
  features: features,
35968
35796
  conditions: conditions,
35969
35797
  requestContainingDirectory: containingDirectory,
35970
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
35798
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35971
35799
  };
35972
35800
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
35973
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
35801
+ 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);
35974
35802
  function tryResolve(extensions) {
35975
35803
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
35976
35804
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -36306,7 +36134,7 @@ var ts;
36306
36134
  features: NodeResolutionFeatures.None,
36307
36135
  conditions: ts.emptyArray,
36308
36136
  requestContainingDirectory: undefined,
36309
- reportResolutionDiagnostic: ts.noop
36137
+ reportDiagnostic: ts.noop
36310
36138
  };
36311
36139
  }
36312
36140
  ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
@@ -36348,13 +36176,12 @@ var ts;
36348
36176
  }
36349
36177
  var directoryExists = ts.directoryProbablyExists(packageDirectory, host);
36350
36178
  if (directoryExists && host.fileExists(packageJsonPath)) {
36351
- var packageJsonText = host.readFile(packageJsonPath);
36352
- var packageJsonContent = ts.readJsonIgnoringErrorsFromText(packageJsonPath, packageJsonText);
36179
+ var packageJsonContent = ts.readJson(packageJsonPath, host);
36353
36180
  if (traceEnabled) {
36354
36181
  trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
36355
36182
  }
36356
36183
  var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
36357
- var result = { packageDirectory: packageDirectory, packageJsonText: packageJsonText, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36184
+ var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
36358
36185
  (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
36359
36186
  state.affectingLocations.push(packageJsonPath);
36360
36187
  return result;
@@ -36726,8 +36553,11 @@ var ts;
36726
36553
  fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
36727
36554
  }
36728
36555
  }
36729
- if (commonSourceDirGuesses.length > 1)
36730
- state.reportResolutionDiagnostic({ isImports: isImports, entry: entry, packagePath: packagePath });
36556
+ if (commonSourceDirGuesses.length > 1) {
36557
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
36558
+ ? 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
36559
+ : 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));
36560
+ }
36731
36561
  for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
36732
36562
  var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
36733
36563
  var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
@@ -36792,10 +36622,10 @@ var ts;
36792
36622
  return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
36793
36623
  }
36794
36624
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
36795
- var mode = state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
36625
+ var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
36796
36626
  return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
36797
36627
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
36798
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, ancestorDirectory, redirectedReference, state);
36628
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
36799
36629
  if (resolutionFromCache) {
36800
36630
  return resolutionFromCache;
36801
36631
  }
@@ -36932,8 +36762,8 @@ var ts;
36932
36762
  typesPackageName;
36933
36763
  }
36934
36764
  ts.unmangleScopedPackageName = unmangleScopedPackageName;
36935
- function tryFindNonRelativeModuleNameInCache(cache, moduleName, mode, containingDirectory, redirectedReference, state) {
36936
- var result = cache === null || cache === void 0 ? void 0 : cache.getFromModuleNameCache(containingDirectory, moduleName, mode, redirectedReference);
36765
+ function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
36766
+ var result = cache && cache.get(containingDirectory);
36937
36767
  if (result) {
36938
36768
  if (state.traceEnabled) {
36939
36769
  trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
@@ -36958,18 +36788,19 @@ var ts;
36958
36788
  features: NodeResolutionFeatures.None,
36959
36789
  conditions: [],
36960
36790
  requestContainingDirectory: containingDirectory,
36961
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36791
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
36962
36792
  };
36963
36793
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
36964
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36794
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36965
36795
  function tryResolve(extensions) {
36966
36796
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
36967
36797
  if (resolvedUsingSettings) {
36968
36798
  return { value: resolvedUsingSettings };
36969
36799
  }
36970
36800
  if (!ts.isExternalModuleNameRelative(moduleName)) {
36801
+ var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, undefined, redirectedReference);
36971
36802
  var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
36972
- var resolutionFromCache = tryFindNonRelativeModuleNameInCache(cache, moduleName, undefined, directory, redirectedReference, state);
36803
+ var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
36973
36804
  if (resolutionFromCache) {
36974
36805
  return resolutionFromCache;
36975
36806
  }
@@ -37008,10 +36839,10 @@ var ts;
37008
36839
  features: NodeResolutionFeatures.None,
37009
36840
  conditions: [],
37010
36841
  requestContainingDirectory: undefined,
37011
- reportResolutionDiagnostic: function (diag) { return void diagnostics.push(diag); },
36842
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
37012
36843
  };
37013
36844
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
37014
- return createResolvedModuleWithFailedLookupLocations(compilerOptions, resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
36845
+ return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
37015
36846
  }
37016
36847
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
37017
36848
  function toSearchResult(value) {
@@ -40004,10 +39835,9 @@ var ts;
40004
39835
  host.getSourceFiles().forEach(function (sf) {
40005
39836
  if (!sf.resolvedModules)
40006
39837
  return;
40007
- sf.resolvedModules.forEach(function (_a) {
40008
- var resolvedModule = _a.resolvedModule;
40009
- if (resolvedModule === null || resolvedModule === void 0 ? void 0 : resolvedModule.packageId)
40010
- map.set(resolvedModule.packageId.name, resolvedModule.extension === ".d.ts" || !!map.get(resolvedModule.packageId.name));
39838
+ sf.resolvedModules.forEach(function (r) {
39839
+ if (r && r.packageId)
39840
+ map.set(r.packageId.name, r.extension === ".d.ts" || !!map.get(r.packageId.name));
40011
39841
  });
40012
39842
  });
40013
39843
  return map;
@@ -74233,12 +74063,11 @@ var ts;
74233
74063
  var fileToDirective;
74234
74064
  if (resolvedTypeReferenceDirectives) {
74235
74065
  fileToDirective = new ts.Map();
74236
- resolvedTypeReferenceDirectives.forEach(function (_a, key, mode) {
74237
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
74238
- if (!resolvedTypeReferenceDirective || !resolvedTypeReferenceDirective.resolvedFileName) {
74066
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
74067
+ if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
74239
74068
  return;
74240
74069
  }
74241
- var file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName);
74070
+ var file = host.getSourceFile(resolvedDirective.resolvedFileName);
74242
74071
  if (file) {
74243
74072
  addReferencedFilesToTypeDirective(file, key, mode);
74244
74073
  }
@@ -91983,7 +91812,7 @@ var ts;
91983
91812
  var sourceMap = sourceMapGenerator.toString();
91984
91813
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
91985
91814
  if (printer.bundleFileInfo)
91986
- printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, host);
91815
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
91987
91816
  }
91988
91817
  }
91989
91818
  else {
@@ -91992,7 +91821,7 @@ var ts;
91992
91821
  var text = writer.getText();
91993
91822
  ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
91994
91823
  if (printer.bundleFileInfo)
91995
- printer.bundleFileInfo.hash = ts.computeSignature(text, host);
91824
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
91996
91825
  writer.clear();
91997
91826
  }
91998
91827
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92117,6 +91946,7 @@ var ts;
92117
91946
  });
92118
91947
  }
92119
91948
  function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
91949
+ var createHash = ts.maybeBind(host, host.createHash);
92120
91950
  var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
92121
91951
  var buildInfo;
92122
91952
  if (host.getBuildInfo) {
@@ -92136,22 +91966,22 @@ var ts;
92136
91966
  var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
92137
91967
  if (!jsFileText)
92138
91968
  return jsFilePath;
92139
- if (ts.computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
91969
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92140
91970
  return jsFilePath;
92141
91971
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92142
91972
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
92143
91973
  return sourceMapFilePath || "inline sourcemap decoding";
92144
- if (sourceMapFilePath && ts.computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
91974
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92145
91975
  return sourceMapFilePath;
92146
91976
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
92147
91977
  if (declarationFilePath && !declarationText)
92148
91978
  return declarationFilePath;
92149
- if (declarationFilePath && ts.computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
91979
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92150
91980
  return declarationFilePath;
92151
91981
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92152
91982
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
92153
91983
  return declarationMapPath || "inline sourcemap decoding";
92154
- if (declarationMapPath && ts.computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
91984
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92155
91985
  return declarationMapPath;
92156
91986
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92157
91987
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
@@ -92189,7 +92019,7 @@ var ts;
92189
92019
  var newBuildInfo = data.buildInfo;
92190
92020
  newBuildInfo.program = buildInfo.program;
92191
92021
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
92192
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, host, changedDtsData);
92022
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
92193
92023
  }
92194
92024
  var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
92195
92025
  newBuildInfo.bundle.js.sources = js.sources;
@@ -92222,7 +92052,7 @@ var ts;
92222
92052
  getSourceFileFromReference: ts.returnUndefined,
92223
92053
  redirectTargetsMap: ts.createMultiMap(),
92224
92054
  getFileIncludeReasons: ts.notImplemented,
92225
- createHash: ts.maybeBind(host, host.createHash),
92055
+ createHash: createHash,
92226
92056
  };
92227
92057
  emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
92228
92058
  return outputFiles;
@@ -97206,7 +97036,7 @@ var ts;
97206
97036
  var name = names_2[_i];
97207
97037
  var result = void 0;
97208
97038
  var mode = getModeForFileReference(name, containingFileMode);
97209
- var strName = ts.isString(name) ? name : ts.toFileNameLowerCase(name.fileName);
97039
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
97210
97040
  var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
97211
97041
  if (cache.has(cacheKey)) {
97212
97042
  result = cache.get(cacheKey);
@@ -97290,21 +97120,7 @@ var ts;
97290
97120
  return elem.value.text === "import" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
97291
97121
  }
97292
97122
  ts.getResolutionModeOverrideForClause = getResolutionModeOverrideForClause;
97293
- var emptyResolution = {
97294
- resolvedModule: undefined,
97295
- resolvedTypeReferenceDirective: undefined,
97296
- failedLookupLocations: [],
97297
- affectingLocations: [],
97298
- resolutionDiagnostics: [],
97299
- };
97300
- function isResolvedModuleWithFailedLookupLocation(resolved) {
97301
- return !!resolved && !!resolved.failedLookupLocations;
97302
- }
97303
- function isResolvedTypeReferenceDirectiveWithFailedLookupLocations(resolved) {
97304
- return !!resolved && !!resolved.failedLookupLocations;
97305
- }
97306
- function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader) {
97307
- var _a;
97123
+ function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
97308
97124
  if (names.length === 0) {
97309
97125
  return [];
97310
97126
  }
@@ -97314,7 +97130,7 @@ var ts;
97314
97130
  for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
97315
97131
  var name = names_3[_i];
97316
97132
  var result = void 0;
97317
- var mode = getModeForResolutionAtIndex(containingFile, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _a !== void 0 ? _a : i);
97133
+ var mode = getModeForResolutionAtIndex(containingFile, i);
97318
97134
  i++;
97319
97135
  var cacheKey = mode !== undefined ? mode + "|" + name : name;
97320
97136
  if (cache.has(cacheKey)) {
@@ -97372,14 +97188,14 @@ var ts;
97372
97188
  ts.isReferenceFileLocation = isReferenceFileLocation;
97373
97189
  function getReferencedFileLocation(getSourceFileByPath, ref) {
97374
97190
  var _a, _b, _c;
97375
- var _d, _e, _f, _g, _h, _j;
97191
+ var _d, _e, _f, _g;
97376
97192
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
97377
97193
  var kind = ref.kind, index = ref.index;
97378
97194
  var pos, end, packageId, resolutionMode;
97379
97195
  switch (kind) {
97380
97196
  case ts.FileIncludeKind.Import:
97381
97197
  var importLiteral = getModuleNameStringLiteralAt(file, index);
97382
- packageId = (_f = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.resolvedModule) === null || _f === void 0 ? void 0 : _f.packageId;
97198
+ 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;
97383
97199
  if (importLiteral.pos === -1)
97384
97200
  return { file: file, packageId: packageId, text: importLiteral.text };
97385
97201
  pos = ts.skipTrivia(file.text, importLiteral.pos);
@@ -97390,7 +97206,7 @@ var ts;
97390
97206
  break;
97391
97207
  case ts.FileIncludeKind.TypeReferenceDirective:
97392
97208
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
97393
- packageId = (_j = (_h = (_g = file.resolvedTypeReferenceDirectiveNames) === null || _g === void 0 ? void 0 : _g.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _h === void 0 ? void 0 : _h.resolvedTypeReferenceDirective) === null || _j === void 0 ? void 0 : _j.packageId;
97209
+ 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;
97394
97210
  break;
97395
97211
  case ts.FileIncludeKind.LibReferenceDirective:
97396
97212
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -97582,10 +97398,10 @@ var ts;
97582
97398
  };
97583
97399
  }
97584
97400
  function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
97585
- var _a, _b, _c, _d, _e;
97401
+ var _a, _b, _c, _d;
97586
97402
  var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
97587
97403
  var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
97588
- var oldProgramOrOldBuildInfoProgramConstructor = createProgramOptions.oldProgram;
97404
+ var oldProgram = createProgramOptions.oldProgram;
97589
97405
  var processingDefaultLibFiles;
97590
97406
  var processingOtherFiles;
97591
97407
  var files;
@@ -97599,8 +97415,6 @@ var ts;
97599
97415
  var cachedDeclarationDiagnosticsForFile = {};
97600
97416
  var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
97601
97417
  var fileProcessingDiagnostics;
97602
- var automaticTypeDirectiveNames;
97603
- var automaticTypeDirectiveResolutions;
97604
97418
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
97605
97419
  var currentNodeModulesDepth = 0;
97606
97420
  var modulesWithElidedImports = new ts.Map();
@@ -97623,69 +97437,29 @@ var ts;
97623
97437
  var actualResolveModuleNamesWorker;
97624
97438
  var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
97625
97439
  if (host.resolveModuleNames) {
97626
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97627
- var _a;
97628
- var result = host.resolveModuleNames(moduleNames, containingFileName, (_a = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _a === void 0 ? void 0 : _a.map(function (_a) {
97629
- var name = _a.name;
97630
- return name;
97631
- }), redirectedReference, options, containingFile, partialResolutionInfo);
97632
- return result.some(isResolvedModuleWithFailedLookupLocation) ?
97633
- result :
97634
- result.map(function (resolved) { return resolved ?
97635
- resolved.extension !== undefined ?
97636
- { resolvedModule: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97637
- { resolvedModule: __assign(__assign({}, resolved), { extension: ts.extensionFromPath(resolved.resolvedFileName) }), failedLookupLocations: emptyResolution.failedLookupLocations } :
97638
- emptyResolution; });
97639
- };
97440
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
97441
+ if (!resolved || resolved.extension !== undefined) {
97442
+ return resolved;
97443
+ }
97444
+ var withExtension = ts.clone(resolved);
97445
+ withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
97446
+ return withExtension;
97447
+ }); };
97640
97448
  moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
97641
97449
  }
97642
97450
  else {
97643
97451
  moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
97644
- var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode); };
97645
- actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo) {
97646
- return loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, partialResolutionInfo, loader_1);
97647
- };
97452
+ var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
97453
+ actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
97648
97454
  }
97649
97455
  var actualResolveTypeReferenceDirectiveNamesWorker;
97650
97456
  if (host.resolveTypeReferenceDirectives) {
97651
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
97652
- var result = host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, options, containingFileMode, partialResolutionInfo);
97653
- return result.some(isResolvedTypeReferenceDirectiveWithFailedLookupLocations) ?
97654
- result :
97655
- result.map(function (resolved) { return resolved ?
97656
- { resolvedTypeReferenceDirective: resolved, failedLookupLocations: emptyResolution.failedLookupLocations } :
97657
- emptyResolution; });
97658
- };
97659
- typeReferenceDirectiveResolutionCache = (_b = host.getTypeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.call(host);
97457
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
97660
97458
  }
97661
97459
  else {
97662
97460
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
97663
- var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); };
97664
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) {
97665
- return loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_2);
97666
- };
97667
- }
97668
- var oldProgram = typeof oldProgramOrOldBuildInfoProgramConstructor === "object" ? oldProgramOrOldBuildInfoProgramConstructor : undefined;
97669
- var oldBuildInfoProgram;
97670
- if (!oldProgram && typeof oldProgramOrOldBuildInfoProgramConstructor === "function") {
97671
- var state_11 = ts.getTemporaryModuleResolutionState(moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
97672
- oldBuildInfoProgram = oldProgramOrOldBuildInfoProgramConstructor({
97673
- fileExists: function (fileName) { return host.fileExists(fileName); },
97674
- createHash: ts.maybeBind(host, host.createHash),
97675
- getPackageJsonInfo: function (fileName) { return ts.getPackageJsonInfo(ts.getDirectoryPath(fileName), false, state_11); },
97676
- });
97677
- if (oldBuildInfoProgram) {
97678
- moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.setOldResolutionCache({
97679
- getResolved: function (dirPath, name, mode, redirectedReference) {
97680
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedModule(dirPath, name, mode, redirectedReference);
97681
- }
97682
- });
97683
- typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.setOldResolutionCache({
97684
- getResolved: function (dirPath, name, mode, redirectedReference) {
97685
- return oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getResolvedTypeReferenceDirective(dirPath, name, mode, redirectedReference);
97686
- }
97687
- });
97688
- }
97461
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
97462
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
97689
97463
  }
97690
97464
  var packageIdToSourceFile = new ts.Map();
97691
97465
  var sourceFileToPackageName = new ts.Map();
@@ -97698,9 +97472,9 @@ var ts;
97698
97472
  var projectReferenceRedirects;
97699
97473
  var mapFromFileToProjectReferenceRedirects;
97700
97474
  var mapFromToProjectReferenceRedirectSource;
97701
- var useSourceOfProjectReferenceRedirect = !!((_c = host.useSourceOfProjectReferenceRedirect) === null || _c === void 0 ? void 0 : _c.call(host)) &&
97475
+ var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
97702
97476
  !options.disableSourceOfProjectReferenceRedirect;
97703
- var _f = updateHostForUseSourceOfProjectReferenceRedirect({
97477
+ var _e = updateHostForUseSourceOfProjectReferenceRedirect({
97704
97478
  compilerHost: host,
97705
97479
  getSymlinkCache: getSymlinkCache,
97706
97480
  useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
@@ -97708,7 +97482,7 @@ var ts;
97708
97482
  getResolvedProjectReferences: getResolvedProjectReferences,
97709
97483
  getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
97710
97484
  forEachResolvedProjectReference: forEachResolvedProjectReference
97711
- }), onProgramCreateComplete = _f.onProgramCreateComplete, fileExists = _f.fileExists, directoryExists = _f.directoryExists;
97485
+ }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
97712
97486
  var readFile = host.readFile.bind(host);
97713
97487
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
97714
97488
  var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
@@ -97717,7 +97491,7 @@ var ts;
97717
97491
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
97718
97492
  structureIsReused = tryReuseStructureFromOldProgram();
97719
97493
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97720
- if (structureIsReused !== 3) {
97494
+ if (structureIsReused !== 2) {
97721
97495
  processingDefaultLibFiles = [];
97722
97496
  processingOtherFiles = [];
97723
97497
  if (projectReferences) {
@@ -97757,14 +97531,14 @@ var ts;
97757
97531
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
97758
97532
  ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
97759
97533
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97760
- automaticTypeDirectiveNames !== null && automaticTypeDirectiveNames !== void 0 ? automaticTypeDirectiveNames : (automaticTypeDirectiveNames = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray);
97761
- automaticTypeDirectiveResolutions = ts.createModeAwareCache();
97762
- if (automaticTypeDirectiveNames.length) {
97763
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: automaticTypeDirectiveNames.length });
97764
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, getAutomaticTypeDirectiveContainingFile());
97765
- for (var i = 0; i < automaticTypeDirectiveNames.length; i++) {
97766
- automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], undefined, resolutions[i]);
97767
- processTypeReferenceDirective(automaticTypeDirectiveNames[i], undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: automaticTypeDirectiveNames[i], packageId: (_d = resolutions[i].resolvedTypeReferenceDirective) === null || _d === void 0 ? void 0 : _d.packageId });
97534
+ var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
97535
+ if (typeReferences.length) {
97536
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
97537
+ var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97538
+ var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97539
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
97540
+ for (var i = 0; i < typeReferences.length; i++) {
97541
+ 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 });
97768
97542
  }
97769
97543
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97770
97544
  }
@@ -97795,13 +97569,13 @@ var ts;
97795
97569
  var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
97796
97570
  if (shouldCreateNewSourceFile || !newFile ||
97797
97571
  (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
97798
- host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions());
97572
+ host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
97799
97573
  }
97800
97574
  }
97801
97575
  if (!host.getParsedCommandLine) {
97802
97576
  oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
97803
97577
  if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
97804
- host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions());
97578
+ host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
97805
97579
  }
97806
97580
  });
97807
97581
  }
@@ -97817,8 +97591,6 @@ var ts;
97817
97591
  }
97818
97592
  typeReferenceDirectiveResolutionCache = undefined;
97819
97593
  oldProgram = undefined;
97820
- oldBuildInfoProgram = undefined;
97821
- oldProgramOrOldBuildInfoProgramConstructor = undefined;
97822
97594
  var program = {
97823
97595
  getRootFileNames: function () { return rootNames; },
97824
97596
  getSourceFile: getSourceFile,
@@ -97826,7 +97598,6 @@ var ts;
97826
97598
  getSourceFiles: function () { return files; },
97827
97599
  getMissingFilePaths: function () { return missingFilePaths; },
97828
97600
  getModuleResolutionCache: function () { return moduleResolutionCache; },
97829
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
97830
97601
  getFilesByNameMap: function () { return filesByName; },
97831
97602
  getCompilerOptions: function () { return options; },
97832
97603
  getSyntacticDiagnostics: getSyntacticDiagnostics,
@@ -97851,9 +97622,6 @@ var ts;
97851
97622
  getRelationCacheSizes: function () { return getTypeChecker().getRelationCacheSizes(); },
97852
97623
  getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
97853
97624
  getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
97854
- getAutomaticTypeDirectiveNames: function () { return automaticTypeDirectiveNames; },
97855
- getAutomaticTypeDirectiveResolutions: function () { return automaticTypeDirectiveResolutions; },
97856
- getAutomaticTypeDirectiveContainingFile: getAutomaticTypeDirectiveContainingFile,
97857
97625
  isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
97858
97626
  isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
97859
97627
  getSourceFileFromReference: getSourceFileFromReference,
@@ -97863,12 +97631,12 @@ var ts;
97863
97631
  usesUriStyleNodeCoreModules: usesUriStyleNodeCoreModules,
97864
97632
  isEmittedFile: isEmittedFile,
97865
97633
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
97634
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
97866
97635
  getProjectReferences: getProjectReferences,
97867
97636
  getResolvedProjectReferences: getResolvedProjectReferences,
97868
97637
  getProjectReferenceRedirect: getProjectReferenceRedirect,
97869
97638
  getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
97870
97639
  getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
97871
- getRedirectReferenceForResolution: getRedirectReferenceForResolution,
97872
97640
  forEachResolvedProjectReference: forEachResolvedProjectReference,
97873
97641
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
97874
97642
  emitBuildInfo: emitBuildInfo,
@@ -97876,7 +97644,7 @@ var ts;
97876
97644
  readFile: readFile,
97877
97645
  directoryExists: directoryExists,
97878
97646
  getSymlinkCache: getSymlinkCache,
97879
- realpath: (_e = host.realpath) === null || _e === void 0 ? void 0 : _e.bind(host),
97647
+ realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
97880
97648
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
97881
97649
  getFileIncludeReasons: function () { return fileReasons; },
97882
97650
  structureIsReused: structureIsReused,
@@ -97890,8 +97658,6 @@ var ts;
97890
97658
  case 0:
97891
97659
  var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
97892
97660
  return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false)));
97893
- case 2:
97894
- return diagnostic.diagnostics.forEach(function (d) { return programDiagnostics.add(d); });
97895
97661
  default:
97896
97662
  ts.Debug.assertNever(diagnostic);
97897
97663
  }
@@ -97901,44 +97667,57 @@ var ts;
97901
97667
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
97902
97668
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97903
97669
  return program;
97904
- function getAutomaticTypeDirectiveContainingFile() {
97905
- var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
97906
- return ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
97670
+ function addResolutionDiagnostics(list) {
97671
+ if (!list)
97672
+ return;
97673
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
97674
+ var elem = list_3[_i];
97675
+ programDiagnostics.add(elem);
97676
+ }
97907
97677
  }
97908
- function addResolutionDiagnostics(resolution) {
97909
- if (!resolution.resolutionDiagnostics)
97678
+ function pullDiagnosticsFromCache(names, containingFile) {
97679
+ var _a;
97680
+ if (!moduleResolutionCache)
97910
97681
  return;
97911
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
97912
- kind: 2,
97913
- diagnostics: resolution.resolutionDiagnostics.map(function (d) { return ts.createCompilerDiagnostic(d.isImports
97914
- ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
97915
- : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, d.entry === "" ? "." : d.entry, d.packagePath); })
97916
- });
97682
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97683
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97684
+ var containingDir = ts.getDirectoryPath(containingFileName);
97685
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
97686
+ var i = 0;
97687
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
97688
+ var n = names_4[_i];
97689
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
97690
+ var name = typeof n === "string" ? n : n.fileName;
97691
+ i++;
97692
+ if (ts.isExternalModuleNameRelative(name))
97693
+ continue;
97694
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
97695
+ addResolutionDiagnostics(diags);
97696
+ }
97917
97697
  }
97918
- function resolveModuleNamesWorker(moduleNames, containingFile, partialResolutionInfo, redirectedReference) {
97698
+ function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
97919
97699
  if (!moduleNames.length)
97920
97700
  return ts.emptyArray;
97921
97701
  var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
97922
- if (redirectedReference === undefined)
97923
- redirectedReference = getRedirectReferenceForResolution(containingFile);
97702
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
97924
97703
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
97925
97704
  ts.performance.mark("beforeResolveModule");
97926
- var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference || undefined, partialResolutionInfo);
97705
+ var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
97927
97706
  ts.performance.mark("afterResolveModule");
97928
97707
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
97929
97708
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
97709
+ pullDiagnosticsFromCache(moduleNames, containingFile);
97930
97710
  return result;
97931
97711
  }
97932
- function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, partialResolutionInfo, redirectedReference) {
97712
+ function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
97933
97713
  if (!typeDirectiveNames.length)
97934
97714
  return [];
97935
97715
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
97936
- if (redirectedReference === undefined && !ts.isString(containingFile))
97937
- redirectedReference = getRedirectReferenceForResolution(containingFile);
97716
+ var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
97938
97717
  var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
97939
97718
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
97940
97719
  ts.performance.mark("beforeResolveTypeReference");
97941
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference || undefined, containingFileMode, partialResolutionInfo);
97720
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
97942
97721
  ts.performance.mark("afterResolveTypeReference");
97943
97722
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
97944
97723
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -97984,6 +97763,9 @@ var ts;
97984
97763
  }
97985
97764
  return ts.libs.length + 2;
97986
97765
  }
97766
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
97767
+ return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
97768
+ }
97987
97769
  function toPath(fileName) {
97988
97770
  return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
97989
97771
  }
@@ -98007,9 +97789,8 @@ var ts;
98007
97789
  return classifiableNames;
98008
97790
  }
98009
97791
  function resolveModuleNamesReusingOldState(moduleNames, file) {
98010
- var _a;
98011
97792
  if (structureIsReused === 0 && !file.ambientModuleNames.length) {
98012
- return resolveModuleNamesWorker(moduleNames, file, undefined, undefined);
97793
+ return resolveModuleNamesWorker(moduleNames, file, undefined);
98013
97794
  }
98014
97795
  var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
98015
97796
  if (oldSourceFile !== file && file.resolvedModules) {
@@ -98024,34 +97805,21 @@ var ts;
98024
97805
  return result_14;
98025
97806
  }
98026
97807
  var unknownModuleNames;
98027
- var unknownModuleNamesIndex;
98028
- var reusedNames;
98029
97808
  var result;
98030
- var predictedToResolveToAmbientModuleMarker = true;
98031
- var redirectedReference;
97809
+ var reusedNames;
97810
+ var predictedToResolveToAmbientModuleMarker = {};
98032
97811
  for (var i = 0; i < moduleNames.length; i++) {
98033
97812
  var moduleName = moduleNames[i];
98034
- if (oldBuildInfoProgram || file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
98035
- var mode = getModeForResolutionAtIndex(file, i);
98036
- var oldResolution = !oldBuildInfoProgram ?
98037
- (_a = oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(moduleName, mode) :
98038
- oldBuildInfoProgram.getResolvedModule(ts.getDirectoryPath(file.path), moduleName, mode, (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(file) || false) : redirectedReference) || undefined);
98039
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedModule) {
97813
+ if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
97814
+ var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
97815
+ if (oldResolvedModule) {
98040
97816
  if (ts.isTraceEnabled(options, host)) {
98041
- var fileLocation = ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory);
98042
- if (!oldBuildInfoProgram) {
98043
- ts.trace(host, oldResolution.resolvedModule.packageId ?
98044
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98045
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, fileLocation, oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
98046
- }
98047
- else {
98048
- ts.trace(host, oldResolution.resolvedModule.packageId ?
98049
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
98050
- ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, moduleName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedModule.resolvedFileName, oldResolution.resolvedModule.packageId && ts.packageIdToString(oldResolution.resolvedModule.packageId));
98051
- }
97817
+ ts.trace(host, oldResolvedModule.packageId ?
97818
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
97819
+ 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));
98052
97820
  }
98053
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = oldResolution;
98054
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: moduleName, mode: mode });
97821
+ (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
97822
+ (reusedNames || (reusedNames = [])).push(moduleName);
98055
97823
  continue;
98056
97824
  }
98057
97825
  }
@@ -98066,15 +97834,14 @@ var ts;
98066
97834
  resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
98067
97835
  }
98068
97836
  if (resolvesToAmbientModuleInNonModifiedFile) {
98069
- (result !== null && result !== void 0 ? result : (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
97837
+ (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
98070
97838
  }
98071
97839
  else {
98072
- (unknownModuleNames !== null && unknownModuleNames !== void 0 ? unknownModuleNames : (unknownModuleNames = [])).push(moduleName);
98073
- (unknownModuleNamesIndex !== null && unknownModuleNamesIndex !== void 0 ? unknownModuleNamesIndex : (unknownModuleNamesIndex = [])).push(i);
97840
+ (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
98074
97841
  }
98075
97842
  }
98076
97843
  var resolutions = unknownModuleNames && unknownModuleNames.length
98077
- ? resolveModuleNamesWorker(unknownModuleNames, file, { reusedNames: reusedNames, namesIndex: unknownModuleNamesIndex }, redirectedReference)
97844
+ ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
98078
97845
  : ts.emptyArray;
98079
97846
  if (!result) {
98080
97847
  ts.Debug.assert(resolutions.length === moduleNames.length);
@@ -98084,7 +97851,7 @@ var ts;
98084
97851
  for (var i = 0; i < result.length; i++) {
98085
97852
  if (result[i]) {
98086
97853
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
98087
- result[i] = emptyResolution;
97854
+ result[i] = undefined;
98088
97855
  }
98089
97856
  }
98090
97857
  else {
@@ -98112,78 +97879,6 @@ var ts;
98112
97879
  return true;
98113
97880
  }
98114
97881
  }
98115
- function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames, containingFile) {
98116
- var _a;
98117
- if (structureIsReused === 0) {
98118
- return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, undefined, undefined);
98119
- }
98120
- var containingSourceFile = !ts.isString(containingFile) ? containingFile : undefined;
98121
- var inferredTypeFile = !ts.isString(containingFile) ? undefined : containingFile;
98122
- var oldSourceFile = containingSourceFile && (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFile(containingSourceFile.fileName));
98123
- if (containingSourceFile && oldSourceFile !== containingSourceFile && containingSourceFile.resolvedTypeReferenceDirectiveNames) {
98124
- var result_15 = [];
98125
- for (var _i = 0, _b = typeDirectiveNames; _i < _b.length; _i++) {
98126
- var typeDirectiveName = _b[_i];
98127
- var resolvedTypeReferenceDirective = containingSourceFile.resolvedTypeReferenceDirectiveNames.get(ts.toFileNameLowerCase(typeDirectiveName.fileName), typeDirectiveName.resolutionMode || containingSourceFile.impliedNodeFormat);
98128
- result_15.push(resolvedTypeReferenceDirective);
98129
- }
98130
- return result_15;
98131
- }
98132
- var unknownTypeReferenceDirectiveNames;
98133
- var unknownTypeReferenceDirectiveNamesIndex;
98134
- var result;
98135
- var reusedNames;
98136
- var canReuseResolutions = oldBuildInfoProgram || (containingSourceFile ?
98137
- containingSourceFile === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path) :
98138
- !hasInvalidatedResolution(toPath(inferredTypeFile)));
98139
- var redirectedReference;
98140
- for (var i = 0; i < typeDirectiveNames.length; i++) {
98141
- var entry = typeDirectiveNames[i];
98142
- if (canReuseResolutions) {
98143
- var typeDirectiveName = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
98144
- var mode = getModeForFileReference(entry, containingSourceFile === null || containingSourceFile === void 0 ? void 0 : containingSourceFile.impliedNodeFormat);
98145
- var oldResolution = !oldBuildInfoProgram ?
98146
- (_a = (containingSourceFile ? oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.resolvedTypeReferenceDirectiveNames : oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions())) === null || _a === void 0 ? void 0 : _a.get(typeDirectiveName, mode) :
98147
- oldBuildInfoProgram.getResolvedTypeReferenceDirective(ts.getDirectoryPath(containingSourceFile ? containingSourceFile.path : toPath(inferredTypeFile)), typeDirectiveName, mode, containingSourceFile && (redirectedReference === undefined ? (redirectedReference = getRedirectReferenceForResolution(containingSourceFile) || false) : redirectedReference) || undefined);
98148
- if (oldResolution === null || oldResolution === void 0 ? void 0 : oldResolution.resolvedTypeReferenceDirective) {
98149
- if (ts.isTraceEnabled(options, host)) {
98150
- var fileLocation = containingSourceFile ? ts.getNormalizedAbsolutePath(containingSourceFile.originalFileName, currentDirectory) : inferredTypeFile;
98151
- if (!oldBuildInfoProgram) {
98152
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98153
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
98154
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2, typeDirectiveName, fileLocation, oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
98155
- }
98156
- else {
98157
- ts.trace(host, oldResolution.resolvedTypeReferenceDirective.packageId ?
98158
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
98159
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3, typeDirectiveName, fileLocation, ts.getDirectoryPath(fileLocation), oldResolution.resolvedTypeReferenceDirective.resolvedFileName, oldResolution.resolvedTypeReferenceDirective.packageId && ts.packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId));
98160
- }
98161
- }
98162
- (result || (result = new Array(typeDirectiveNames.length)))[i] = oldResolution;
98163
- (reusedNames !== null && reusedNames !== void 0 ? reusedNames : (reusedNames = [])).push({ name: typeDirectiveName, mode: mode });
98164
- continue;
98165
- }
98166
- }
98167
- (unknownTypeReferenceDirectiveNames !== null && unknownTypeReferenceDirectiveNames !== void 0 ? unknownTypeReferenceDirectiveNames : (unknownTypeReferenceDirectiveNames = [])).push(entry);
98168
- (unknownTypeReferenceDirectiveNamesIndex !== null && unknownTypeReferenceDirectiveNamesIndex !== void 0 ? unknownTypeReferenceDirectiveNamesIndex : (unknownTypeReferenceDirectiveNamesIndex = [])).push(i);
98169
- }
98170
- if (!unknownTypeReferenceDirectiveNames)
98171
- return result || ts.emptyArray;
98172
- var resolutions = resolveTypeReferenceDirectiveNamesWorker(unknownTypeReferenceDirectiveNames, containingFile, { reusedNames: reusedNames, namesIndex: unknownTypeReferenceDirectiveNamesIndex }, redirectedReference);
98173
- if (!result) {
98174
- ts.Debug.assert(resolutions.length === typeDirectiveNames.length);
98175
- return resolutions;
98176
- }
98177
- var j = 0;
98178
- for (var i = 0; i < result.length; i++) {
98179
- if (!result[i]) {
98180
- result[i] = resolutions[j];
98181
- j++;
98182
- }
98183
- }
98184
- ts.Debug.assert(j === resolutions.length);
98185
- return result;
98186
- }
98187
97882
  function canReuseProjectReferences() {
98188
97883
  return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
98189
97884
  var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
@@ -98202,17 +97897,12 @@ var ts;
98202
97897
  });
98203
97898
  }
98204
97899
  function tryReuseStructureFromOldProgram() {
98205
- var oldOptions = (oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getCompilerOptions()) || (oldBuildInfoProgram === null || oldBuildInfoProgram === void 0 ? void 0 : oldBuildInfoProgram.getCompilerOptions());
98206
- if (!oldOptions || ts.changesAffectModuleResolution(oldOptions, options)) {
97900
+ var _a;
97901
+ if (!oldProgram) {
98207
97902
  return 0;
98208
97903
  }
98209
- var result = tryReuseStructureFromOldProgramWorker();
98210
- return options.cacheResolutions && (oldProgram || oldBuildInfoProgram) && result === 0 ?
98211
- 1 :
98212
- result;
98213
- }
98214
- function tryReuseStructureFromOldProgramWorker() {
98215
- if (!oldProgram) {
97904
+ var oldOptions = oldProgram.getCompilerOptions();
97905
+ if (ts.changesAffectModuleResolution(oldOptions, options)) {
98216
97906
  return 0;
98217
97907
  }
98218
97908
  var oldRootNames = oldProgram.getRootFileNames();
@@ -98227,7 +97917,7 @@ var ts;
98227
97917
  }
98228
97918
  var newSourceFiles = [];
98229
97919
  var modifiedSourceFiles = [];
98230
- structureIsReused = 3;
97920
+ structureIsReused = 2;
98231
97921
  if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
98232
97922
  return 0;
98233
97923
  }
@@ -98274,90 +97964,81 @@ var ts;
98274
97964
  }
98275
97965
  if (fileChanged) {
98276
97966
  if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
98277
- structureIsReused = 2;
97967
+ structureIsReused = 1;
98278
97968
  }
98279
97969
  if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
98280
- structureIsReused = 2;
97970
+ structureIsReused = 1;
98281
97971
  }
98282
97972
  if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
98283
- structureIsReused = 2;
97973
+ structureIsReused = 1;
98284
97974
  }
98285
97975
  collectExternalModuleReferences(newSourceFile);
98286
97976
  if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
98287
- structureIsReused = 2;
97977
+ structureIsReused = 1;
98288
97978
  }
98289
97979
  if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
98290
- structureIsReused = 2;
97980
+ structureIsReused = 1;
98291
97981
  }
98292
97982
  if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) {
98293
- structureIsReused = 2;
97983
+ structureIsReused = 1;
98294
97984
  }
98295
97985
  if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
98296
- structureIsReused = 2;
97986
+ structureIsReused = 1;
98297
97987
  }
98298
97988
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98299
97989
  }
98300
97990
  else if (hasInvalidatedResolution(oldSourceFile.path)) {
98301
- structureIsReused = 2;
97991
+ structureIsReused = 1;
98302
97992
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
98303
97993
  }
98304
97994
  newSourceFiles.push(newSourceFile);
98305
97995
  }
98306
- if (structureIsReused !== 3) {
97996
+ if (structureIsReused !== 2) {
98307
97997
  return structureIsReused;
98308
97998
  }
98309
97999
  var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
98310
- for (var _a = 0, oldSourceFiles_3 = oldSourceFiles; _a < oldSourceFiles_3.length; _a++) {
98311
- var oldFile = oldSourceFiles_3[_a];
98000
+ for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
98001
+ var oldFile = oldSourceFiles_3[_b];
98312
98002
  if (!ts.contains(modifiedFiles, oldFile)) {
98313
- for (var _b = 0, _c = oldFile.ambientModuleNames; _b < _c.length; _b++) {
98314
- var moduleName = _c[_b];
98003
+ for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
98004
+ var moduleName = _d[_c];
98315
98005
  ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
98316
98006
  }
98317
98007
  }
98318
98008
  }
98319
- for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) {
98320
- var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile;
98009
+ for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
98010
+ var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
98321
98011
  var moduleNames = getModuleNames(newSourceFile);
98322
98012
  var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
98323
98013
  var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
98324
98014
  if (resolutionsChanged) {
98325
- structureIsReused = 2;
98015
+ structureIsReused = 1;
98326
98016
  newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
98327
98017
  }
98328
98018
  else {
98329
98019
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
98330
98020
  }
98331
98021
  var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
98332
- var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile);
98022
+ var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
98333
98023
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
98334
98024
  if (typeReferenceResolutionsChanged) {
98335
- structureIsReused = 2;
98025
+ structureIsReused = 1;
98336
98026
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
98337
98027
  }
98338
98028
  else {
98339
98029
  newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
98340
98030
  }
98341
98031
  }
98342
- if (structureIsReused !== 3) {
98032
+ if (structureIsReused !== 2) {
98343
98033
  return structureIsReused;
98344
98034
  }
98345
- if (ts.changesAffectingProgramStructure(oldProgram.getCompilerOptions(), options)) {
98346
- return 2;
98347
- }
98348
- if (host.hasChangedAutomaticTypeDirectiveNames) {
98349
- if (host.hasChangedAutomaticTypeDirectiveNames())
98350
- return 2;
98351
- }
98352
- else {
98353
- automaticTypeDirectiveNames = ts.getAutomaticTypeDirectiveNames(options, host);
98354
- if (!ts.arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames))
98355
- return 2;
98035
+ if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) {
98036
+ return 1;
98356
98037
  }
98357
98038
  missingFilePaths = oldProgram.getMissingFilePaths();
98358
98039
  ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
98359
- for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) {
98360
- var newSourceFile = newSourceFiles_1[_f];
98040
+ for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
98041
+ var newSourceFile = newSourceFiles_1[_g];
98361
98042
  filesByName.set(newSourceFile.path, newSourceFile);
98362
98043
  }
98363
98044
  var oldFilesByNameMap = oldProgram.getFilesByNameMap();
@@ -98378,12 +98059,10 @@ var ts;
98378
98059
  fileReasons = oldProgram.getFileIncludeReasons();
98379
98060
  fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
98380
98061
  resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
98381
- automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
98382
- automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
98383
98062
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
98384
98063
  redirectTargetsMap = oldProgram.redirectTargetsMap;
98385
98064
  usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules;
98386
- return 3;
98065
+ return 2;
98387
98066
  }
98388
98067
  function getEmitHost(writeFileCallback) {
98389
98068
  return {
@@ -99307,40 +98986,33 @@ var ts;
99307
98986
  }
99308
98987
  function processTypeReferenceDirectives(file) {
99309
98988
  var typeDirectives = file.typeReferenceDirectives;
99310
- if (!typeDirectives.length) {
99311
- file.resolvedTypeReferenceDirectiveNames = undefined;
98989
+ if (!typeDirectives) {
99312
98990
  return;
99313
98991
  }
99314
- var resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
98992
+ var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
99315
98993
  for (var index = 0; index < typeDirectives.length; index++) {
99316
98994
  var ref = file.typeReferenceDirectives[index];
99317
98995
  var resolvedTypeReferenceDirective = resolutions[index];
99318
98996
  var fileName = ts.toFileNameLowerCase(ref.fileName);
99319
- ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat));
98997
+ ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
99320
98998
  var mode = ref.resolutionMode || file.impliedNodeFormat;
99321
98999
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
99322
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99323
- kind: 2,
99324
- diagnostics: [ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)]
99325
- });
99000
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
99326
99001
  }
99327
99002
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
99328
99003
  }
99329
99004
  }
99330
- function processTypeReferenceDirective(typeReferenceDirective, mode, resolution, reason) {
99331
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
99332
- processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason);
99005
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99006
+ 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 });
99007
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
99333
99008
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
99334
99009
  }
99335
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason) {
99336
- var _a;
99337
- addResolutionDiagnostics(resolution);
99338
- var previousResolution = (_a = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)) === null || _a === void 0 ? void 0 : _a.resolvedTypeReferenceDirective;
99010
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
99011
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
99339
99012
  if (previousResolution && previousResolution.primary) {
99340
99013
  return;
99341
99014
  }
99342
99015
  var saveResolution = true;
99343
- var resolvedTypeReferenceDirective = resolution.resolvedTypeReferenceDirective;
99344
99016
  if (resolvedTypeReferenceDirective) {
99345
99017
  if (resolvedTypeReferenceDirective.isExternalLibraryImport)
99346
99018
  currentNodeModulesDepth++;
@@ -99369,7 +99041,7 @@ var ts;
99369
99041
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
99370
99042
  }
99371
99043
  if (saveResolution) {
99372
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution);
99044
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
99373
99045
  }
99374
99046
  }
99375
99047
  function pathForLibFile(libFileName) {
@@ -99398,7 +99070,7 @@ var ts;
99398
99070
  var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
99399
99071
  var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
99400
99072
  var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
99401
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99073
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99402
99074
  kind: 0,
99403
99075
  reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
99404
99076
  diagnostic: diagnostic,
@@ -99421,20 +99093,19 @@ var ts;
99421
99093
  for (var index = 0; index < moduleNames.length; index++) {
99422
99094
  var resolution = resolutions[index];
99423
99095
  ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
99424
- addResolutionDiagnostics(resolution);
99425
- if (!resolution.resolvedModule) {
99096
+ if (!resolution) {
99426
99097
  continue;
99427
99098
  }
99428
- var isFromNodeModulesSearch = resolution.resolvedModule.isExternalLibraryImport;
99429
- var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
99099
+ var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
99100
+ var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
99430
99101
  var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
99431
- var resolvedFileName = resolution.resolvedModule.resolvedFileName;
99102
+ var resolvedFileName = resolution.resolvedFileName;
99432
99103
  if (isFromNodeModulesSearch) {
99433
99104
  currentNodeModulesDepth++;
99434
99105
  }
99435
99106
  var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
99436
99107
  var shouldAddFile = resolvedFileName
99437
- && !getResolutionDiagnostic(optionsForFile, resolution.resolvedModule)
99108
+ && !getResolutionDiagnostic(optionsForFile, resolution)
99438
99109
  && !optionsForFile.noResolve
99439
99110
  && index < file.imports.length
99440
99111
  && !elideImport
@@ -99444,7 +99115,7 @@ var ts;
99444
99115
  modulesWithElidedImports.set(file.path, true);
99445
99116
  }
99446
99117
  else if (shouldAddFile) {
99447
- findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.resolvedModule.packageId);
99118
+ findSourceFile(resolvedFileName, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
99448
99119
  }
99449
99120
  if (isFromNodeModulesSearch) {
99450
99121
  currentNodeModulesDepth--;
@@ -99545,9 +99216,6 @@ var ts;
99545
99216
  createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
99546
99217
  }
99547
99218
  }
99548
- if (options.cacheResolutions && !ts.isIncrementalCompilation(options)) {
99549
- createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "cacheResolutions", "incremental", "composite");
99550
- }
99551
99219
  var outputFile = ts.outFile(options);
99552
99220
  if (options.tsBuildInfoFile) {
99553
99221
  if (!ts.isIncrementalCompilation(options)) {
@@ -99797,7 +99465,7 @@ var ts;
99797
99465
  }
99798
99466
  }
99799
99467
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
99800
- (fileProcessingDiagnostics !== null && fileProcessingDiagnostics !== void 0 ? fileProcessingDiagnostics : (fileProcessingDiagnostics = [])).push({
99468
+ (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
99801
99469
  kind: 1,
99802
99470
  file: file && file.path,
99803
99471
  fileProcessingReason: fileProcessingReason,
@@ -100058,8 +99726,8 @@ var ts;
100058
99726
  if (!symlinks) {
100059
99727
  symlinks = ts.createSymlinkCache(currentDirectory, getCanonicalFileName);
100060
99728
  }
100061
- if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) {
100062
- symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions);
99729
+ if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) {
99730
+ symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives);
100063
99731
  }
100064
99732
  return symlinks;
100065
99733
  }
@@ -100418,8 +100086,7 @@ var ts;
100418
100086
  }
100419
100087
  }
100420
100088
  if (sourceFile.resolvedTypeReferenceDirectiveNames) {
100421
- sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (_a) {
100422
- var resolvedTypeReferenceDirective = _a.resolvedTypeReferenceDirective;
100089
+ sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
100423
100090
  if (!resolvedTypeReferenceDirective) {
100424
100091
  return;
100425
100092
  }
@@ -100468,13 +100135,12 @@ var ts;
100468
100135
  return oldState && !oldState.referencedMap === !newReferencedMap;
100469
100136
  }
100470
100137
  BuilderState.canReuseOldState = canReuseOldState;
100471
- function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100138
+ function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100472
100139
  var _a, _b, _c;
100473
100140
  var fileInfos = new ts.Map();
100474
100141
  var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? createManyToManyPathMap() : undefined;
100475
100142
  var exportedModulesMap = referencedMap ? createManyToManyPathMap() : undefined;
100476
100143
  var useOldState = canReuseOldState(referencedMap, oldState);
100477
- var getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100478
100144
  newProgram.getTypeChecker();
100479
100145
  for (var _i = 0, _d = newProgram.getSourceFiles(); _i < _d.length; _i++) {
100480
100146
  var sourceFile = _d[_i];
@@ -100518,23 +100184,23 @@ var ts;
100518
100184
  state.allFileNames = undefined;
100519
100185
  }
100520
100186
  BuilderState.releaseCache = releaseCache;
100521
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100187
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100522
100188
  var _a, _b;
100523
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host);
100189
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
100524
100190
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
100525
100191
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
100526
100192
  return result;
100527
100193
  }
100528
100194
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
100529
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100195
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100530
100196
  var sourceFile = programOfThisState.getSourceFileByPath(path);
100531
100197
  if (!sourceFile) {
100532
100198
  return ts.emptyArray;
100533
100199
  }
100534
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100200
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100535
100201
  return [sourceFile];
100536
100202
  }
100537
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100203
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100538
100204
  }
100539
100205
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100540
100206
  function updateSignatureOfFile(state, signature, path) {
@@ -100542,7 +100208,7 @@ var ts;
100542
100208
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path);
100543
100209
  }
100544
100210
  BuilderState.updateSignatureOfFile = updateSignatureOfFile;
100545
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature) {
100211
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
100546
100212
  var _a;
100547
100213
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
100548
100214
  if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath))
@@ -100553,7 +100219,7 @@ var ts;
100553
100219
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
100554
100220
  programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
100555
100221
  ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
100556
- latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, host, ts.createGetCanonicalFileName(programOfThisState.useCaseSensitiveFileNames()), data);
100222
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
100557
100223
  if (latestSignature !== prevSignature) {
100558
100224
  updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
100559
100225
  }
@@ -100687,7 +100353,7 @@ var ts;
100687
100353
  }
100688
100354
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100689
100355
  }
100690
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100356
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
100691
100357
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100692
100358
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100693
100359
  }
@@ -100703,7 +100369,7 @@ var ts;
100703
100369
  if (!seenFileNamesMap.has(currentPath)) {
100704
100370
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100705
100371
  seenFileNamesMap.set(currentPath, currentSourceFile);
100706
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100372
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100707
100373
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
100708
100374
  }
100709
100375
  }
@@ -100717,9 +100383,9 @@ var ts;
100717
100383
  function hasSameKeys(map1, map2) {
100718
100384
  return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
100719
100385
  }
100720
- function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100386
+ function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100721
100387
  var _a, _b;
100722
- var state = ts.BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100388
+ var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
100723
100389
  state.program = newProgram;
100724
100390
  var compilerOptions = newProgram.getCompilerOptions();
100725
100391
  state.compilerOptions = compilerOptions;
@@ -100772,7 +100438,7 @@ var ts;
100772
100438
  return;
100773
100439
  var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100774
100440
  if (diagnostics) {
100775
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100441
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
100776
100442
  if (!state.semanticDiagnosticsFromOldState) {
100777
100443
  state.semanticDiagnosticsFromOldState = new ts.Set();
100778
100444
  }
@@ -100794,16 +100460,13 @@ var ts;
100794
100460
  ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
100795
100461
  state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
100796
100462
  }
100797
- state.buildInfoEmitPending = !useOldState ||
100798
- state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0) ||
100799
- state.fileInfos.size !== oldState.fileInfos.size;
100463
+ state.buildInfoEmitPending = !useOldState || state.changedFilesSet.size !== (((_b = oldState.changedFilesSet) === null || _b === void 0 ? void 0 : _b.size) || 0);
100800
100464
  return state;
100801
100465
  }
100802
- function convertToDiagnostics(diagnostics, newProgram) {
100466
+ function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100803
100467
  if (!diagnostics.length)
100804
100468
  return ts.emptyArray;
100805
- var buildInfoDirectory;
100806
- var getCanonicalFileName;
100469
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
100807
100470
  return diagnostics.map(function (diagnostic) {
100808
100471
  var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
100809
100472
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100819,8 +100482,7 @@ var ts;
100819
100482
  return result;
100820
100483
  });
100821
100484
  function toPath(path) {
100822
- buildInfoDirectory !== null && buildInfoDirectory !== void 0 ? buildInfoDirectory : (buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())));
100823
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName !== null && getCanonicalFileName !== void 0 ? getCanonicalFileName : (getCanonicalFileName = ts.createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames())));
100485
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
100824
100486
  }
100825
100487
  }
100826
100488
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
@@ -100829,8 +100491,6 @@ var ts;
100829
100491
  }
100830
100492
  function releaseCache(state) {
100831
100493
  ts.BuilderState.releaseCache(state);
100832
- if (!state.resuableCacheResolutions)
100833
- getCacheResolutions(state);
100834
100494
  state.program = undefined;
100835
100495
  }
100836
100496
  function backupBuilderProgramEmitState(state) {
@@ -100865,7 +100525,7 @@ var ts;
100865
100525
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100866
100526
  ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100867
100527
  }
100868
- function getNextAffectedFile(state, cancellationToken, host) {
100528
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
100869
100529
  var _a, _b;
100870
100530
  while (true) {
100871
100531
  var affectedFiles = state.affectedFiles;
@@ -100876,7 +100536,7 @@ var ts;
100876
100536
  var affectedFile = affectedFiles[affectedFilesIndex];
100877
100537
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
100878
100538
  state.affectedFilesIndex = affectedFilesIndex;
100879
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host);
100539
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
100880
100540
  return affectedFile;
100881
100541
  }
100882
100542
  affectedFilesIndex++;
@@ -100897,7 +100557,7 @@ var ts;
100897
100557
  ts.Debug.assert(!state.semanticDiagnosticsPerFile);
100898
100558
  return program;
100899
100559
  }
100900
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, host);
100560
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
100901
100561
  state.currentChangedFilePath = nextKey.value;
100902
100562
  state.affectedFilesIndex = 0;
100903
100563
  if (!state.seenAffectedFiles)
@@ -100940,24 +100600,24 @@ var ts;
100940
100600
  });
100941
100601
  }
100942
100602
  }
100943
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
100603
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100944
100604
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
100945
100605
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
100946
100606
  removeDiagnosticsOfLibraryFiles(state);
100947
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, host);
100607
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
100948
100608
  return;
100949
100609
  }
100950
100610
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
100951
100611
  return;
100952
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host);
100612
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
100953
100613
  }
100954
- function handleDtsMayChangeOf(state, path, cancellationToken, host) {
100614
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
100955
100615
  removeSemanticDiagnosticsOf(state, path);
100956
100616
  if (!state.changedFilesSet.has(path)) {
100957
100617
  var program = ts.Debug.checkDefined(state.program);
100958
100618
  var sourceFile = program.getSourceFileByPath(path);
100959
100619
  if (sourceFile) {
100960
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, host, !host.disableUseFileVersionAsSignature);
100620
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
100961
100621
  if (ts.getEmitDeclarations(state.compilerOptions)) {
100962
100622
  addToAffectedFilesPendingEmit(state, path, 0);
100963
100623
  }
@@ -100977,16 +100637,16 @@ var ts;
100977
100637
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
100978
100638
  return newSignature !== oldSignature;
100979
100639
  }
100980
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
100640
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
100981
100641
  var _a;
100982
100642
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
100983
100643
  return false;
100984
100644
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
100985
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, host); });
100645
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
100986
100646
  removeDiagnosticsOfLibraryFiles(state);
100987
100647
  return true;
100988
100648
  }
100989
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
100649
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100990
100650
  var _a;
100991
100651
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
100992
100652
  return;
@@ -101000,9 +100660,9 @@ var ts;
101000
100660
  var currentPath = queue.pop();
101001
100661
  if (!seenFileNamesMap.has(currentPath)) {
101002
100662
  seenFileNamesMap.set(currentPath, true);
101003
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
100663
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101004
100664
  return;
101005
- handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
100665
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101006
100666
  if (isChangedSignature(state, currentPath)) {
101007
100667
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
101008
100668
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -101012,27 +100672,27 @@ var ts;
101012
100672
  }
101013
100673
  var seenFileAndExportsOfFile = new ts.Set();
101014
100674
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
101015
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
100675
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101016
100676
  return true;
101017
100677
  var references = state.referencedMap.getKeys(exportedFromPath);
101018
100678
  return references && ts.forEachKey(references, function (filePath) {
101019
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host);
100679
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101020
100680
  });
101021
100681
  });
101022
100682
  }
101023
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
100683
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101024
100684
  var _a, _b;
101025
100685
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
101026
100686
  return undefined;
101027
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
100687
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101028
100688
  return true;
101029
- handleDtsMayChangeOf(state, filePath, cancellationToken, host);
100689
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101030
100690
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
101031
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, host);
100691
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
101032
100692
  });
101033
100693
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
101034
100694
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
101035
- handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, host);
100695
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
101036
100696
  });
101037
100697
  return undefined;
101038
100698
  }
@@ -101087,45 +100747,34 @@ var ts;
101087
100747
  return !!ts.outFile(info.options || {});
101088
100748
  }
101089
100749
  ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo;
101090
- function getProgramBuildInfo(state, host) {
100750
+ function getProgramBuildInfo(state, getCanonicalFileName) {
101091
100751
  var outFilePath = ts.outFile(state.compilerOptions);
101092
- if (outFilePath && !state.compilerOptions.composite && !state.compilerOptions.cacheResolutions)
100752
+ if (outFilePath && !state.compilerOptions.composite)
101093
100753
  return;
101094
100754
  var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
101095
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101096
- var buildInfoPath = ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory);
101097
- var buildInfoDirectory = ts.getDirectoryPath(buildInfoPath);
100755
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101098
100756
  var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined;
101099
- var fileNames = [];
101100
- var fileNameToFileId = new ts.Map();
101101
- var resolutions;
101102
- var names;
101103
- var resolutionNameToResolutionNameId;
101104
- var resolutionEntries;
101105
- var resolutionEntryToResolutionEntryId;
101106
- var affectedFilesHash;
101107
100757
  if (outFilePath) {
101108
- var fileInfos_1;
101109
- if (state.compilerOptions.composite) {
101110
- state.program.getRootFileNames().forEach(function (f) {
101111
- var sourceFile = state.program.getSourceFile(f);
101112
- if (!sourceFile)
101113
- return;
101114
- var fileId = toFileId(sourceFile.resolvedPath);
101115
- (fileInfos_1 !== null && fileInfos_1 !== void 0 ? fileInfos_1 : (fileInfos_1 = []))[fileId - 1] = sourceFile.version;
101116
- });
101117
- }
101118
- var cacheResolutions_1 = toProgramBuildInfoCacheResolutions();
101119
- var result_16 = {
101120
- fileNames: fileNames,
100758
+ var fileNames_1 = [];
100759
+ var fileInfos_1 = [];
100760
+ state.program.getRootFileNames().forEach(function (f) {
100761
+ var sourceFile = state.program.getSourceFile(f);
100762
+ if (!sourceFile)
100763
+ return;
100764
+ fileNames_1.push(relativeToBuildInfo(sourceFile.resolvedPath));
100765
+ fileInfos_1.push(sourceFile.version);
100766
+ });
100767
+ var result_15 = {
100768
+ fileNames: fileNames_1,
101121
100769
  fileInfos: fileInfos_1,
101122
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
100770
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"),
101123
100771
  outSignature: state.outSignature,
101124
100772
  latestChangedDtsFile: latestChangedDtsFile,
101125
- cacheResolutions: cacheResolutions_1,
101126
100773
  };
101127
- return result_16;
100774
+ return result_15;
101128
100775
  }
100776
+ var fileNames = [];
100777
+ var fileNameToFileId = new ts.Map();
101129
100778
  var fileIdsList;
101130
100779
  var fileNamesToFileIdListId;
101131
100780
  var emitSignatures;
@@ -101182,7 +100831,7 @@ var ts;
101182
100831
  (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ?
101183
100832
  [
101184
100833
  toFileId(key),
101185
- value.map(toReusableDiagnostic)
100834
+ convertToReusableDiagnostics(value, relativeToBuildInfo)
101186
100835
  ] :
101187
100836
  toFileId(key));
101188
100837
  }
@@ -101204,11 +100853,10 @@ var ts;
101204
100853
  (changeFileSet || (changeFileSet = [])).push(toFileId(path));
101205
100854
  }
101206
100855
  }
101207
- var cacheResolutions = toProgramBuildInfoCacheResolutions();
101208
100856
  var result = {
101209
100857
  fileNames: fileNames,
101210
100858
  fileInfos: fileInfos,
101211
- options: toProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo", !!state.compilerOptions.cacheResolutions),
100859
+ options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsMultiFileEmitBuildInfo"),
101212
100860
  fileIdsList: fileIdsList,
101213
100861
  referencedMap: referencedMap,
101214
100862
  exportedModulesMap: exportedModulesMap,
@@ -101217,7 +100865,6 @@ var ts;
101217
100865
  changeFileSet: changeFileSet,
101218
100866
  emitSignatures: emitSignatures,
101219
100867
  latestChangedDtsFile: latestChangedDtsFile,
101220
- cacheResolutions: cacheResolutions,
101221
100868
  };
101222
100869
  return result;
101223
100870
  function relativeToBuildInfoEnsuringAbsolutePath(path) {
@@ -101226,7 +100873,7 @@ var ts;
101226
100873
  function relativeToBuildInfo(path) {
101227
100874
  return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
101228
100875
  }
101229
- function toFileAndAbsoluteFileId(path) {
100876
+ function toFileId(path) {
101230
100877
  var fileId = fileNameToFileId.get(path);
101231
100878
  if (fileId === undefined) {
101232
100879
  fileNames.push(relativeToBuildInfo(path));
@@ -101234,12 +100881,6 @@ var ts;
101234
100881
  }
101235
100882
  return fileId;
101236
100883
  }
101237
- function toFileId(path) {
101238
- return toFileAndAbsoluteFileId(path);
101239
- }
101240
- function toAbsoluteFileId(path) {
101241
- return toFileAndAbsoluteFileId(ts.getNormalizedAbsolutePath(path, currentDirectory));
101242
- }
101243
100884
  function toFileIdListId(set) {
101244
100885
  var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues);
101245
100886
  var key = fileIds.join();
@@ -101250,236 +100891,53 @@ var ts;
101250
100891
  }
101251
100892
  return fileIdListId;
101252
100893
  }
101253
- function toProgramBuildInfoCompilerOptions(options, optionKey, affectsModuleResolution) {
100894
+ function convertToProgramBuildInfoCompilerOptions(options, optionKey) {
101254
100895
  var result;
101255
100896
  var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
101256
100897
  for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
101257
100898
  var name = _a[_i];
101258
100899
  var optionInfo = optionsNameMap.get(name.toLowerCase());
101259
- if ((optionKey && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey])) || (affectsModuleResolution && (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsModuleResolution))) {
101260
- (result !== null && result !== void 0 ? result : (result = {}))[name] = toReusableCompilerOptionValue(optionInfo, options[name]);
101261
- }
101262
- else if (affectsModuleResolution && name === "pathsBasePath") {
101263
- (result !== null && result !== void 0 ? result : (result = {})).pathsBasePath = relativeToBuildInfoEnsuringAbsolutePath(options.pathsBasePath);
101264
- continue;
100900
+ if (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo[optionKey]) {
100901
+ (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfoEnsuringAbsolutePath);
101265
100902
  }
101266
100903
  }
101267
100904
  return result;
101268
100905
  }
101269
- function toReusableCompilerOptionValue(option, value) {
101270
- if (option) {
101271
- if (option.type === "list") {
101272
- var values = value;
101273
- if (option.element.isFilePath && values.length) {
101274
- return values.map(relativeToBuildInfoEnsuringAbsolutePath);
101275
- }
101276
- }
101277
- else if (option.isFilePath) {
101278
- return relativeToBuildInfoEnsuringAbsolutePath(value);
100906
+ }
100907
+ function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
100908
+ if (option) {
100909
+ if (option.type === "list") {
100910
+ var values = value;
100911
+ if (option.element.isFilePath && values.length) {
100912
+ return values.map(relativeToBuildInfo);
101279
100913
  }
101280
100914
  }
101281
- return value;
101282
- }
101283
- function toReadonlyArrayOrUndefined(array, map) {
101284
- return (array === null || array === void 0 ? void 0 : array.length) ? array.map(map) : undefined;
100915
+ else if (option.isFilePath) {
100916
+ return relativeToBuildInfo(value);
100917
+ }
101285
100918
  }
101286
- function toReusableDiagnostic(diagnostic) {
101287
- var result = toReusableDiagnosticRelatedInformation(diagnostic);
100919
+ return value;
100920
+ }
100921
+ function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
100922
+ ts.Debug.assert(!!diagnostics.length);
100923
+ return diagnostics.map(function (diagnostic) {
100924
+ var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
101288
100925
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
101289
100926
  result.reportDeprecated = diagnostic.reportsDeprecated;
101290
100927
  result.source = diagnostic.source;
101291
100928
  result.skippedOn = diagnostic.skippedOn;
101292
100929
  var relatedInformation = diagnostic.relatedInformation;
101293
- result.relatedInformation = relatedInformation === null || relatedInformation === void 0 ? void 0 : relatedInformation.map(toReusableDiagnosticRelatedInformation);
101294
- return result;
101295
- }
101296
- function toReusableDiagnosticRelatedInformation(diagnostic) {
101297
- var file = diagnostic.file;
101298
- return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101299
- }
101300
- function toProgramBuildInfoCacheResolutions() {
101301
- var cacheResolutions = getCacheResolutions(state);
101302
- var modules = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules);
101303
- var typeRefs = toProgramBuildInfoResolutionCacheWithRedirects(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs);
101304
- if (!resolutions)
101305
- return;
101306
- ts.Debug.assertIsDefined(names);
101307
- ts.Debug.assertIsDefined(resolutionEntries);
101308
- state.resuableCacheResolutions = {
101309
- cache: {
101310
- resolutions: resolutions.map(toProgramBuildInfoResolution),
101311
- names: names,
101312
- hash: toProgramBuildInfoHashes(),
101313
- resolutionEntries: resolutionEntries,
101314
- modules: modules,
101315
- typeRefs: typeRefs,
101316
- },
101317
- getProgramBuildInfoFilePathDecoder: ts.memoize(function () { return getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName); })
101318
- };
101319
- return state.resuableCacheResolutions.cache;
101320
- }
101321
- function toProgramBuildInfoResolutionCacheWithRedirects(cache) {
101322
- if (!cache)
101323
- return undefined;
101324
- var ownMap = cache.getOwnMap();
101325
- var own = toProgramBuildInfoResolutionCache(ownMap);
101326
- var redirects;
101327
- cache.redirectsKeyToCache.forEach(function (_a) {
101328
- var map = _a.map, options = _a.options;
101329
- if (map === ownMap)
101330
- return;
101331
- var redirectCache = toProgramBuildInfoResolutionCache(map);
101332
- if (redirectCache) {
101333
- (redirects !== null && redirects !== void 0 ? redirects : (redirects = [])).push({
101334
- options: toProgramBuildInfoCompilerOptions(options, undefined, true),
101335
- cache: redirectCache
101336
- });
101337
- }
101338
- });
101339
- return !redirects ? own : { own: own, redirects: redirects };
101340
- }
101341
- function toProgramBuildInfoResolutionCache(cache) {
101342
- var result;
101343
- cache === null || cache === void 0 ? void 0 : cache.forEach(function (dirCache, dirPath) { return dirCache.size() ?
101344
- (result !== null && result !== void 0 ? result : (result = [])).push([
101345
- toFileId(dirPath),
101346
- ts.arrayFrom(dirCache.entries()).map(toProgramBuildInfoResolutionEntryId)
101347
- ]) :
101348
- undefined; });
100930
+ result.relatedInformation = relatedInformation ?
100931
+ relatedInformation.length ?
100932
+ relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
100933
+ [] :
100934
+ undefined;
101349
100935
  return result;
101350
- }
101351
- function toProgramBuildInfoResolutionEntryId(_a) {
101352
- var name = _a[0], mode = _a[1], resolution = _a[2];
101353
- var resolutionNameId = toProgramBuildInfoResolutionNameId(name);
101354
- var resolutionId = toProgramBuildInfoResolutionId(resolution);
101355
- var key = resolutionNameId + "," + mode + "," + resolutionId;
101356
- var resolutionEntryId = resolutionEntryToResolutionEntryId === null || resolutionEntryToResolutionEntryId === void 0 ? void 0 : resolutionEntryToResolutionEntryId.get(key);
101357
- if (resolutionEntryId === undefined) {
101358
- (resolutionEntries || (resolutionEntries = [])).push(mode ? [resolutionNameId, resolutionId, mode] : [resolutionNameId, resolutionId]);
101359
- (resolutionEntryToResolutionEntryId || (resolutionEntryToResolutionEntryId = new ts.Map())).set(key, resolutionEntryId = resolutionEntries.length);
101360
- }
101361
- return resolutionEntryId;
101362
- }
101363
- function toProgramBuildInfoResolutionNameId(name) {
101364
- var resolutionNameId = resolutionNameToResolutionNameId === null || resolutionNameToResolutionNameId === void 0 ? void 0 : resolutionNameToResolutionNameId.get(name);
101365
- if (resolutionNameId === undefined) {
101366
- (names !== null && names !== void 0 ? names : (names = [])).push(name);
101367
- (resolutionNameToResolutionNameId !== null && resolutionNameToResolutionNameId !== void 0 ? resolutionNameToResolutionNameId : (resolutionNameToResolutionNameId = new ts.Map())).set(name, resolutionNameId = names.length);
101368
- }
101369
- return resolutionNameId;
101370
- }
101371
- function toProgramBuildInfoResolutionId(resolution) {
101372
- if (resolution.serializationIndex === undefined) {
101373
- (resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = [])).push(resolution);
101374
- resolution.serializationIndex = resolutions.length;
101375
- }
101376
- return resolution.serializationIndex;
101377
- }
101378
- function toProgramBuildInfoResolution(resolution) {
101379
- resolution.serializationIndex = undefined;
101380
- return {
101381
- resolvedModule: toProgramBuildInfoResolved(resolution.resolvedModule),
101382
- resolvedTypeReferenceDirective: toProgramBuildInfoResolved(resolution.resolvedTypeReferenceDirective),
101383
- affectingLocations: toReadonlyArrayOrUndefined(resolution.affectingLocations, toAffectedFileId),
101384
- resolutionDiagnostics: toReadonlyArrayOrUndefined(resolution.resolutionDiagnostics, toProgramBuildInfoResolutionDiagnostic),
101385
- };
101386
- }
101387
- function toProgramBuildInfoHashes() {
101388
- if (!affectedFilesHash)
101389
- return undefined;
101390
- var hashes = [];
101391
- for (var _i = 0, _a = ts.arrayFrom(affectedFilesHash.keys()).sort(ts.compareValues); _i < _a.length; _i++) {
101392
- var key = _a[_i];
101393
- var value = affectedFilesHash.get(key);
101394
- hashes.push(value ? [key, value] : key);
101395
- }
101396
- return hashes;
101397
- }
101398
- function toAffectedFileId(file) {
101399
- var _a;
101400
- var fileId = toAbsoluteFileId(file);
101401
- if (!(affectedFilesHash === null || affectedFilesHash === void 0 ? void 0 : affectedFilesHash.has(fileId))) {
101402
- var packageJsonInfo = (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(file);
101403
- var text = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101404
- (affectedFilesHash !== null && affectedFilesHash !== void 0 ? affectedFilesHash : (affectedFilesHash = new ts.Map())).set(fileId, text ? computeSignature(text, host) : undefined);
101405
- }
101406
- return fileId;
101407
- }
101408
- function toProgramBuildInfoResolved(resolved) {
101409
- return resolved ? __assign(__assign({}, resolved), { resolvedFileName: toAbsoluteFileId(resolved.resolvedFileName), isExternalLibraryImport: resolved.isExternalLibraryImport ? true : undefined, originalPath: resolved.originalPath ? toAbsoluteFileId(resolved.originalPath) : undefined, primary: resolved.primary || undefined, extension: undefined }) : undefined;
101410
- }
101411
- function toProgramBuildInfoResolutionDiagnostic(d) {
101412
- return {
101413
- isImports: d.isImports || undefined,
101414
- entry: d.entry || undefined,
101415
- packagePath: toAbsoluteFileId(d.packagePath),
101416
- };
101417
- }
101418
- }
101419
- function getCacheResolutions(state) {
101420
- var _a;
101421
- if (state.cacheResolutions || !state.compilerOptions.cacheResolutions)
101422
- return state.cacheResolutions;
101423
- var modules;
101424
- var typeRefs;
101425
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(state.compilerOptions);
101426
- var getCanonicalFileName = ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101427
- state.program.getSourceFiles().forEach(function (f) {
101428
- modules = toPerDirectoryCache(state, getCanonicalFileName, modules, f, f.resolvedModules, moduleNameToDirectoryMap);
101429
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, f, f.resolvedTypeReferenceDirectiveNames);
101430
100936
  });
101431
- var automaticTypeDirectiveNames = state.program.getAutomaticTypeDirectiveNames();
101432
- if (automaticTypeDirectiveNames.length) {
101433
- var currentDirectory = state.program.getCurrentDirectory();
101434
- var containingPath = ts.toPath(state.program.getAutomaticTypeDirectiveContainingFile(), currentDirectory, getCanonicalFileName);
101435
- typeRefs = toPerDirectoryCache(state, getCanonicalFileName, typeRefs, containingPath, state.program.getAutomaticTypeDirectiveResolutions());
101436
- }
101437
- return state.cacheResolutions = {
101438
- modules: modules,
101439
- typeRefs: typeRefs,
101440
- moduleNameToDirectoryMap: moduleNameToDirectoryMap,
101441
- packageJsonCache: (_a = state.program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache().clone(),
101442
- };
101443
100937
  }
101444
- function toPerDirectoryCache(state, getCanonicalFileName, cacheWithRedirects, fOrPath, cache, moduleNameToDirectoryMap) {
101445
- if (!(cache === null || cache === void 0 ? void 0 : cache.size()))
101446
- return cacheWithRedirects;
101447
- var dirPath, redirectedReference;
101448
- if (!ts.isString(fOrPath)) {
101449
- redirectedReference = state.program.getRedirectReferenceForResolution(fOrPath);
101450
- dirPath = ts.getDirectoryPath(fOrPath.path);
101451
- }
101452
- else {
101453
- dirPath = ts.getDirectoryPath(fOrPath);
101454
- }
101455
- var perDirResolutionCache = cacheWithRedirects === null || cacheWithRedirects === void 0 ? void 0 : cacheWithRedirects.getMapOfCacheRedirects(redirectedReference);
101456
- var dirCache = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(dirPath);
101457
- cache.forEach(function (resolution, name, mode) {
101458
- var _a, _b, _c, _d;
101459
- if (!((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) && !((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.resolvedFileName))
101460
- return;
101461
- if (dirCache === null || dirCache === void 0 ? void 0 : dirCache.has(name, mode))
101462
- return;
101463
- if (moduleNameToDirectoryMap &&
101464
- !ts.isExternalModuleNameRelative(name) &&
101465
- ((_d = (_c = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath))) {
101466
- return;
101467
- }
101468
- if (!dirCache) {
101469
- perDirResolutionCache !== null && perDirResolutionCache !== void 0 ? perDirResolutionCache : (perDirResolutionCache = (cacheWithRedirects !== null && cacheWithRedirects !== void 0 ? cacheWithRedirects : (cacheWithRedirects = ts.createCacheWithRedirects(state.compilerOptions))).getOrCreateMapOfCacheRedirects(redirectedReference));
101470
- perDirResolutionCache.set(dirPath, dirCache = ts.createModeAwareCache());
101471
- }
101472
- dirCache.set(name, mode, resolution);
101473
- if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
101474
- return;
101475
- var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(redirectedReference);
101476
- var key = ts.getModeAwareCacheKey(name, mode);
101477
- var directoryPathMap = actualModuleNameToDirectoryMap.get(key);
101478
- if (!directoryPathMap)
101479
- actualModuleNameToDirectoryMap.set(key, directoryPathMap = new ts.Map());
101480
- ts.moduleNameToDirectorySet(directoryPathMap, dirPath, resolution, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return ts.toPath(dir, state.program.getCurrentDirectory(), getCanonicalFileName); }, function (ancestorPath) { var _a; return (_a = perDirResolutionCache === null || perDirResolutionCache === void 0 ? void 0 : perDirResolutionCache.get(ancestorPath)) === null || _a === void 0 ? void 0 : _a.delete(name, mode); });
101481
- });
101482
- return cacheWithRedirects;
100938
+ function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
100939
+ var file = diagnostic.file;
100940
+ return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
101483
100941
  }
101484
100942
  var BuilderProgramKind;
101485
100943
  (function (BuilderProgramKind) {
@@ -101503,7 +100961,7 @@ var ts;
101503
100961
  rootNames: newProgramOrRootNames,
101504
100962
  options: hostOrOptions,
101505
100963
  host: oldProgramOrHost,
101506
- oldProgram: oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getProgramOrOldBuildInfoProgramUndefined(),
100964
+ oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
101507
100965
  configFileParsingDiagnostics: configFileParsingDiagnostics,
101508
100966
  projectReferences: projectReferences
101509
100967
  });
@@ -101521,8 +100979,8 @@ var ts;
101521
100979
  function getTextHandlingSourceMapForSignature(text, data) {
101522
100980
  return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
101523
100981
  }
101524
- function computeSignatureWithDiagnostics(sourceFile, text, host, getCanonicalFileName, data) {
101525
- var _a, _b;
100982
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
100983
+ var _a;
101526
100984
  text = getTextHandlingSourceMapForSignature(text, data);
101527
100985
  var sourceFileDirectory;
101528
100986
  if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
@@ -101530,7 +100988,7 @@ var ts;
101530
100988
  return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
101531
100989
  }).join("\n");
101532
100990
  }
101533
- return ((_b = host.createHash) !== null && _b !== void 0 ? _b : ts.generateDjb2Hash)(text);
100991
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
101534
100992
  function flattenDiagnosticMessageText(diagnostic) {
101535
100993
  return ts.isString(diagnostic) ?
101536
100994
  diagnostic :
@@ -101549,9 +101007,8 @@ var ts;
101549
101007
  }
101550
101008
  }
101551
101009
  ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
101552
- function computeSignature(text, host, data) {
101553
- var _a;
101554
- return ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101010
+ function computeSignature(text, computeHash, data) {
101011
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101555
101012
  }
101556
101013
  ts.computeSignature = computeSignature;
101557
101014
  function createBuilderProgram(kind, _a) {
@@ -101562,8 +101019,10 @@ var ts;
101562
101019
  oldState = undefined;
101563
101020
  return oldProgram;
101564
101021
  }
101565
- var state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101566
- newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, host); };
101022
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101023
+ var computeHash = ts.maybeBind(host, host.createHash);
101024
+ var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101025
+ newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
101567
101026
  newProgram = undefined;
101568
101027
  oldProgram = undefined;
101569
101028
  oldState = undefined;
@@ -101577,7 +101036,6 @@ var ts;
101577
101036
  builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
101578
101037
  builderProgram.emit = emit;
101579
101038
  builderProgram.releaseProgram = function () { return releaseCache(state); };
101580
- builderProgram.getProgramOrOldBuildInfoProgramUndefined = createGetProgramOrOldBuildInfoProgramUndefined(state);
101581
101039
  if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
101582
101040
  builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
101583
101041
  }
@@ -101599,7 +101057,7 @@ var ts;
101599
101057
  return ts.emitSkippedWithNoDiagnostics;
101600
101058
  }
101601
101059
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101602
- var affected = getNextAffectedFile(state, cancellationToken, host);
101060
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101603
101061
  var emitKind = 1;
101604
101062
  var isPendingEmitFile = false;
101605
101063
  if (!affected) {
@@ -101637,7 +101095,7 @@ var ts;
101637
101095
  var file = sourceFiles[0];
101638
101096
  var info = state.fileInfos.get(file.resolvedPath);
101639
101097
  if (info.signature === file.version) {
101640
- var signature = computeSignatureWithDiagnostics(file, text, host, ts.createGetCanonicalFileName(state.program.useCaseSensitiveFileNames()), data);
101098
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
101641
101099
  if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
101642
101100
  emitSignature = signature;
101643
101101
  if (signature !== file.version) {
@@ -101661,7 +101119,7 @@ var ts;
101661
101119
  if (state.compilerOptions.composite) {
101662
101120
  var filePath = sourceFiles[0].resolvedPath;
101663
101121
  var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
101664
- emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, host, data));
101122
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
101665
101123
  if (emitSignature === oldSignature)
101666
101124
  return;
101667
101125
  ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
@@ -101670,7 +101128,7 @@ var ts;
101670
101128
  }
101671
101129
  }
101672
101130
  else if (state.compilerOptions.composite) {
101673
- var newSignature = computeSignature(text, host, data);
101131
+ var newSignature = computeSignature(text, computeHash, data);
101674
101132
  if (newSignature === state.outSignature)
101675
101133
  return;
101676
101134
  state.outSignature = newSignature;
@@ -101731,7 +101189,7 @@ var ts;
101731
101189
  }
101732
101190
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101733
101191
  while (true) {
101734
- var affected = getNextAffectedFile(state, cancellationToken, host);
101192
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101735
101193
  if (!affected) {
101736
101194
  return undefined;
101737
101195
  }
@@ -101789,32 +101247,12 @@ var ts;
101789
101247
  { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
101790
101248
  }
101791
101249
  ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
101792
- function getProgramBuildInfoFilePathDecoder(fileNames, buildInfoPath, currentDirectory, getCanonicalFileName) {
101793
- var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, currentDirectory));
101794
- var filePaths;
101795
- var fileAbsolutePaths;
101796
- return { toAbsolutePath: toAbsolutePath, toFilePath: toFilePath, toFileAbsolutePath: toFileAbsolutePath, currentDirectory: currentDirectory, getCanonicalFileName: getCanonicalFileName };
101797
- function toPath(path) {
101798
- return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101799
- }
101800
- function toAbsolutePath(path) {
101801
- return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101802
- }
101803
- function toFilePath(fileId) {
101804
- var _a;
101805
- return (_a = filePaths === null || filePaths === void 0 ? void 0 : filePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((filePaths !== null && filePaths !== void 0 ? filePaths : (filePaths = new Array(fileNames.length)))[fileId - 1] = toPath(fileNames[fileId - 1]));
101806
- }
101807
- function toFileAbsolutePath(fileId) {
101808
- var _a;
101809
- return (_a = fileAbsolutePaths === null || fileAbsolutePaths === void 0 ? void 0 : fileAbsolutePaths[fileId - 1]) !== null && _a !== void 0 ? _a : ((fileAbsolutePaths !== null && fileAbsolutePaths !== void 0 ? fileAbsolutePaths : (fileAbsolutePaths = new Array(fileNames.length)))[fileId - 1] = toAbsolutePath(fileNames[fileId - 1]));
101810
- }
101811
- }
101812
- ts.getProgramBuildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder;
101813
- function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host, configFilePath) {
101814
- var _a, _b, _c;
101815
- var buildInfoFilePathDecoder = getProgramBuildInfoFilePathDecoder(program.fileNames, buildInfoPath, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()));
101816
- var toFilePath = buildInfoFilePathDecoder.toFilePath, toAbsolutePath = buildInfoFilePathDecoder.toAbsolutePath;
101250
+ function createBuilderProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
101251
+ var _a, _b, _c, _d;
101252
+ var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
101253
+ var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101817
101254
  var state;
101255
+ var filePaths;
101818
101256
  var filePathsSetList;
101819
101257
  var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined;
101820
101258
  if (isProgramBundleEmitBuildInfo(program)) {
@@ -101823,13 +101261,13 @@ var ts;
101823
101261
  compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {},
101824
101262
  latestChangedDtsFile: latestChangedDtsFile,
101825
101263
  outSignature: program.outSignature,
101826
- resuableCacheResolutions: toResuableCacheResolutions(),
101827
101264
  };
101828
101265
  }
101829
101266
  else {
101830
- filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101267
+ filePaths = (_a = program.fileNames) === null || _a === void 0 ? void 0 : _a.map(toPath);
101268
+ filePathsSetList = (_b = program.fileIdsList) === null || _b === void 0 ? void 0 : _b.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); });
101831
101269
  var fileInfos_2 = new ts.Map();
101832
- var emitSignatures_1 = ((_b = program.options) === null || _b === void 0 ? void 0 : _b.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101270
+ var emitSignatures_1 = ((_c = program.options) === null || _c === void 0 ? void 0 : _c.composite) && !ts.outFile(program.options) ? new ts.Map() : undefined;
101833
101271
  program.fileInfos.forEach(function (fileInfo, index) {
101834
101272
  var path = toFilePath(index + 1);
101835
101273
  var stateFileInfo = toBuilderStateFileInfo(fileInfo);
@@ -101837,7 +101275,7 @@ var ts;
101837
101275
  if (emitSignatures_1 && stateFileInfo.signature)
101838
101276
  emitSignatures_1.set(path, stateFileInfo.signature);
101839
101277
  });
101840
- (_c = program.emitSignatures) === null || _c === void 0 ? void 0 : _c.forEach(function (value) {
101278
+ (_d = program.emitSignatures) === null || _d === void 0 ? void 0 : _d.forEach(function (value) {
101841
101279
  if (ts.isNumber(value))
101842
101280
  emitSignatures_1.delete(toFilePath(value));
101843
101281
  else
@@ -101856,17 +101294,14 @@ var ts;
101856
101294
  changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)),
101857
101295
  latestChangedDtsFile: latestChangedDtsFile,
101858
101296
  emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined,
101859
- resuableCacheResolutions: toResuableCacheResolutions(),
101860
101297
  };
101861
101298
  }
101862
- state.compilerOptions.configFilePath = configFilePath;
101863
101299
  return {
101864
101300
  getState: function () { return state; },
101865
101301
  saveEmitState: ts.noop,
101866
101302
  restoreEmitState: ts.noop,
101867
101303
  getProgram: ts.notImplemented,
101868
101304
  getProgramOrUndefined: ts.returnUndefined,
101869
- getProgramOrOldBuildInfoProgramUndefined: createGetProgramOrOldBuildInfoProgramUndefined(state),
101870
101305
  releaseProgram: ts.noop,
101871
101306
  getCompilerOptions: function () { return state.compilerOptions; },
101872
101307
  getSourceFile: ts.notImplemented,
@@ -101886,6 +101321,15 @@ var ts;
101886
101321
  close: ts.noop,
101887
101322
  hasChangedEmitSignature: ts.returnFalse,
101888
101323
  };
101324
+ function toPath(path) {
101325
+ return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
101326
+ }
101327
+ function toAbsolutePath(path) {
101328
+ return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
101329
+ }
101330
+ function toFilePath(fileId) {
101331
+ return filePaths[fileId - 1];
101332
+ }
101889
101333
  function toFilePathsSet(fileIdsListId) {
101890
101334
  return filePathsSetList[fileIdsListId - 1];
101891
101335
  }
@@ -101900,186 +101344,8 @@ var ts;
101900
101344
  });
101901
101345
  return map;
101902
101346
  }
101903
- function toResuableCacheResolutions() {
101904
- return program.cacheResolutions && {
101905
- cache: program.cacheResolutions,
101906
- getProgramBuildInfoFilePathDecoder: function () { return buildInfoFilePathDecoder; },
101907
- };
101908
- }
101909
101347
  }
101910
101348
  ts.createBuilderProgramUsingProgramBuildInfo = createBuilderProgramUsingProgramBuildInfo;
101911
- function createGetProgramOrOldBuildInfoProgramUndefined(state) {
101912
- return function () {
101913
- var _a;
101914
- return (_a = state.program) !== null && _a !== void 0 ? _a : (state.cacheResolutions || state.resuableCacheResolutions ?
101915
- (function (host) { return createOldBuildInfoProgram(host, state.compilerOptions, state.cacheResolutions, !state.cacheResolutions ? state.resuableCacheResolutions : undefined); }) :
101916
- undefined);
101917
- };
101918
- }
101919
- function createOldBuildInfoProgram(host, compilerOptions, cacheResolutions, resuableCacheResolutions) {
101920
- if (!cacheResolutions && !resuableCacheResolutions)
101921
- return undefined;
101922
- var fileExistsMap = new ts.Map();
101923
- var affectingLoationsSameMap = new ts.Map();
101924
- var decodedResolvedModules = ts.createCacheWithRedirects(compilerOptions);
101925
- var decodedResolvedTypeRefs = ts.createCacheWithRedirects(compilerOptions);
101926
- var decodedModuleNameToDirectoryMap = ts.createCacheWithRedirects(compilerOptions);
101927
- var decodedHashes;
101928
- var resolutions;
101929
- var originalPathOrResolvedFileNames;
101930
- var resolutionEntries;
101931
- return {
101932
- getCompilerOptions: function () { return compilerOptions; },
101933
- getResolvedModule: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.modules, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.modules, decodedResolvedModules, dirPath, name, mode, redirectedReference, cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap); },
101934
- getResolvedTypeReferenceDirective: function (dirPath, name, mode, redirectedReference) { return getResolvedFromCache(cacheResolutions === null || cacheResolutions === void 0 ? void 0 : cacheResolutions.typeRefs, resuableCacheResolutions === null || resuableCacheResolutions === void 0 ? void 0 : resuableCacheResolutions.cache.typeRefs, decodedResolvedTypeRefs, dirPath, name, mode, redirectedReference, undefined, undefined); },
101935
- };
101936
- function fileExists(fileName) {
101937
- var result = fileExistsMap.get(fileName);
101938
- if (result === undefined)
101939
- fileExistsMap.set(fileName, result = host.fileExists(fileName));
101940
- return result;
101941
- }
101942
- function affectingLocationsSame(fileName, expected) {
101943
- var _a;
101944
- var result = affectingLoationsSameMap.get(fileName);
101945
- if (result !== undefined)
101946
- return result;
101947
- var packageJsonInfo = host.getPackageJsonInfo(fileName);
101948
- var currentText = typeof packageJsonInfo === "object" ? packageJsonInfo.packageJsonText : undefined;
101949
- if (ts.isString(expected)) {
101950
- result = !!currentText && ((_a = host.createHash) !== null && _a !== void 0 ? _a : ts.generateDjb2Hash)(currentText) === expected;
101951
- }
101952
- else {
101953
- var expectedText = typeof expected === "object" ? expected.packageJsonText : undefined;
101954
- result = currentText === expectedText;
101955
- }
101956
- affectingLoationsSameMap.set(fileName, result);
101957
- return result;
101958
- }
101959
- function getResolvedFromCache(cache, reusableCache, decodedReusableCache, dirPath, name, mode, redirectedReference, moduleNameToDirectoryMap, decodedModuleNameToDirectoryMap) {
101960
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
101961
- var fromCache = ((_b = (_a = cache === null || cache === void 0 ? void 0 : cache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
101962
- ((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
101963
- if (fromCache) {
101964
- return fileExists(((_e = fromCache.resolvedModule) === null || _e === void 0 ? void 0 : _e.resolvedFileName) ||
101965
- fromCache.resolvedTypeReferenceDirective.resolvedFileName) && ts.every(fromCache.affectingLocations, function (fileName) { var _a; return affectingLocationsSame(fileName, (_a = cacheResolutions.packageJsonCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(fileName)); }) ? fromCache : undefined;
101966
- }
101967
- if (!reusableCache)
101968
- return undefined;
101969
- if (!decodedReusableCache.getOwnMap().size && !decodedReusableCache.redirectsKeyToCache.size) {
101970
- if (ts.isArray(reusableCache)) {
101971
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache, decodedModuleNameToDirectoryMap);
101972
- }
101973
- else {
101974
- if (reusableCache.own)
101975
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, undefined, reusableCache.own, decodedModuleNameToDirectoryMap);
101976
- reusableCache.redirects.forEach(function (_a) {
101977
- var options = _a.options, cache = _a.cache;
101978
- var compilerOptions = options ? ts.convertToOptionsWithAbsolutePaths(options, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toAbsolutePath) : {};
101979
- setBuildInfoResolutionEntries(decodedReusableCache, compilerOptions, ts.getRedirectsCacheKey(compilerOptions), cache, decodedModuleNameToDirectoryMap);
101980
- });
101981
- }
101982
- decodedReusableCache.clearRedirectsMap();
101983
- decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.clearRedirectsMap();
101984
- }
101985
- var resolutionId = ((_g = (_f = decodedReusableCache.getMapOfCacheRedirects(redirectedReference)) === null || _f === void 0 ? void 0 : _f.get(dirPath)) === null || _g === void 0 ? void 0 : _g.get(name, mode)) ||
101986
- ((_j = (_h = decodedModuleNameToDirectoryMap === null || decodedModuleNameToDirectoryMap === void 0 ? void 0 : decodedModuleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _h === void 0 ? void 0 : _h.get(ts.getModeAwareCacheKey(name, mode))) === null || _j === void 0 ? void 0 : _j.get(dirPath));
101987
- return resolutionId ? toResolution(resolutionId) : undefined;
101988
- }
101989
- function setBuildInfoResolutionEntries(decodedReusableCache, options, optionsKey, reusableCache, decodedModuleNameToDirectoryMap) {
101990
- var map = decodedReusableCache.createMapForCompilerOptions(options, optionsKey);
101991
- reusableCache.forEach(function (_a) {
101992
- var dirId = _a[0], entryId = _a[1];
101993
- var dirPath = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFilePath(dirId);
101994
- map.set(dirPath, toModeAwareCache(entryId, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap));
101995
- });
101996
- }
101997
- function toModeAwareCache(entries, dirPath, options, optionsKey, decodedModuleNameToDirectoryMap) {
101998
- var modeAwareCache = ts.createModeAwareCache();
101999
- entries.forEach(function (entryId) {
102000
- var _a = toResolutionEntry(entryId), name = _a[0], resolutionId = _a[1], mode = _a[2];
102001
- modeAwareCache.set(name, mode, resolutionId);
102002
- if (!decodedModuleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102003
- return;
102004
- var mapForOptions = decodedModuleNameToDirectoryMap.createMapForCompilerOptions(options, optionsKey);
102005
- var key = ts.getModeAwareCacheKey(name, mode);
102006
- var moduleNameMap = mapForOptions.get(key);
102007
- ;
102008
- if (!moduleNameMap)
102009
- mapForOptions.set(key, moduleNameMap = new ts.Map());
102010
- ts.moduleNameToDirectorySet(moduleNameMap, dirPath, resolutionId, toOriginalPathOrResolvedFileName, function (fileName) { return ts.toPath(fileName, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().currentDirectory, resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().getCanonicalFileName); }, ts.noop);
102011
- });
102012
- return modeAwareCache;
102013
- }
102014
- function toResolutionEntry(entryId) {
102015
- var existing = resolutionEntries === null || resolutionEntries === void 0 ? void 0 : resolutionEntries[entryId - 1];
102016
- if (existing)
102017
- return existing;
102018
- resolutionEntries !== null && resolutionEntries !== void 0 ? resolutionEntries : (resolutionEntries = new Array(resuableCacheResolutions.cache.resolutionEntries.length));
102019
- var _a = resuableCacheResolutions.cache.resolutionEntries[entryId - 1], nameId = _a[0], resolutionId = _a[1], mode = _a[2];
102020
- return resolutionEntries[entryId - 1] = [
102021
- toName(nameId),
102022
- resolutionId,
102023
- mode
102024
- ];
102025
- }
102026
- function toName(nameId) {
102027
- return resuableCacheResolutions.cache.names[nameId - 1];
102028
- }
102029
- function toOriginalPathOrResolvedFileName(resolutionId) {
102030
- var _a;
102031
- return (_a = originalPathOrResolvedFileNames === null || originalPathOrResolvedFileNames === void 0 ? void 0 : originalPathOrResolvedFileNames[resolutionId - 1]) !== null && _a !== void 0 ? _a : ((originalPathOrResolvedFileNames !== null && originalPathOrResolvedFileNames !== void 0 ? originalPathOrResolvedFileNames : (originalPathOrResolvedFileNames = new Array(resuableCacheResolutions.cache.resolutions.length)))[resolutionId - 1] = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.originalPath ||
102032
- resuableCacheResolutions.cache.resolutions[resolutionId - 1].resolvedModule.resolvedFileName));
102033
- }
102034
- function toAffectingFileLocation(fileId) {
102035
- if (!decodedHashes && resuableCacheResolutions.cache.hash) {
102036
- decodedHashes = ts.arrayToMap(resuableCacheResolutions.cache.hash, function (hash) { return ts.isArray(hash) ? hash[0] : hash; }, function (hash) { return ts.isArray(hash) ? hash[1] : undefined; });
102037
- }
102038
- var hash = decodedHashes === null || decodedHashes === void 0 ? void 0 : decodedHashes.get(fileId);
102039
- var file = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(fileId);
102040
- return affectingLocationsSame(file, hash) ? file : undefined;
102041
- }
102042
- function toResolution(resolutionId) {
102043
- var _a, _b;
102044
- var existing = resolutions === null || resolutions === void 0 ? void 0 : resolutions[resolutionId - 1];
102045
- if (existing !== undefined)
102046
- return existing || undefined;
102047
- resolutions !== null && resolutions !== void 0 ? resolutions : (resolutions = new Array(resuableCacheResolutions.cache.resolutions.length));
102048
- var resolution = resuableCacheResolutions.cache.resolutions[resolutionId - 1];
102049
- var resolvedFileName = resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName) || resolution.resolvedTypeReferenceDirective.resolvedFileName);
102050
- var affectingLocations;
102051
- if (fileExists(resolvedFileName) && ts.every(resolution.affectingLocations, function (fileId) {
102052
- var file = toAffectingFileLocation(fileId);
102053
- if (file)
102054
- (affectingLocations !== null && affectingLocations !== void 0 ? affectingLocations : (affectingLocations = [])).push(file);
102055
- return !!file;
102056
- })) {
102057
- var extenstion = resolution.resolvedModule ? ts.extensionFromPath(resolvedFileName) : undefined;
102058
- return resolutions[resolutionId - 1] = {
102059
- resolvedModule: toResolved(resolution.resolvedModule, resolvedFileName, extenstion),
102060
- resolvedTypeReferenceDirective: toResolved(resolution.resolvedTypeReferenceDirective, resolvedFileName, extenstion),
102061
- failedLookupLocations: ts.emptyArray,
102062
- affectingLocations: affectingLocations,
102063
- resolutionDiagnostics: (_b = resolution.resolutionDiagnostics) === null || _b === void 0 ? void 0 : _b.map(toResolutionDiagnostic)
102064
- };
102065
- }
102066
- resolutions[resolutionId - 1] = false;
102067
- return undefined;
102068
- }
102069
- function toResolved(resolved, resolvedFileName, extension) {
102070
- if (!resolved)
102071
- return undefined;
102072
- return __assign(__assign({}, resolved), { resolvedFileName: resolvedFileName, originalPath: resolved.originalPath ? resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(resolved.originalPath) : undefined, extension: extension });
102073
- }
102074
- function toResolutionDiagnostic(d) {
102075
- return {
102076
- isImports: !!d.isImports,
102077
- entry: d.entry || "",
102078
- packagePath: resuableCacheResolutions.getProgramBuildInfoFilePathDecoder().toFileAbsolutePath(d.packagePath)
102079
- };
102080
- }
102081
- }
102082
- ts.createOldBuildInfoProgram = createOldBuildInfoProgram;
102083
101349
  function getBuildInfoFileVersionMap(program, buildInfoPath, host) {
102084
101350
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
102085
101351
  var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
@@ -102099,7 +101365,6 @@ var ts;
102099
101365
  restoreEmitState: ts.noop,
102100
101366
  getProgram: getProgram,
102101
101367
  getProgramOrUndefined: function () { return getState().program; },
102102
- getProgramOrOldBuildInfoProgramUndefined: function () { return getState().program; },
102103
101368
  releaseProgram: function () { return getState().program = undefined; },
102104
101369
  getCompilerOptions: function () { return getState().compilerOptions; },
102105
101370
  getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
@@ -102185,10 +101450,11 @@ var ts;
102185
101450
  function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
102186
101451
  var filesWithChangedSetOfUnresolvedImports;
102187
101452
  var filesWithInvalidatedResolutions;
101453
+ var filesWithInvalidatedNonRelativeUnresolvedImports;
101454
+ var nonRelativeExternalModuleResolutions = ts.createMultiMap();
102188
101455
  var resolutionsWithFailedLookups = [];
102189
101456
  var resolutionsWithOnlyAffectingLocations = [];
102190
101457
  var resolvedFileToResolution = ts.createMultiMap();
102191
- var resolutionsToCloseWatcherOn;
102192
101458
  var hasChangedAutomaticTypeDirectiveNames = false;
102193
101459
  var affectingPathChecks;
102194
101460
  var failedLookupChecks;
@@ -102196,11 +101462,13 @@ var ts;
102196
101462
  var isInDirectoryChecks;
102197
101463
  var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
102198
101464
  var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
102199
- var oldModuleAndTypeRefCache;
102200
101465
  var resolvedModuleNames = new ts.Map();
102201
- var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName);
101466
+ var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
101467
+ var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
101468
+ var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache);
102202
101469
  var resolvedTypeReferenceDirectives = new ts.Map();
102203
- var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache());
101470
+ var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
101471
+ var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives);
102204
101472
  var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
102205
101473
  var customFailedLookupPaths = new ts.Map();
102206
101474
  var directoryWatchesOfFailedLookups = new ts.Map();
@@ -102210,21 +101478,24 @@ var ts;
102210
101478
  var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
102211
101479
  var typeRootsWatches = new ts.Map();
102212
101480
  return {
102213
- resolvedModuleNames: resolvedModuleNames,
102214
- resolvedTypeReferenceDirectives: resolvedTypeReferenceDirectives,
102215
101481
  getModuleResolutionCache: function () { return moduleResolutionCache; },
102216
- getTypeReferenceDirectiveResolutionCache: function () { return typeReferenceDirectiveResolutionCache; },
102217
101482
  startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
102218
101483
  finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
102219
- startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
101484
+ startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
102220
101485
  finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
102221
101486
  resolveModuleNames: resolveModuleNames,
101487
+ getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
102222
101488
  resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
101489
+ removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
101490
+ removeResolutionsOfFile: removeResolutionsOfFile,
102223
101491
  hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
102224
101492
  invalidateResolutionOfFile: invalidateResolutionOfFile,
102225
101493
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
102226
101494
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
102227
101495
  createHasInvalidatedResolution: createHasInvalidatedResolution,
101496
+ isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
101497
+ updateTypeRootsWatch: updateTypeRootsWatch,
101498
+ closeTypeRootsWatch: closeTypeRootsWatch,
102228
101499
  clear: clear
102229
101500
  };
102230
101501
  function getResolvedModule(resolution) {
@@ -102243,6 +101514,7 @@ var ts;
102243
101514
  ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
102244
101515
  ts.clearMap(fileWatchesOfAffectingLocations, ts.closeFileWatcherOf);
102245
101516
  customFailedLookupPaths.clear();
101517
+ nonRelativeExternalModuleResolutions.clear();
102246
101518
  closeTypeRootsWatch();
102247
101519
  resolvedModuleNames.clear();
102248
101520
  resolvedTypeReferenceDirectives.clear();
@@ -102253,10 +101525,7 @@ var ts;
102253
101525
  startsWithPathChecks = undefined;
102254
101526
  isInDirectoryChecks = undefined;
102255
101527
  affectingPathChecks = undefined;
102256
- resolutionsToCloseWatcherOn = undefined;
102257
- moduleResolutionCache.clear();
102258
- typeReferenceDirectiveResolutionCache.clear();
102259
- oldModuleAndTypeRefCache = undefined;
101528
+ clearPerDirectoryResolutions();
102260
101529
  hasChangedAutomaticTypeDirectiveNames = false;
102261
101530
  }
102262
101531
  function startRecordingFilesWithChangedResolutions() {
@@ -102267,6 +101536,13 @@ var ts;
102267
101536
  filesWithChangedSetOfUnresolvedImports = undefined;
102268
101537
  return collected;
102269
101538
  }
101539
+ function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
101540
+ if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
101541
+ return false;
101542
+ }
101543
+ var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
101544
+ return !!value && !!value.length;
101545
+ }
102270
101546
  function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
102271
101547
  invalidateResolutionsOfFailedLookupLocations();
102272
101548
  if (forceAllFilesAsInvalidated) {
@@ -102275,162 +101551,46 @@ var ts;
102275
101551
  }
102276
101552
  var collected = filesWithInvalidatedResolutions;
102277
101553
  filesWithInvalidatedResolutions = undefined;
102278
- return function (path) { return !!(collected === null || collected === void 0 ? void 0 : collected.has(path)); };
101554
+ return function (path) { return (!!collected && collected.has(path)) ||
101555
+ isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
102279
101556
  }
102280
- function startCachingPerDirectoryResolution() {
101557
+ function clearPerDirectoryResolutions() {
102281
101558
  moduleResolutionCache.clear();
102282
101559
  typeReferenceDirectiveResolutionCache.clear();
102283
- moduleResolutionCache.update(resolutionHost.getCompilationSettings());
102284
- typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
102285
- if (oldModuleAndTypeRefCache) {
102286
- oldModuleAndTypeRefCache.clearRedirectsMap();
102287
- moduleResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.modules);
102288
- typeReferenceDirectiveResolutionCache.setOldResolutionCache(oldModuleAndTypeRefCache.typeRefs);
102289
- }
101560
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
101561
+ nonRelativeExternalModuleResolutions.clear();
102290
101562
  }
102291
- function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
102292
- hasChangedAutomaticTypeDirectiveNames = false;
102293
- if (!newProgram) {
102294
- clear();
102295
- return;
102296
- }
102297
- if (newProgram === oldProgram || newProgram.structureIsReused === 3)
102298
- return;
102299
- var modules;
102300
- var typeRefs;
102301
- var moduleNameToDirectoryMap = ts.createCacheWithRedirects(newProgram.getCompilerOptions());
102302
- for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
102303
- var f = _a[_i];
102304
- modules = ensureResolutionsOfFile(newProgram, resolvedModuleNames, f.resolvedModules, f, getResolvedModule, modules, moduleNameToDirectoryMap);
102305
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, f.resolvedTypeReferenceDirectiveNames, f, getResolvedTypeReferenceDirective, typeRefs, undefined);
102306
- }
102307
- var newProgramAutoTypeRefContainingFile = resolutionHost.toPath(newProgram.getAutomaticTypeDirectiveContainingFile());
102308
- typeRefs = ensureResolutionsOfFile(newProgram, resolvedTypeReferenceDirectives, newProgram.getAutomaticTypeDirectiveResolutions(), newProgramAutoTypeRefContainingFile, getResolvedTypeReferenceDirective, typeRefs, undefined);
102309
- if (!modules && !typeRefs) {
102310
- oldModuleAndTypeRefCache = undefined;
102311
- }
102312
- else {
102313
- oldModuleAndTypeRefCache = getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap);
102314
- }
102315
- if (oldProgram) {
102316
- for (var _b = 0, _c = oldProgram.getSourceFiles(); _b < _c.length; _b++) {
102317
- var f = _c[_b];
102318
- if (!newProgram.getSourceFileByPath(f.path))
102319
- removeResolutionsOfFile(f.path);
101563
+ function finishCachingPerDirectoryResolution() {
101564
+ filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
101565
+ clearPerDirectoryResolutions();
101566
+ directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
101567
+ if (watcher.refCount === 0) {
101568
+ directoryWatchesOfFailedLookups.delete(path);
101569
+ watcher.watcher.close();
102320
101570
  }
102321
- var oldProgramAutoTypeRefContainingFile = resolutionHost.toPath(oldProgram.getAutomaticTypeDirectiveContainingFile());
102322
- if (oldProgramAutoTypeRefContainingFile !== newProgramAutoTypeRefContainingFile) {
102323
- removeResolutionsOfFile(oldProgramAutoTypeRefContainingFile);
101571
+ });
101572
+ fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
101573
+ if (watcher.refCount === 0) {
101574
+ fileWatchesOfAffectingLocations.delete(path);
101575
+ watcher.watcher.close();
101576
+ watcher.watcher = ts.noopFileWatcher;
102324
101577
  }
102325
- }
102326
- if (!oldProgram || newProgram.getCompilerOptions() !== oldProgram.getCompilerOptions())
102327
- updateTypeRootsWatch();
102328
- resolutionsToCloseWatcherOn === null || resolutionsToCloseWatcherOn === void 0 ? void 0 : resolutionsToCloseWatcherOn.forEach(closeWatchersOfResolution);
102329
- resolutionsToCloseWatcherOn = undefined;
102330
- fileWatchesOfAffectingLocations.forEach(closeAffectingFileWatcher);
102331
- }
102332
- function closeAffectingFileWatcher(watcher, path) {
102333
- if (watcher.refCount === 0) {
102334
- fileWatchesOfAffectingLocations.delete(path);
102335
- watcher.watcher.close();
102336
- watcher.watcher = ts.noopFileWatcher;
102337
- }
102338
- }
102339
- function ensureResolutionsOfFile(newProgram, perFileCache, fileCacheFromProgram, sourceFileOrPath, getResolutionWithResolvedFileName, perDirCache, moduleNameToDirectoryMap) {
102340
- var path = !ts.isString(sourceFileOrPath) ? sourceFileOrPath.path : sourceFileOrPath;
102341
- var resolutionsInFile = perFileCache.get(path);
102342
- var seenNamesInFile = ts.createModeAwareCache();
102343
- if (fileCacheFromProgram === null || fileCacheFromProgram === void 0 ? void 0 : fileCacheFromProgram.size()) {
102344
- var redirectedReference = !ts.isString(sourceFileOrPath) ? newProgram.getRedirectReferenceForResolution(sourceFileOrPath) : undefined;
102345
- var options_3 = (redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || newProgram.getCompilerOptions();
102346
- var key_2 = ts.getRedirectsCacheKey(options_3);
102347
- if (resolutionsInFile && resolutionsInFile.key !== key_2) {
102348
- resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102349
- resolutionsInFile = undefined;
102350
- }
102351
- var dirPath_1 = ts.getDirectoryPath(path);
102352
- var perDirResolutionCache_1 = perDirCache === null || perDirCache === void 0 ? void 0 : perDirCache.getMapOfCacheRedirects(redirectedReference);
102353
- var cacheForDir_1 = perDirResolutionCache_1 === null || perDirResolutionCache_1 === void 0 ? void 0 : perDirResolutionCache_1.get(dirPath_1);
102354
- fileCacheFromProgram.forEach(function (r, name, mode) {
102355
- seenNamesInFile.set(name, mode, true);
102356
- var existing = resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.get(name, mode);
102357
- if (existing && r !== existing)
102358
- stopWatchingResolution(existing, path, getResolutionWithResolvedFileName);
102359
- watchResolution(newProgram, name, r, path, getResolutionWithResolvedFileName);
102360
- if (!resolutionsInFile)
102361
- perFileCache.set(path, resolutionsInFile = { key: key_2, cache: ts.createModeAwareCache() });
102362
- resolutionsInFile.cache.set(name, mode, r);
102363
- if (cacheForDir_1 === null || cacheForDir_1 === void 0 ? void 0 : cacheForDir_1.has(name, mode))
102364
- return;
102365
- if (!cacheForDir_1) {
102366
- perDirResolutionCache_1 !== null && perDirResolutionCache_1 !== void 0 ? perDirResolutionCache_1 : (perDirResolutionCache_1 = (perDirCache !== null && perDirCache !== void 0 ? perDirCache : (perDirCache = ts.createCacheWithRedirects(newProgram.getCompilerOptions()))).createMapForCompilerOptions(options_3, key_2));
102367
- perDirResolutionCache_1.set(dirPath_1, cacheForDir_1 = ts.createModeAwareCache());
102368
- }
102369
- cacheForDir_1.set(name, mode, r);
102370
- if (!moduleNameToDirectoryMap || ts.isExternalModuleNameRelative(name))
102371
- return;
102372
- var actualModuleNameToDirectoryMap = moduleNameToDirectoryMap.createMapForCompilerOptions(options_3, key_2);
102373
- var modeAwareCacheKey = ts.getModeAwareCacheKey(name, mode);
102374
- var directoryPathMap = actualModuleNameToDirectoryMap.get(modeAwareCacheKey);
102375
- if (!directoryPathMap)
102376
- actualModuleNameToDirectoryMap.set(modeAwareCacheKey, directoryPathMap = new ts.Map());
102377
- ts.moduleNameToDirectorySet(directoryPathMap, dirPath_1, r, ts.getResolvedFileNameForModuleNameToDirectorySet, function (dir) { return resolutionHost.toPath(dir); }, ts.noop);
102378
- });
102379
- }
102380
- if (((resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size()) || 0) !== seenNamesInFile.size()) {
102381
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102382
- if (!seenNamesInFile.has(name, mode)) {
102383
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102384
- resolutionsInFile.cache.delete(name, mode);
102385
- }
102386
- });
102387
- if (!(resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.size))
102388
- perFileCache.delete(path);
102389
- }
102390
- return perDirCache;
102391
- }
102392
- function getOldResolutionCache(modules, typeRefs, moduleNameToDirectoryMap) {
102393
- if (!modules && !typeRefs)
102394
- return undefined;
102395
- return {
102396
- modules: {
102397
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, modules, moduleNameToDirectoryMap); }
102398
- },
102399
- typeRefs: {
102400
- getResolved: function (dirPath, name, mode, redirectedReference) { return getResolvedWithOldCache(dirPath, name, mode, redirectedReference, typeRefs, undefined); }
102401
- },
102402
- clearRedirectsMap: function () {
102403
- modules === null || modules === void 0 ? void 0 : modules.clearRedirectsMap();
102404
- typeRefs === null || typeRefs === void 0 ? void 0 : typeRefs.clearRedirectsMap();
102405
- moduleNameToDirectoryMap.clearRedirectsMap();
102406
- },
102407
- };
102408
- }
102409
- function getResolvedWithOldCache(dirPath, name, mode, redirectedReference, perDirCache, moduleNameToDirectoryMap) {
102410
- var _a, _b, _c, _d;
102411
- if (!perDirCache)
102412
- return undefined;
102413
- var result = ((_b = (_a = perDirCache.getMapOfCacheRedirects(redirectedReference)) === null || _a === void 0 ? void 0 : _a.get(dirPath)) === null || _b === void 0 ? void 0 : _b.get(name, mode)) ||
102414
- ((_d = (_c = moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) === null || _c === void 0 ? void 0 : _c.get(ts.getModeAwareCacheKey(name, mode))) === null || _d === void 0 ? void 0 : _d.get(dirPath));
102415
- return result && !result.isInvalidated ? result : undefined;
101578
+ });
101579
+ hasChangedAutomaticTypeDirectiveNames = false;
102416
101580
  }
102417
101581
  function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
102418
- var _a;
101582
+ var _a, _b;
102419
101583
  var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
102420
101584
  if (!resolutionHost.getGlobalCache) {
102421
101585
  return primaryResult;
102422
101586
  }
102423
101587
  var globalCache = resolutionHost.getGlobalCache();
102424
101588
  if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
102425
- var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations, affectingLocations = _b.affectingLocations, resolutionDiagnostics = _b.resolutionDiagnostics;
101589
+ 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;
102426
101590
  if (resolvedModule) {
102427
101591
  primaryResult.resolvedModule = resolvedModule;
102428
- if (!compilerOptions.cacheResolutions)
102429
- (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
102430
- else
102431
- primaryResult.failedLookupLocations.length = 0;
102432
- primaryResult.affectingLocations = ts.updateResolutionField(primaryResult.affectingLocations, affectingLocations);
102433
- primaryResult.resolutionDiagnostics = ts.updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
101592
+ (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
101593
+ (_b = primaryResult.affectingLocations).push.apply(_b, affectingLocations);
102434
101594
  return primaryResult;
102435
101595
  }
102436
101596
  }
@@ -102440,35 +101600,68 @@ var ts;
102440
101600
  return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
102441
101601
  }
102442
101602
  function resolveNamesWithLocalCache(_a) {
102443
- var _b, _c, _d, _e;
102444
- var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, perFileCache = _a.perFileCache, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, partialResolutionInfo = _a.partialResolutionInfo, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
101603
+ var _b, _c, _d;
101604
+ 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;
102445
101605
  var path = resolutionHost.toPath(containingFile);
102446
- var resolutionsInFile = perFileCache.get(path);
102447
- var compilerOptions = resolutionHost.getCompilationSettings();
102448
- var key = ts.getRedirectsCacheKey((redirectedReference === null || redirectedReference === void 0 ? void 0 : redirectedReference.commandLine.options) || compilerOptions);
102449
- if (!resolutionsInFile || resolutionsInFile.key !== key) {
102450
- resolutionsInFile === null || resolutionsInFile === void 0 ? void 0 : resolutionsInFile.cache.forEach(function (r) { return stopWatchingResolution(r, path, getResolutionWithResolvedFileName); });
102451
- perFileCache.set(path, resolutionsInFile = { key: key, cache: ts.createModeAwareCache() });
101606
+ var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
101607
+ var dirPath = ts.getDirectoryPath(path);
101608
+ var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
101609
+ var perDirectoryResolution = perDirectoryCache.get(dirPath);
101610
+ if (!perDirectoryResolution) {
101611
+ perDirectoryResolution = ts.createModeAwareCache();
101612
+ perDirectoryCache.set(dirPath, perDirectoryResolution);
102452
101613
  }
102453
101614
  var resolvedModules = [];
101615
+ var compilerOptions = resolutionHost.getCompilationSettings();
101616
+ var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
101617
+ var program = resolutionHost.getCurrentProgram();
101618
+ var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
101619
+ var unmatchedRedirects = oldRedirect ?
101620
+ !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
101621
+ !!redirectedReference;
102454
101622
  var seenNamesInFile = ts.createModeAwareCache();
102455
101623
  var i = 0;
102456
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
102457
- var entry = names_4[_i];
102458
- var name = ts.isString(entry) ? entry : ts.toFileNameLowerCase(entry.fileName);
101624
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
101625
+ var entry = names_5[_i];
101626
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
102459
101627
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
102460
- containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, (_b = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.namesIndex[i]) !== null && _b !== void 0 ? _b : i) : undefined;
101628
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
102461
101629
  i++;
102462
- var resolution = resolutionsInFile.cache.get(name, mode);
102463
- if (!seenNamesInFile.has(name, mode) && (!resolution || resolution.isInvalidated)) {
101630
+ var resolution = resolutionsInFile.get(name, mode);
101631
+ if (!seenNamesInFile.has(name, mode) &&
101632
+ unmatchedRedirects || !resolution || resolution.isInvalidated ||
101633
+ (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
102464
101634
  var existingResolution = resolution;
102465
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
102466
- if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
102467
- resolutionHost.onDiscoveredSymlink();
101635
+ var resolutionInDirectory = perDirectoryResolution.get(name, mode);
101636
+ if (resolutionInDirectory) {
101637
+ resolution = resolutionInDirectory;
101638
+ var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
101639
+ if (ts.isTraceEnabled(compilerOptions, host)) {
101640
+ var resolved = getResolutionWithResolvedFileName(resolution);
101641
+ ts.trace(host, loader === resolveModuleName ?
101642
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101643
+ resolved.packagetId ?
101644
+ 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 :
101645
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101646
+ ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
101647
+ (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
101648
+ resolved.packagetId ?
101649
+ 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 :
101650
+ ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
101651
+ 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));
101652
+ }
102468
101653
  }
102469
- resolutionsInFile.cache.set(name, mode, resolution);
101654
+ else {
101655
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
101656
+ perDirectoryResolution.set(name, mode, resolution);
101657
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
101658
+ resolutionHost.onDiscoveredSymlink();
101659
+ }
101660
+ }
101661
+ resolutionsInFile.set(name, mode, resolution);
101662
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
102470
101663
  if (existingResolution) {
102471
- stopWatchingResolution(existingResolution, path, getResolutionWithResolvedFileName);
101664
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
102472
101665
  }
102473
101666
  if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
102474
101667
  filesWithChangedSetOfUnresolvedImports.push(path);
@@ -102481,33 +101674,27 @@ var ts;
102481
101674
  var resolved = getResolutionWithResolvedFileName(resolution);
102482
101675
  ts.trace(host, loader === resolveModuleName ?
102483
101676
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
102484
- resolved.packageId ?
101677
+ resolved.packagetId ?
102485
101678
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
102486
101679
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
102487
101680
  ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved :
102488
101681
  (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
102489
- resolved.packageId ?
101682
+ resolved.packagetId ?
102490
101683
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 :
102491
101684
  ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 :
102492
- ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packageId) && ts.packageIdToString(resolved.packageId));
101685
+ 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));
102493
101686
  }
102494
101687
  }
102495
101688
  ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
102496
101689
  seenNamesInFile.set(name, mode, true);
102497
- resolvedModules.push(resolution);
101690
+ resolvedModules.push(getResolutionWithResolvedFileName(resolution));
102498
101691
  }
102499
- (_e = partialResolutionInfo === null || partialResolutionInfo === void 0 ? void 0 : partialResolutionInfo.reusedNames) === null || _e === void 0 ? void 0 : _e.forEach(function (_a) {
102500
- var name = _a.name, mode = _a.mode;
102501
- return seenNamesInFile.set(name, mode, true);
101692
+ resolutionsInFile.forEach(function (resolution, name, mode) {
101693
+ if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
101694
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
101695
+ resolutionsInFile.delete(name, mode);
101696
+ }
102502
101697
  });
102503
- if (resolutionsInFile.cache.size() !== seenNamesInFile.size()) {
102504
- resolutionsInFile.cache.forEach(function (resolution, name, mode) {
102505
- if (!seenNamesInFile.has(name, mode)) {
102506
- stopWatchingResolution(resolution, path, getResolutionWithResolvedFileName);
102507
- resolutionsInFile.cache.delete(name, mode);
102508
- }
102509
- });
102510
- }
102511
101698
  return resolvedModules;
102512
101699
  function resolutionIsEqualTo(oldResolution, newResolution) {
102513
101700
  if (oldResolution === newResolution) {
@@ -102527,31 +101714,40 @@ var ts;
102527
101714
  return oldResult.resolvedFileName === newResult.resolvedFileName;
102528
101715
  }
102529
101716
  }
102530
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo) {
101717
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
102531
101718
  return resolveNamesWithLocalCache({
102532
101719
  names: typeDirectiveNames,
102533
101720
  containingFile: containingFile,
102534
101721
  redirectedReference: redirectedReference,
102535
- perFileCache: resolvedTypeReferenceDirectives,
101722
+ cache: resolvedTypeReferenceDirectives,
101723
+ perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
102536
101724
  loader: resolveTypeReferenceDirective,
102537
101725
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
102538
- containingSourceFileMode: containingFileMode,
102539
- partialResolutionInfo: partialResolutionInfo,
101726
+ shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
101727
+ containingSourceFileMode: containingFileMode
102540
101728
  });
102541
101729
  }
102542
- function resolveModuleNames(moduleNames, containingFile, redirectedReference, containingSourceFile, partialResolutionInfo) {
101730
+ function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
102543
101731
  return resolveNamesWithLocalCache({
102544
101732
  names: moduleNames,
102545
101733
  containingFile: containingFile,
102546
101734
  redirectedReference: redirectedReference,
102547
- perFileCache: resolvedModuleNames,
101735
+ cache: resolvedModuleNames,
101736
+ perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
102548
101737
  loader: resolveModuleName,
102549
101738
  getResolutionWithResolvedFileName: getResolvedModule,
102550
- partialResolutionInfo: partialResolutionInfo,
101739
+ shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
101740
+ reusedNames: reusedNames,
102551
101741
  logChanges: logChangesWhenResolvingModule,
102552
101742
  containingSourceFile: containingSourceFile,
102553
101743
  });
102554
101744
  }
101745
+ function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
101746
+ var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
101747
+ if (!cache)
101748
+ return undefined;
101749
+ return cache.get(moduleName, resolutionMode);
101750
+ }
102555
101751
  function isNodeModulesAtTypesDirectory(dirPath) {
102556
101752
  return ts.endsWith(dirPath, "/node_modules/@types");
102557
101753
  }
@@ -102605,41 +101801,37 @@ var ts;
102605
101801
  function isPathWithDefaultFailedLookupExtension(path) {
102606
101802
  return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
102607
101803
  }
102608
- function watchResolution(newProgram, name, resolution, filePath, getResolutionWithResolvedFileName) {
102609
- if (resolution.files) {
102610
- resolution.files.add(filePath);
102611
- if (resolution.watchedFailed !== false)
102612
- watchFailedLookupLocationOfResolution(resolution);
102613
- watchAffectingLocationsOfResolution(resolution);
102614
- return;
102615
- }
102616
- resolution.files = new ts.Set();
102617
- resolution.files.add(filePath);
102618
- var resolved = getResolutionWithResolvedFileName(resolution);
102619
- if (resolved && resolved.resolvedFileName) {
102620
- resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102621
- }
102622
- if (ts.isExternalModuleNameRelative(name) || !newProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
102623
- watchFailedLookupLocationOfResolution(resolution);
102624
- watchAffectingLocationsOfResolution(resolution);
101804
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
101805
+ if (resolution.refCount) {
101806
+ resolution.refCount++;
101807
+ ts.Debug.assertIsDefined(resolution.files);
102625
101808
  }
102626
101809
  else {
102627
- resolution.watchedFailed = false;
102628
- watchAffectingLocationsOfResolution(resolution);
101810
+ resolution.refCount = 1;
101811
+ ts.Debug.assert(ts.length(resolution.files) === 0);
101812
+ if (ts.isExternalModuleNameRelative(name)) {
101813
+ watchFailedLookupLocationOfResolution(resolution);
101814
+ }
101815
+ else {
101816
+ nonRelativeExternalModuleResolutions.add(name, resolution);
101817
+ }
101818
+ var resolved = getResolutionWithResolvedFileName(resolution);
101819
+ if (resolved && resolved.resolvedFileName) {
101820
+ resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
101821
+ }
102629
101822
  }
101823
+ (resolution.files || (resolution.files = [])).push(filePath);
102630
101824
  }
102631
101825
  function watchFailedLookupLocationOfResolution(resolution) {
102632
- var failedLookupLocations = resolution.failedLookupLocations;
102633
- if (!failedLookupLocations.length || resolution.watchedFailed === failedLookupLocations.length)
101826
+ ts.Debug.assert(!!resolution.refCount);
101827
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
101828
+ if (!failedLookupLocations.length && !affectingLocations.length)
102634
101829
  return;
102635
- if (!resolution.watchedFailed) {
101830
+ if (failedLookupLocations.length)
102636
101831
  resolutionsWithFailedLookups.push(resolution);
102637
- if (resolution.watchedAffected)
102638
- ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102639
- }
102640
- var setAtRoot = !!resolution.setAtRoot;
102641
- for (var i = resolution.watchedFailed || 0; i < failedLookupLocations.length; i++) {
102642
- var failedLookupLocation = failedLookupLocations[i];
101832
+ var setAtRoot = false;
101833
+ for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
101834
+ var failedLookupLocation = failedLookupLocations_1[_i];
102643
101835
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102644
101836
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102645
101837
  if (toWatch) {
@@ -102657,22 +101849,22 @@ var ts;
102657
101849
  }
102658
101850
  }
102659
101851
  }
102660
- if (setAtRoot && !resolution.setAtRoot) {
101852
+ if (setAtRoot) {
102661
101853
  setDirectoryWatcher(rootDir, rootPath, true);
102662
101854
  }
102663
- resolution.setAtRoot = setAtRoot;
102664
- resolution.watchedFailed = failedLookupLocations.length;
101855
+ watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length);
102665
101856
  }
102666
- function watchAffectingLocationsOfResolution(resolution) {
101857
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
101858
+ ts.Debug.assert(!!resolution.refCount);
102667
101859
  var affectingLocations = resolution.affectingLocations;
102668
- if (!(affectingLocations === null || affectingLocations === void 0 ? void 0 : affectingLocations.length) || resolution.watchedAffected === affectingLocations.length)
101860
+ if (!affectingLocations.length)
102669
101861
  return;
102670
- if (!resolution.watchedFailed && !resolution.watchedAffected)
101862
+ if (addToResolutionsWithOnlyAffectingLocations)
102671
101863
  resolutionsWithOnlyAffectingLocations.push(resolution);
102672
- for (var i = resolution.watchedAffected || 0; i < affectingLocations.length; i++) {
102673
- createFileWatcherOfAffectingLocation(affectingLocations[i]);
101864
+ for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
101865
+ var affectingLocation = affectingLocations_1[_i];
101866
+ createFileWatcherOfAffectingLocation(affectingLocation);
102674
101867
  }
102675
- resolution.watchedAffected = affectingLocations.length;
102676
101868
  }
102677
101869
  function createFileWatcherOfAffectingLocation(affectingLocation) {
102678
101870
  var path = resolutionHost.toPath(affectingLocation);
@@ -102713,6 +101905,15 @@ var ts;
102713
101905
  paths.add(path);
102714
101906
  }
102715
101907
  }
101908
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
101909
+ var program = resolutionHost.getCurrentProgram();
101910
+ if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
101911
+ resolutions.forEach(watchFailedLookupLocationOfResolution);
101912
+ }
101913
+ else {
101914
+ resolutions.forEach(function (resolution) { return watchAffectingLocationsOfResolution(resolution, true); });
101915
+ }
101916
+ }
102716
101917
  function setDirectoryWatcher(dir, dirPath, nonRecursive) {
102717
101918
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102718
101919
  if (dirWatcher) {
@@ -102723,27 +101924,21 @@ var ts;
102723
101924
  directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
102724
101925
  }
102725
101926
  }
102726
- function stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName) {
102727
- var _a, _b;
102728
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.delete(filePath);
102729
- if (!((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size))
102730
- (resolutionsToCloseWatcherOn !== null && resolutionsToCloseWatcherOn !== void 0 ? resolutionsToCloseWatcherOn : (resolutionsToCloseWatcherOn = [])).push({ resolution: resolution, getResolved: getResolutionWithResolvedFileName });
102731
- }
102732
- function closeWatchersOfResolution(_a) {
102733
- var _b;
102734
- var resolution = _a.resolution, getResolved = _a.getResolved;
102735
- if (((_b = resolution.files) === null || _b === void 0 ? void 0 : _b.size) || !resolution.files)
101927
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
101928
+ ts.unorderedRemoveItem(ts.Debug.checkDefined(resolution.files), filePath);
101929
+ resolution.refCount--;
101930
+ if (resolution.refCount) {
102736
101931
  return;
102737
- resolution.files = undefined;
102738
- var resolved = getResolved(resolution);
101932
+ }
101933
+ var resolved = getResolutionWithResolvedFileName(resolution);
102739
101934
  if (resolved && resolved.resolvedFileName) {
102740
101935
  resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
102741
101936
  }
102742
- if (resolution.watchedFailed) {
102743
- ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution);
101937
+ var failedLookupLocations = resolution.failedLookupLocations, affectingLocations = resolution.affectingLocations;
101938
+ if (ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
102744
101939
  var removeAtRoot = false;
102745
- for (var i = 0; i < resolution.watchedFailed; i++) {
102746
- var failedLookupLocation = resolution.failedLookupLocations[i];
101940
+ for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
101941
+ var failedLookupLocation = failedLookupLocations_2[_i];
102747
101942
  var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
102748
101943
  var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
102749
101944
  if (toWatch) {
@@ -102766,31 +101961,22 @@ var ts;
102766
101961
  }
102767
101962
  }
102768
101963
  }
102769
- ts.Debug.assert(resolution.setAtRoot === removeAtRoot);
102770
101964
  if (removeAtRoot) {
102771
101965
  removeDirectoryWatcher(rootPath);
102772
101966
  }
102773
101967
  }
102774
- else if (resolution.watchedAffected) {
101968
+ else if (affectingLocations.length) {
102775
101969
  ts.unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution);
102776
101970
  }
102777
- if (resolution.watchedAffected) {
102778
- for (var i = 0; i < resolution.watchedAffected; i++) {
102779
- var affectingLocation = resolution.affectingLocations[i];
102780
- var path = resolutionHost.toPath(affectingLocation);
102781
- var watcher = fileWatchesOfAffectingLocations.get(path);
102782
- watcher.refCount--;
102783
- closeAffectingFileWatcher(watcher, path);
102784
- }
101971
+ for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
101972
+ var affectingLocation = affectingLocations_2[_a];
101973
+ var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation));
101974
+ watcher.refCount--;
102785
101975
  }
102786
101976
  }
102787
101977
  function removeDirectoryWatcher(dirPath) {
102788
101978
  var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
102789
101979
  dirWatcher.refCount--;
102790
- if (dirWatcher.refCount === 0) {
102791
- directoryWatchesOfFailedLookups.delete(dirPath);
102792
- dirWatcher.watcher.close();
102793
- }
102794
101980
  }
102795
101981
  function createDirectoryWatcher(directory, dirPath, nonRecursive) {
102796
101982
  return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
@@ -102804,16 +101990,26 @@ var ts;
102804
101990
  function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
102805
101991
  var resolutions = cache.get(filePath);
102806
101992
  if (resolutions) {
102807
- resolutions.cache.forEach(function (resolution) { return stopWatchingResolution(resolution, filePath, getResolutionWithResolvedFileName); });
101993
+ resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
102808
101994
  cache.delete(filePath);
102809
101995
  }
102810
101996
  }
101997
+ function removeResolutionsFromProjectReferenceRedirects(filePath) {
101998
+ if (!ts.fileExtensionIs(filePath, ".json"))
101999
+ return;
102000
+ var program = resolutionHost.getCurrentProgram();
102001
+ if (!program)
102002
+ return;
102003
+ var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
102004
+ if (!resolvedProjectReference)
102005
+ return;
102006
+ resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
102007
+ }
102811
102008
  function removeResolutionsOfFile(filePath) {
102812
102009
  removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
102813
102010
  removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
102814
102011
  }
102815
102012
  function invalidateResolutions(resolutions, canInvalidate) {
102816
- var _a;
102817
102013
  if (!resolutions)
102818
102014
  return false;
102819
102015
  var invalidated = false;
@@ -102822,14 +102018,16 @@ var ts;
102822
102018
  if (resolution.isInvalidated || !canInvalidate(resolution))
102823
102019
  continue;
102824
102020
  resolution.isInvalidated = invalidated = true;
102825
- (_a = resolution.files) === null || _a === void 0 ? void 0 : _a.forEach(function (containingFilePath) {
102021
+ for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
102022
+ var containingFilePath = _b[_a];
102826
102023
  (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
102827
102024
  hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
102828
- });
102025
+ }
102829
102026
  }
102830
102027
  return invalidated;
102831
102028
  }
102832
102029
  function invalidateResolutionOfFile(filePath) {
102030
+ removeResolutionsOfFile(filePath);
102833
102031
  var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
102834
102032
  if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
102835
102033
  hasChangedAutomaticTypeDirectiveNames &&
@@ -102838,28 +102036,8 @@ var ts;
102838
102036
  }
102839
102037
  }
102840
102038
  function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
102841
- filesMap.forEach(function (_a, filePath) {
102842
- var imports = _a.imports;
102843
- if (!imports.length)
102844
- return;
102845
- var resolvedModules = resolvedModuleNames.get(filePath);
102846
- var resolvedTypeRefs = resolvedTypeReferenceDirectives.get(filePath);
102847
- if (!(resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.size()) && !(resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.size()))
102848
- return;
102849
- imports.forEach(function (_a) {
102850
- var name = _a.name, mode = _a.mode;
102851
- var resolvedModule = resolvedModules === null || resolvedModules === void 0 ? void 0 : resolvedModules.cache.get(name, mode);
102852
- if (resolvedModule && !resolvedModule.isInvalidated && (!resolvedModule.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolvedModule.resolvedModule.extension))) {
102853
- resolvedModule.isInvalidated = true;
102854
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
102855
- }
102856
- var resolvedTypeRef = resolvedTypeRefs === null || resolvedTypeRefs === void 0 ? void 0 : resolvedTypeRefs.cache.get(name, mode);
102857
- if (resolvedTypeRef && !resolvedTypeRef.isInvalidated && !resolvedTypeRef.resolvedTypeReferenceDirective) {
102858
- resolvedTypeRef.isInvalidated = true;
102859
- (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(filePath);
102860
- }
102861
- });
102862
- });
102039
+ ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
102040
+ filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
102863
102041
  }
102864
102042
  function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
102865
102043
  if (isCreatingWatchedDirectory) {
@@ -102919,10 +102097,9 @@ var ts;
102919
102097
  });
102920
102098
  }
102921
102099
  function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
102922
- var _a;
102923
- return !!affectingPathChecks && !!((_a = resolution.affectingLocations) === null || _a === void 0 ? void 0 : _a.some(function (location) {
102100
+ return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
102924
102101
  return affectingPathChecks.has(resolutionHost.toPath(location));
102925
- }));
102102
+ });
102926
102103
  }
102927
102104
  function closeTypeRootsWatch() {
102928
102105
  ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
@@ -103224,9 +102401,9 @@ var ts;
103224
102401
  var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
103225
102402
  var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
103226
102403
  if (!preferSymlinks) {
103227
- var result_17 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
103228
- if (result_17)
103229
- return result_17;
102404
+ var result_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
102405
+ if (result_16)
102406
+ return result_16;
103230
102407
  }
103231
102408
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
103232
102409
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -103245,10 +102422,10 @@ var ts;
103245
102422
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
103246
102423
  var symlinkDirectory = symlinkDirectories_1[_i];
103247
102424
  var option = ts.resolvePath(symlinkDirectory, relative);
103248
- var result_18 = cb(option, target === referenceRedirect);
102425
+ var result_17 = cb(option, target === referenceRedirect);
103249
102426
  shouldFilterIgnoredPaths = true;
103250
- if (result_18)
103251
- return result_18;
102427
+ if (result_17)
102428
+ return result_17;
103252
102429
  }
103253
102430
  });
103254
102431
  });
@@ -103307,9 +102484,9 @@ var ts;
103307
102484
  };
103308
102485
  var out_directory_1;
103309
102486
  for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
103310
- var state_12 = _loop_35(directory);
102487
+ var state_11 = _loop_35(directory);
103311
102488
  directory = out_directory_1;
103312
- if (state_12 === "break")
102489
+ if (state_11 === "break")
103313
102490
  break;
103314
102491
  }
103315
102492
  if (allFileNames.size) {
@@ -104189,7 +103366,7 @@ var ts;
104189
103366
  })(ts || (ts = {}));
104190
103367
  var ts;
104191
103368
  (function (ts) {
104192
- function readBuildInfoForProgram(compilerOptions, host) {
103369
+ function readBuilderProgram(compilerOptions, host) {
104193
103370
  var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
104194
103371
  if (!buildInfoPath)
104195
103372
  return undefined;
@@ -104209,12 +103386,7 @@ var ts;
104209
103386
  return undefined;
104210
103387
  if (!buildInfo.program)
104211
103388
  return undefined;
104212
- return { buildInfo: buildInfo, buildInfoPath: buildInfoPath };
104213
- }
104214
- ts.readBuildInfoForProgram = readBuildInfoForProgram;
104215
- function readBuilderProgram(compilerOptions, host) {
104216
- var result = readBuildInfoForProgram(compilerOptions, host);
104217
- return result && ts.createBuilderProgramUsingProgramBuildInfo(result.buildInfo.program, result.buildInfoPath, host, compilerOptions.configFilePath);
103389
+ return ts.createBuilderProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
104218
103390
  }
104219
103391
  ts.readBuilderProgram = readBuilderProgram;
104220
103392
  function createIncrementalCompilerHost(options, system) {
@@ -104347,7 +103519,7 @@ var ts;
104347
103519
  }
104348
103520
  return host.resolveModuleNames.apply(host, args);
104349
103521
  }) :
104350
- (function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, sourceFile, partialResolutionInfo) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, redirectedReference, sourceFile, partialResolutionInfo); });
103522
+ (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
104351
103523
  compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
104352
103524
  (function () {
104353
103525
  var args = [];
@@ -104356,13 +103528,7 @@ var ts;
104356
103528
  }
104357
103529
  return host.resolveTypeReferenceDirectives.apply(host, args);
104358
103530
  }) :
104359
- (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, partialResolutionInfo) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, partialResolutionInfo); });
104360
- compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
104361
- ts.maybeBind(host, host.getModuleResolutionCache) :
104362
- (function () { return resolutionCache.getModuleResolutionCache(); });
104363
- compilerHost.getTypeReferenceDirectiveResolutionCache = host.resolveTypeReferenceDirectives ?
104364
- ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache) :
104365
- (function () { return resolutionCache.getTypeReferenceDirectiveResolutionCache(); });
103531
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
104366
103532
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
104367
103533
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
104368
103534
  synchronizeProgram();
@@ -104428,8 +103594,7 @@ var ts;
104428
103594
  }
104429
103595
  }
104430
103596
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
104431
- var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
104432
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103597
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
104433
103598
  if (hasChangedConfigFileParsingErrors) {
104434
103599
  if (reportFileChangeDetectedOnCreateProgram) {
104435
103600
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -104448,11 +103613,6 @@ var ts;
104448
103613
  if (host.afterProgramCreate && program !== builderProgram) {
104449
103614
  host.afterProgramCreate(builderProgram);
104450
103615
  }
104451
- compilerHost.readFile = originalReadFile;
104452
- compilerHost.fileExists = originalFileExists;
104453
- compilerHost.directoryExists = originalDirectoryExists;
104454
- compilerHost.createDirectory = originalCreateDirectory;
104455
- compilerHost.writeFile = originalWriteFile;
104456
103616
  return builderProgram;
104457
103617
  }
104458
103618
  function createNewProgram(hasInvalidatedResolution) {
@@ -104461,15 +103621,18 @@ var ts;
104461
103621
  writeLog(" options: " + JSON.stringify(compilerOptions));
104462
103622
  if (projectReferences)
104463
103623
  writeLog(" projectReferences: " + JSON.stringify(projectReferences));
103624
+ var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
104464
103625
  hasChangedCompilerOptions = false;
104465
103626
  hasChangedConfigFileParsingErrors = false;
104466
103627
  resolutionCache.startCachingPerDirectoryResolution();
104467
103628
  compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
104468
103629
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
104469
- var oldProgram = getCurrentProgram();
104470
103630
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
104471
- resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
103631
+ resolutionCache.finishCachingPerDirectoryResolution();
104472
103632
  ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
103633
+ if (needsUpdateInTypeRootWatch) {
103634
+ resolutionCache.updateTypeRootsWatch();
103635
+ }
104473
103636
  if (missingFilePathsRequestedForRelease) {
104474
103637
  for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
104475
103638
  var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
@@ -104535,6 +103698,9 @@ var ts;
104535
103698
  sourceFilesCache.set(path, false);
104536
103699
  }
104537
103700
  }
103701
+ if (sourceFile) {
103702
+ sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
103703
+ }
104538
103704
  return sourceFile;
104539
103705
  }
104540
103706
  return hostSourceFile.sourceFile;
@@ -104554,7 +103720,7 @@ var ts;
104554
103720
  var hostSourceFile = sourceFilesCache.get(path);
104555
103721
  return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
104556
103722
  }
104557
- function onReleaseOldSourceFile(oldSourceFile) {
103723
+ function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
104558
103724
  var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
104559
103725
  if (hostSourceFileInfo !== undefined) {
104560
103726
  if (isFileMissingOnHost(hostSourceFileInfo)) {
@@ -104565,6 +103731,9 @@ var ts;
104565
103731
  hostSourceFileInfo.fileWatcher.close();
104566
103732
  }
104567
103733
  sourceFilesCache.delete(oldSourceFile.resolvedPath);
103734
+ if (!hasSourceFileByPath) {
103735
+ resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
103736
+ }
104568
103737
  }
104569
103738
  }
104570
103739
  }
@@ -104799,6 +103968,7 @@ var ts;
104799
103968
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath);
104800
103969
  if (config)
104801
103970
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
103971
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath);
104802
103972
  }
104803
103973
  scheduleProgramUpdate();
104804
103974
  });
@@ -104811,6 +103981,7 @@ var ts;
104811
103981
  var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath);
104812
103982
  if (config)
104813
103983
  config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
103984
+ resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath);
104814
103985
  scheduleProgramUpdate();
104815
103986
  }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject));
104816
103987
  if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) {
@@ -104982,23 +104153,20 @@ var ts;
104982
104153
  compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
104983
104154
  compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
104984
104155
  compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
104985
- compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
104986
- compilerHost.getTypeReferenceDirectiveResolutionCache = ts.maybeBind(host, host.getTypeReferenceDirectiveResolutionCache);
104987
104156
  var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
104988
104157
  var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
104989
104158
  if (!compilerHost.resolveModuleNames) {
104990
- var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode); };
104991
- compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, partialResolutionInfo) {
104992
- return ts.loadWithModeAwareCache(moduleNames, ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, partialResolutionInfo, loader_3);
104159
+ var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
104160
+ compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
104161
+ return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
104993
104162
  };
104994
104163
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
104995
104164
  }
104996
104165
  if (!compilerHost.resolveTypeReferenceDirectives) {
104997
- var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode); };
104166
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
104998
104167
  compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
104999
- return ts.loadWithTypeDirectiveCache(typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode, loader_4);
104168
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
105000
104169
  };
105001
- compilerHost.getTypeReferenceDirectiveResolutionCache = function () { return typeReferenceDirectiveResolutionCache; };
105002
104170
  }
105003
104171
  compilerHost.getBuildInfo = function (fileName, configFilePath) { return getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath), undefined); };
105004
104172
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
@@ -105942,7 +105110,7 @@ var ts;
105942
105110
  if (buildInfoTime && buildInfoTime < inputTime) {
105943
105111
  var version_3 = void 0;
105944
105112
  var currentVersion = void 0;
105945
- if (buildInfoProgram === null || buildInfoProgram === void 0 ? void 0 : buildInfoProgram.fileInfos) {
105113
+ if (buildInfoProgram) {
105946
105114
  if (!buildInfoVersionMap)
105947
105115
  buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
105948
105116
  version_3 = buildInfoVersionMap.get(toPath(state, inputFile));