typescript 5.0.0-dev.20221115 → 5.0.0-dev.20221116

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
@@ -23,7 +23,7 @@ var __export = (target, all) => {
23
23
 
24
24
  // src/compiler/corePublic.ts
25
25
  var versionMajorMinor = "5.0";
26
- var version = `${versionMajorMinor}.0-dev.20221115`;
26
+ var version = `${versionMajorMinor}.0-dev.20221116`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -1294,15 +1294,9 @@ function isNodeLikeSystem() {
1294
1294
  // src/compiler/debug.ts
1295
1295
  var Debug;
1296
1296
  ((Debug2) => {
1297
- let typeScriptVersion2;
1298
1297
  let currentAssertionLevel = 0 /* None */;
1299
1298
  Debug2.currentLogLevel = 2 /* Warning */;
1300
1299
  Debug2.isDebugging = false;
1301
- Debug2.enableDeprecationWarnings = true;
1302
- function getTypeScriptVersion() {
1303
- return typeScriptVersion2 != null ? typeScriptVersion2 : typeScriptVersion2 = new Version(version);
1304
- }
1305
- Debug2.getTypeScriptVersion = getTypeScriptVersion;
1306
1300
  function shouldLog(level) {
1307
1301
  return Debug2.currentLogLevel <= level;
1308
1302
  }
@@ -1818,52 +1812,6 @@ Node ${formatSyntaxKind(node.kind)} was unexpected.`,
1818
1812
  isDebugInfoEnabled = true;
1819
1813
  }
1820
1814
  Debug2.enableDebugInfo = enableDebugInfo;
1821
- function formatDeprecationMessage(name, error, errorAfter, since, message) {
1822
- let deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: ";
1823
- deprecationMessage += `'${name}' `;
1824
- deprecationMessage += since ? `has been deprecated since v${since}` : "is deprecated";
1825
- deprecationMessage += error ? " and can no longer be used." : errorAfter ? ` and will no longer be usable after v${errorAfter}.` : ".";
1826
- deprecationMessage += message ? ` ${formatStringFromArgs(message, [name], 0)}` : "";
1827
- return deprecationMessage;
1828
- }
1829
- function createErrorDeprecation(name, errorAfter, since, message) {
1830
- const deprecationMessage = formatDeprecationMessage(name, true, errorAfter, since, message);
1831
- return () => {
1832
- throw new TypeError(deprecationMessage);
1833
- };
1834
- }
1835
- function createWarningDeprecation(name, errorAfter, since, message) {
1836
- let hasWrittenDeprecation = false;
1837
- return () => {
1838
- if (Debug2.enableDeprecationWarnings && !hasWrittenDeprecation) {
1839
- log.warn(formatDeprecationMessage(name, false, errorAfter, since, message));
1840
- hasWrittenDeprecation = true;
1841
- }
1842
- };
1843
- }
1844
- function createDeprecation(name, options = {}) {
1845
- var _a2, _b;
1846
- const version2 = typeof options.typeScriptVersion === "string" ? new Version(options.typeScriptVersion) : (_a2 = options.typeScriptVersion) != null ? _a2 : getTypeScriptVersion();
1847
- const errorAfter = typeof options.errorAfter === "string" ? new Version(options.errorAfter) : options.errorAfter;
1848
- const warnAfter = typeof options.warnAfter === "string" ? new Version(options.warnAfter) : options.warnAfter;
1849
- const since = typeof options.since === "string" ? new Version(options.since) : (_b = options.since) != null ? _b : warnAfter;
1850
- const error = options.error || errorAfter && version2.compareTo(errorAfter) <= 0;
1851
- const warn = !warnAfter || version2.compareTo(warnAfter) >= 0;
1852
- return error ? createErrorDeprecation(name, errorAfter, since, options.message) : warn ? createWarningDeprecation(name, errorAfter, since, options.message) : noop;
1853
- }
1854
- Debug2.createDeprecation = createDeprecation;
1855
- function wrapFunction(deprecation, func) {
1856
- return function() {
1857
- deprecation();
1858
- return func.apply(this, arguments);
1859
- };
1860
- }
1861
- function deprecate(func, options) {
1862
- var _a2;
1863
- const deprecation = createDeprecation((_a2 = options == null ? void 0 : options.name) != null ? _a2 : getFunctionName(func), options);
1864
- return wrapFunction(deprecation, func);
1865
- }
1866
- Debug2.deprecate = deprecate;
1867
1815
  function formatVariance(varianceFlags) {
1868
1816
  const variance = varianceFlags & 7 /* VarianceMask */;
1869
1817
  let result = variance === 0 /* Invariant */ ? "in out" : variance === 3 /* Bivariant */ ? "[bivariant]" : variance === 2 /* Contravariant */ ? "in" : variance === 1 /* Covariant */ ? "out" : variance === 4 /* Independent */ ? "[independent]" : "";
@@ -6776,10 +6724,10 @@ var Diagnostics = {
6776
6724
  Module_name_0_matched_pattern_1: diag(6092, 3 /* Message */, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
6777
6725
  Trying_substitution_0_candidate_module_location_Colon_1: diag(6093, 3 /* Message */, "Trying_substitution_0_candidate_module_location_Colon_1_6093", "Trying substitution '{0}', candidate module location: '{1}'."),
6778
6726
  Resolving_module_name_0_relative_to_base_url_1_2: diag(6094, 3 /* Message */, "Resolving_module_name_0_relative_to_base_url_1_2_6094", "Resolving module name '{0}' relative to base url '{1}' - '{2}'."),
6779
- Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1: diag(6095, 3 /* Message */, "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095", "Loading module as file / folder, candidate module location '{0}', target file type '{1}'."),
6727
+ Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1: diag(6095, 3 /* Message */, "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1_6095", "Loading module as file / folder, candidate module location '{0}', target file types: {1}."),
6780
6728
  File_0_does_not_exist: diag(6096, 3 /* Message */, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
6781
6729
  File_0_exist_use_it_as_a_name_resolution_result: diag(6097, 3 /* Message */, "File_0_exist_use_it_as_a_name_resolution_result_6097", "File '{0}' exist - use it as a name resolution result."),
6782
- Loading_module_0_from_node_modules_folder_target_file_type_1: diag(6098, 3 /* Message */, "Loading_module_0_from_node_modules_folder_target_file_type_1_6098", "Loading module '{0}' from 'node_modules' folder, target file type '{1}'."),
6730
+ Loading_module_0_from_node_modules_folder_target_file_types_Colon_1: diag(6098, 3 /* Message */, "Loading_module_0_from_node_modules_folder_target_file_types_Colon_1_6098", "Loading module '{0}' from 'node_modules' folder, target file types: {1}."),
6783
6731
  Found_package_json_at_0: diag(6099, 3 /* Message */, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
6784
6732
  package_json_does_not_have_a_0_field: diag(6100, 3 /* Message */, "package_json_does_not_have_a_0_field_6100", "'package.json' does not have a '{0}' field."),
6785
6733
  package_json_has_0_field_1_that_references_2: diag(6101, 3 /* Message */, "package_json_has_0_field_1_that_references_2_6101", "'package.json' has '{0}' field '{1}' that references '{2}'."),
@@ -15134,6 +15082,7 @@ var supportedJSExtensionsFlat = flatten(supportedJSExtensions);
15134
15082
  var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
15135
15083
  var allSupportedExtensionsWithJson = [...allSupportedExtensions, [".json" /* Json */]];
15136
15084
  var supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */];
15085
+ var supportedTSImplementationExtensions = [".ts" /* Ts */, ".cts" /* Cts */, ".mts" /* Mts */, ".tsx" /* Tsx */];
15137
15086
  function getSupportedExtensions(options, extraFileExtensions) {
15138
15087
  const needJsExtensions = options && getAllowJSCompilerOption(options);
15139
15088
  if (!extraFileExtensions || extraFileExtensions.length === 0) {
@@ -21121,7 +21070,7 @@ var asyncDelegator = {
21121
21070
  var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
21122
21071
  var i, p;
21123
21072
  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
21124
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
21073
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
21125
21074
  };`
21126
21075
  };
21127
21076
  var asyncValues = {
@@ -32722,15 +32671,18 @@ function removeIgnoredPackageId(r) {
32722
32671
  return { path: r.path, ext: r.extension };
32723
32672
  }
32724
32673
  }
32725
- var Extensions = /* @__PURE__ */ ((Extensions2) => {
32726
- Extensions2[Extensions2["TypeScript"] = 0] = "TypeScript";
32727
- Extensions2[Extensions2["JavaScript"] = 1] = "JavaScript";
32728
- Extensions2[Extensions2["Json"] = 2] = "Json";
32729
- Extensions2[Extensions2["TSConfig"] = 3] = "TSConfig";
32730
- Extensions2[Extensions2["DtsOnly"] = 4] = "DtsOnly";
32731
- Extensions2[Extensions2["TsOnly"] = 5] = "TsOnly";
32732
- return Extensions2;
32733
- })(Extensions || {});
32674
+ function formatExtensions(extensions) {
32675
+ const result = [];
32676
+ if (extensions & 1 /* TypeScript */)
32677
+ result.push("TypeScript");
32678
+ if (extensions & 2 /* JavaScript */)
32679
+ result.push("JavaScript");
32680
+ if (extensions & 4 /* Declaration */)
32681
+ result.push("Declaration");
32682
+ if (extensions & 8 /* Json */)
32683
+ result.push("JSON");
32684
+ return result.join(", ");
32685
+ }
32734
32686
  function resolvedTypeScriptOnly(resolved) {
32735
32687
  if (!resolved) {
32736
32688
  return void 0;
@@ -32934,7 +32886,8 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
32934
32886
  features,
32935
32887
  conditions,
32936
32888
  requestContainingDirectory: containingDirectory,
32937
- reportDiagnostic: (diag2) => void diagnostics.push(diag2)
32889
+ reportDiagnostic: (diag2) => void diagnostics.push(diag2),
32890
+ isConfigLookup: false
32938
32891
  };
32939
32892
  let resolved = primaryLookup();
32940
32893
  let primary = true;
@@ -32984,7 +32937,7 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
32984
32937
  }
32985
32938
  return resolvedTypeScriptOnly(
32986
32939
  loadNodeModuleFromDirectory(
32987
- 4 /* DtsOnly */,
32940
+ 4 /* Declaration */,
32988
32941
  candidate,
32989
32942
  !directoryExists,
32990
32943
  moduleResolutionState
@@ -33005,11 +32958,11 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
33005
32958
  }
33006
32959
  let result2;
33007
32960
  if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
33008
- const searchResult = loadModuleFromNearestNodeModulesDirectory(4 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, void 0, void 0);
32961
+ const searchResult = loadModuleFromNearestNodeModulesDirectory(4 /* Declaration */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, void 0, void 0);
33009
32962
  result2 = searchResult && searchResult.value;
33010
32963
  } else {
33011
32964
  const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
33012
- result2 = nodeLoadModuleByRelativeName(4 /* DtsOnly */, candidate, false, moduleResolutionState, true);
32965
+ result2 = nodeLoadModuleByRelativeName(4 /* Declaration */, candidate, false, moduleResolutionState, true);
33013
32966
  }
33014
32967
  return resolvedTypeScriptOnly(result2);
33015
32968
  } else {
@@ -33525,38 +33478,42 @@ function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions,
33525
33478
  resolutionMode
33526
33479
  );
33527
33480
  }
33528
- var jsOnlyExtensions = [1 /* JavaScript */];
33529
- var tsExtensions = [0 /* TypeScript */, 1 /* JavaScript */];
33530
- var tsPlusJsonExtensions = [...tsExtensions, 2 /* Json */];
33531
- var tsconfigExtensions = [3 /* TSConfig */];
33532
33481
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
33533
33482
  const containingDirectory = getDirectoryPath(containingFile);
33534
33483
  const esmMode = resolutionMode === 99 /* ESNext */ ? 32 /* EsmMode */ : 0;
33535
- let extensions = compilerOptions.noDtsResolution ? [5 /* TsOnly */, 1 /* JavaScript */] : tsExtensions;
33484
+ let extensions = compilerOptions.noDtsResolution ? 3 /* ImplementationFiles */ : 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */;
33536
33485
  if (compilerOptions.resolveJsonModule) {
33537
- extensions = [...extensions, 2 /* Json */];
33486
+ extensions |= 8 /* Json */;
33538
33487
  }
33539
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
33488
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, false, redirectedReference);
33540
33489
  }
33541
33490
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
33542
- return nodeModuleNameResolverWorker(0 /* None */, moduleName, initialDir, { moduleResolution: 2 /* NodeJs */, allowJs: true }, host, void 0, jsOnlyExtensions, void 0);
33491
+ return nodeModuleNameResolverWorker(
33492
+ 0 /* None */,
33493
+ moduleName,
33494
+ initialDir,
33495
+ { moduleResolution: 2 /* NodeJs */, allowJs: true },
33496
+ host,
33497
+ void 0,
33498
+ 2 /* JavaScript */,
33499
+ false,
33500
+ void 0
33501
+ );
33543
33502
  }
33544
- function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
33503
+ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, isConfigLookup) {
33545
33504
  let extensions;
33546
- if (lookupConfig) {
33547
- extensions = tsconfigExtensions;
33505
+ if (isConfigLookup) {
33506
+ extensions = 8 /* Json */;
33548
33507
  } else if (compilerOptions.noDtsResolution) {
33549
- extensions = [5 /* TsOnly */];
33550
- if (compilerOptions.allowJs)
33551
- extensions.push(1 /* JavaScript */);
33508
+ extensions = 3 /* ImplementationFiles */;
33552
33509
  if (compilerOptions.resolveJsonModule)
33553
- extensions.push(2 /* Json */);
33510
+ extensions |= 8 /* Json */;
33554
33511
  } else {
33555
- extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions;
33512
+ extensions = compilerOptions.resolveJsonModule ? 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */ | 8 /* Json */ : 1 /* TypeScript */ | 2 /* JavaScript */ | 4 /* Declaration */;
33556
33513
  }
33557
- return nodeModuleNameResolverWorker(0 /* None */, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference);
33514
+ return nodeModuleNameResolverWorker(0 /* None */, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, !!isConfigLookup, redirectedReference);
33558
33515
  }
33559
- function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
33516
+ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, isConfigLookup, redirectedReference) {
33560
33517
  var _a2, _b;
33561
33518
  const traceEnabled = isTraceEnabled(compilerOptions, host);
33562
33519
  const failedLookupLocations = [];
@@ -33576,12 +33533,20 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
33576
33533
  features,
33577
33534
  conditions,
33578
33535
  requestContainingDirectory: containingDirectory,
33579
- reportDiagnostic: (diag2) => void diagnostics.push(diag2)
33536
+ reportDiagnostic: (diag2) => void diagnostics.push(diag2),
33537
+ isConfigLookup
33580
33538
  };
33581
33539
  if (traceEnabled && getEmitModuleResolutionKind(compilerOptions) >= 3 /* Node16 */ && getEmitModuleResolutionKind(compilerOptions) <= 99 /* NodeNext */) {
33582
33540
  trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & 32 /* EsmMode */ ? "ESM" : "CJS", conditions.map((c) => `'${c}'`).join(", "));
33583
33541
  }
33584
- const result = forEach(extensions, (ext) => tryResolve(ext));
33542
+ let result;
33543
+ if (getEmitModuleResolutionKind(compilerOptions) === 2 /* NodeJs */) {
33544
+ const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
33545
+ const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
33546
+ result = priorityExtensions && tryResolve(priorityExtensions) || secondaryExtensions && tryResolve(secondaryExtensions) || void 0;
33547
+ } else {
33548
+ result = tryResolve(extensions);
33549
+ }
33585
33550
  return createResolvedModuleWithFailedLookupLocations(
33586
33551
  (_a2 = result == null ? void 0 : result.value) == null ? void 0 : _a2.resolved,
33587
33552
  (_b = result == null ? void 0 : result.value) == null ? void 0 : _b.isExternalLibraryImport,
@@ -33606,7 +33571,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
33606
33571
  }
33607
33572
  if (!resolved2) {
33608
33573
  if (traceEnabled) {
33609
- trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions2]);
33574
+ trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
33610
33575
  }
33611
33576
  resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state, cache, redirectedReference);
33612
33577
  }
@@ -33647,7 +33612,7 @@ function realPath(path, host, traceEnabled) {
33647
33612
  }
33648
33613
  function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
33649
33614
  if (state.traceEnabled) {
33650
- trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
33615
+ trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_types_Colon_1, candidate, formatExtensions(extensions));
33651
33616
  }
33652
33617
  if (!hasTrailingDirectorySeparator(candidate)) {
33653
33618
  if (!onlyRecordFailures) {
@@ -33705,10 +33670,9 @@ function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures
33705
33670
  return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
33706
33671
  }
33707
33672
  function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
33708
- if (extensions === 2 /* Json */ || extensions === 3 /* TSConfig */) {
33709
- const extensionLess = tryRemoveExtension(candidate, ".json" /* Json */);
33710
- const extension = extensionLess ? candidate.substring(extensionLess.length) : "";
33711
- return extensionLess === void 0 && extensions === 2 /* Json */ ? void 0 : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
33673
+ const resolvedByReplacingExtension = loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
33674
+ if (resolvedByReplacingExtension) {
33675
+ return resolvedByReplacingExtension;
33712
33676
  }
33713
33677
  if (!(state.features & 32 /* EsmMode */)) {
33714
33678
  const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
@@ -33716,10 +33680,9 @@ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
33716
33680
  return resolvedByAddingExtension;
33717
33681
  }
33718
33682
  }
33719
- return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
33720
33683
  }
33721
33684
  function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
33722
- if (hasJSFileExtension(candidate) || fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule) {
33685
+ if (hasJSFileExtension(candidate) || extensions & 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */)) {
33723
33686
  const extensionless = removeFileExtension(candidate);
33724
33687
  const extension = candidate.substring(extensionless.length);
33725
33688
  if (state.traceEnabled) {
@@ -33729,7 +33692,7 @@ function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecor
33729
33692
  }
33730
33693
  }
33731
33694
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
33732
- if ((extensions === 0 /* TypeScript */ || extensions === 4 /* DtsOnly */) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) {
33695
+ if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
33733
33696
  const result = tryFile(candidate, onlyRecordFailures, state);
33734
33697
  return result !== void 0 ? { path: candidate, ext: tryExtractTSExtension(candidate) } : void 0;
33735
33698
  }
@@ -33742,59 +33705,32 @@ function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecor
33742
33705
  onlyRecordFailures = !directoryProbablyExists(directory, state.host);
33743
33706
  }
33744
33707
  }
33745
- switch (extensions) {
33746
- case 4 /* DtsOnly */:
33747
- switch (originalExtension) {
33748
- case ".mjs" /* Mjs */:
33749
- case ".mts" /* Mts */:
33750
- case ".d.mts" /* Dmts */:
33751
- return tryExtension(".d.mts" /* Dmts */);
33752
- case ".cjs" /* Cjs */:
33753
- case ".cts" /* Cts */:
33754
- case ".d.cts" /* Dcts */:
33755
- return tryExtension(".d.cts" /* Dcts */);
33756
- case ".json" /* Json */:
33757
- candidate += ".json" /* Json */;
33758
- return tryExtension(".d.ts" /* Dts */);
33759
- default:
33760
- return tryExtension(".d.ts" /* Dts */);
33761
- }
33762
- case 0 /* TypeScript */:
33763
- case 5 /* TsOnly */:
33764
- const useDts = extensions === 0 /* TypeScript */;
33765
- switch (originalExtension) {
33766
- case ".mjs" /* Mjs */:
33767
- case ".mts" /* Mts */:
33768
- case ".d.mts" /* Dmts */:
33769
- return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : void 0);
33770
- case ".cjs" /* Cjs */:
33771
- case ".cts" /* Cts */:
33772
- case ".d.cts" /* Dcts */:
33773
- return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : void 0);
33774
- case ".json" /* Json */:
33775
- candidate += ".json" /* Json */;
33776
- return useDts ? tryExtension(".d.ts" /* Dts */) : void 0;
33777
- default:
33778
- return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : void 0);
33779
- }
33780
- case 1 /* JavaScript */:
33781
- switch (originalExtension) {
33782
- case ".mjs" /* Mjs */:
33783
- case ".mts" /* Mts */:
33784
- case ".d.mts" /* Dmts */:
33785
- return tryExtension(".mjs" /* Mjs */);
33786
- case ".cjs" /* Cjs */:
33787
- case ".cts" /* Cts */:
33788
- case ".d.cts" /* Dcts */:
33789
- return tryExtension(".cjs" /* Cjs */);
33790
- case ".json" /* Json */:
33791
- return tryExtension(".json" /* Json */);
33792
- default:
33793
- return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
33708
+ switch (originalExtension) {
33709
+ case ".mjs" /* Mjs */:
33710
+ case ".mts" /* Mts */:
33711
+ case ".d.mts" /* Dmts */:
33712
+ return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
33713
+ case ".cjs" /* Cjs */:
33714
+ case ".cts" /* Cts */:
33715
+ case ".d.cts" /* Dcts */:
33716
+ return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
33717
+ case ".json" /* Json */:
33718
+ const originalCandidate = candidate;
33719
+ if (extensions & 4 /* Declaration */) {
33720
+ candidate += ".json" /* Json */;
33721
+ const result = tryExtension(".d.ts" /* Dts */);
33722
+ if (result)
33723
+ return result;
33724
+ }
33725
+ if (extensions & 8 /* Json */) {
33726
+ candidate = originalCandidate;
33727
+ const result = tryExtension(".json" /* Json */);
33728
+ if (result)
33729
+ return result;
33794
33730
  }
33795
- case 3 /* TSConfig */:
33796
- case 2 /* Json */:
33797
- return tryExtension(".json" /* Json */);
33731
+ return void 0;
33732
+ default:
33733
+ return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
33798
33734
  }
33799
33735
  function tryExtension(ext) {
33800
33736
  const path = tryFile(candidate + ext, onlyRecordFailures, state);
@@ -33843,7 +33779,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
33843
33779
  features: 0 /* None */,
33844
33780
  conditions: emptyArray,
33845
33781
  requestContainingDirectory: void 0,
33846
- reportDiagnostic: noop
33782
+ reportDiagnostic: noop,
33783
+ isConfigLookup: false
33847
33784
  };
33848
33785
  }
33849
33786
  function getPackageScopeForPath(fileName, state) {
@@ -33902,23 +33839,10 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
33902
33839
  function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
33903
33840
  let packageFile;
33904
33841
  if (jsonContent) {
33905
- switch (extensions) {
33906
- case 1 /* JavaScript */:
33907
- case 2 /* Json */:
33908
- case 5 /* TsOnly */:
33909
- packageFile = readPackageJsonMainField(jsonContent, candidate, state);
33910
- break;
33911
- case 0 /* TypeScript */:
33912
- packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
33913
- break;
33914
- case 4 /* DtsOnly */:
33915
- packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
33916
- break;
33917
- case 3 /* TSConfig */:
33918
- packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
33919
- break;
33920
- default:
33921
- return Debug.assertNever(extensions);
33842
+ if (state.isConfigLookup) {
33843
+ packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
33844
+ } else {
33845
+ packageFile = extensions & 4 /* Declaration */ && readPackageJsonTypesFields(jsonContent, candidate, state) || extensions & (3 /* ImplementationFiles */ | 4 /* Declaration */) && readPackageJsonMainField(jsonContent, candidate, state) || void 0;
33922
33846
  }
33923
33847
  }
33924
33848
  const loader = (extensions2, candidate2, onlyRecordFailures2, state2) => {
@@ -33932,18 +33856,18 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
33932
33856
  trace(state2.host, Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
33933
33857
  }
33934
33858
  }
33935
- const nextExtensions = extensions2 === 4 /* DtsOnly */ ? 0 /* TypeScript */ : extensions2;
33859
+ const expandedExtensions = extensions2 === 4 /* Declaration */ ? 1 /* TypeScript */ | 4 /* Declaration */ : extensions2;
33936
33860
  const features = state2.features;
33937
33861
  if ((jsonContent == null ? void 0 : jsonContent.type) !== "module") {
33938
33862
  state2.features &= ~32 /* EsmMode */;
33939
33863
  }
33940
- const result = nodeLoadModuleByRelativeName(nextExtensions, candidate2, onlyRecordFailures2, state2, false);
33864
+ const result = nodeLoadModuleByRelativeName(expandedExtensions, candidate2, onlyRecordFailures2, state2, false);
33941
33865
  state2.features = features;
33942
33866
  return result;
33943
33867
  };
33944
33868
  const onlyRecordFailuresForPackageFile = packageFile ? !directoryProbablyExists(getDirectoryPath(packageFile), state.host) : void 0;
33945
33869
  const onlyRecordFailuresForIndex = onlyRecordFailures || !directoryProbablyExists(candidate, state.host);
33946
- const indexPath = combinePaths(candidate, extensions === 3 /* TSConfig */ ? "tsconfig" : "index");
33870
+ const indexPath = combinePaths(candidate, state.isConfigLookup ? "tsconfig" : "index");
33947
33871
  if (versionPaths && (!packageFile || containsPath(candidate, packageFile))) {
33948
33872
  const moduleName = getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
33949
33873
  if (state.traceEnabled) {
@@ -33966,19 +33890,7 @@ function resolvedIfExtensionMatches(extensions, path) {
33966
33890
  return ext !== void 0 && extensionIsOk(extensions, ext) ? { path, ext } : void 0;
33967
33891
  }
33968
33892
  function extensionIsOk(extensions, extension) {
33969
- switch (extensions) {
33970
- case 1 /* JavaScript */:
33971
- return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */;
33972
- case 3 /* TSConfig */:
33973
- case 2 /* Json */:
33974
- return extension === ".json" /* Json */;
33975
- case 0 /* TypeScript */:
33976
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
33977
- case 5 /* TsOnly */:
33978
- return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */;
33979
- case 4 /* DtsOnly */:
33980
- return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */;
33981
- }
33893
+ return extensions & 2 /* JavaScript */ && (extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */) || extensions & 1 /* TypeScript */ && (extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */) || extensions & 4 /* Declaration */ && (extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */) || extensions & 8 /* Json */ && extension === ".json" /* Json */ || false;
33982
33894
  }
33983
33895
  function parsePackageName(moduleName) {
33984
33896
  let idx = moduleName.indexOf(directorySeparator);
@@ -34140,7 +34052,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
34140
34052
  const combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
34141
34053
  traceIfEnabled(state, Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
34142
34054
  traceIfEnabled(state, Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
34143
- const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
34055
+ const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, extensions, false, redirectedReference);
34144
34056
  return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : void 0);
34145
34057
  }
34146
34058
  if (state.traceEnabled) {
@@ -34231,7 +34143,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
34231
34143
  }
34232
34144
  function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports2) {
34233
34145
  var _a2, _b, _c, _d;
34234
- if ((extensions === 0 /* TypeScript */ || extensions === 1 /* JavaScript */ || extensions === 2 /* Json */) && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) && finalPath.indexOf("/node_modules/") === -1 && (state.compilerOptions.configFile ? containsPath(scope.packageDirectory, toAbsolutePath(state.compilerOptions.configFile.fileName), !useCaseSensitiveFileNames()) : true)) {
34146
+ if (!state.isConfigLookup && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) && finalPath.indexOf("/node_modules/") === -1 && (state.compilerOptions.configFile ? containsPath(scope.packageDirectory, toAbsolutePath(state.compilerOptions.configFile.fileName), !useCaseSensitiveFileNames()) : true)) {
34235
34147
  const getCanonicalFileName = hostGetCanonicalFileName({ useCaseSensitiveFileNames });
34236
34148
  const commonSourceDirGuesses = [];
34237
34149
  if (state.compilerOptions.rootDir || state.compilerOptions.composite && state.compilerOptions.configFilePath) {
@@ -34268,10 +34180,9 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
34268
34180
  if (fileExtensionIs(possibleInputBase, ext)) {
34269
34181
  const inputExts = getPossibleOriginalInputExtensionForExtension(possibleInputBase);
34270
34182
  for (const possibleExt of inputExts) {
34271
- const possibleInputWithInputExtension = changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
34272
- if (extensions === 0 /* TypeScript */ && hasJSFileExtension(possibleInputWithInputExtension) || extensions === 1 /* JavaScript */ && hasTSFileExtension(possibleInputWithInputExtension)) {
34183
+ if (!extensionIsOk(extensions, possibleExt))
34273
34184
  continue;
34274
- }
34185
+ const possibleInputWithInputExtension = changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
34275
34186
  if (state.host.fileExists(possibleInputWithInputExtension)) {
34276
34187
  return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, false, state)));
34277
34188
  }
@@ -34312,19 +34223,31 @@ function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, direc
34312
34223
  return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
34313
34224
  }
34314
34225
  function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
34315
- return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* DtsOnly */, moduleName, directory, state, true, void 0, void 0);
34226
+ return loadModuleFromNearestNodeModulesDirectoryWorker(4 /* Declaration */, moduleName, directory, state, true, void 0, void 0);
34316
34227
  }
34317
34228
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
34318
34229
  const perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */, redirectedReference);
34319
- return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
34320
- if (getBaseFileName(ancestorDirectory) !== "node_modules") {
34321
- const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
34322
- if (resolutionFromCache) {
34323
- return resolutionFromCache;
34230
+ const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
34231
+ const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
34232
+ if (priorityExtensions) {
34233
+ const result = lookup(priorityExtensions);
34234
+ if (result)
34235
+ return result;
34236
+ }
34237
+ if (secondaryExtensions && !typesScopeOnly) {
34238
+ return lookup(secondaryExtensions);
34239
+ }
34240
+ function lookup(extensions2) {
34241
+ return forEachAncestorDirectory(normalizeSlashes(directory), (ancestorDirectory) => {
34242
+ if (getBaseFileName(ancestorDirectory) !== "node_modules") {
34243
+ const resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
34244
+ if (resolutionFromCache) {
34245
+ return resolutionFromCache;
34246
+ }
34247
+ return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions2, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
34324
34248
  }
34325
- return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
34326
- }
34327
- });
34249
+ });
34250
+ }
34328
34251
  }
34329
34252
  function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
34330
34253
  const nodeModulesFolder = combinePaths(directory, "node_modules");
@@ -34332,11 +34255,13 @@ function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, dir
34332
34255
  if (!nodeModulesFolderExists && state.traceEnabled) {
34333
34256
  trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
34334
34257
  }
34335
- const packageResult = typesScopeOnly ? void 0 : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
34336
- if (packageResult) {
34337
- return packageResult;
34258
+ if (!typesScopeOnly) {
34259
+ const packageResult = loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
34260
+ if (packageResult) {
34261
+ return packageResult;
34262
+ }
34338
34263
  }
34339
- if (extensions === 0 /* TypeScript */ || extensions === 4 /* DtsOnly */) {
34264
+ if (extensions & 4 /* Declaration */) {
34340
34265
  const nodeModulesAtTypes2 = combinePaths(nodeModulesFolder, "@types");
34341
34266
  let nodeModulesAtTypesExists = nodeModulesFolderExists;
34342
34267
  if (nodeModulesFolderExists && !directoryProbablyExists(nodeModulesAtTypes2, state.host)) {
@@ -34345,7 +34270,7 @@ function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, dir
34345
34270
  }
34346
34271
  nodeModulesAtTypesExists = false;
34347
34272
  }
34348
- return loadModuleFromSpecificNodeModulesDirectory(4 /* DtsOnly */, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes2, nodeModulesAtTypesExists, state, cache, redirectedReference);
34273
+ return loadModuleFromSpecificNodeModulesDirectory(4 /* Declaration */, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes2, nodeModulesAtTypesExists, state, cache, redirectedReference);
34349
34274
  }
34350
34275
  }
34351
34276
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
@@ -34486,9 +34411,10 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
34486
34411
  features: 0 /* None */,
34487
34412
  conditions: [],
34488
34413
  requestContainingDirectory: containingDirectory,
34489
- reportDiagnostic: (diag2) => void diagnostics.push(diag2)
34414
+ reportDiagnostic: (diag2) => void diagnostics.push(diag2),
34415
+ isConfigLookup: false
34490
34416
  };
34491
- const resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */);
34417
+ const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
34492
34418
  return createResolvedModuleWithFailedLookupLocations(
34493
34419
  resolved && resolved.value,
34494
34420
  false,
@@ -34515,7 +34441,7 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
34515
34441
  if (resolved2) {
34516
34442
  return resolved2;
34517
34443
  }
34518
- if (extensions === 0 /* TypeScript */) {
34444
+ if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
34519
34445
  return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
34520
34446
  }
34521
34447
  } else {
@@ -34542,9 +34468,10 @@ function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, hos
34542
34468
  features: 0 /* None */,
34543
34469
  conditions: [],
34544
34470
  requestContainingDirectory: void 0,
34545
- reportDiagnostic: (diag2) => void diagnostics.push(diag2)
34471
+ reportDiagnostic: (diag2) => void diagnostics.push(diag2),
34472
+ isConfigLookup: false
34546
34473
  };
34547
- const resolved = loadModuleFromImmediateNodeModulesDirectory(4 /* DtsOnly */, moduleName, globalCache, state, false, void 0, void 0);
34474
+ const resolved = loadModuleFromImmediateNodeModulesDirectory(4 /* Declaration */, moduleName, globalCache, state, false, void 0, void 0);
34548
34475
  return createResolvedModuleWithFailedLookupLocations(
34549
34476
  resolved,
34550
34477
  true,
@@ -37494,6 +37421,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
37494
37421
  const importedFileIsInNodeModules = some(modulePaths, (p) => p.isInNodeModules);
37495
37422
  let nodeModulesSpecifiers;
37496
37423
  let pathsSpecifiers;
37424
+ let redirectPathsSpecifiers;
37497
37425
  let relativeSpecifiers;
37498
37426
  for (const modulePath of modulePaths) {
37499
37427
  const specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, void 0, options.overrideImportMode);
@@ -37501,60 +37429,77 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
37501
37429
  if (specifier && modulePath.isRedirect) {
37502
37430
  return nodeModulesSpecifiers;
37503
37431
  }
37504
- if (!specifier && !modulePath.isRedirect) {
37505
- const local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
37506
- if (pathIsBareSpecifier(local)) {
37432
+ if (!specifier) {
37433
+ const local = getLocalModuleSpecifier(
37434
+ modulePath.path,
37435
+ info,
37436
+ compilerOptions,
37437
+ host,
37438
+ options.overrideImportMode || importingSourceFile.impliedNodeFormat,
37439
+ preferences,
37440
+ modulePath.isRedirect
37441
+ );
37442
+ if (!local) {
37443
+ continue;
37444
+ }
37445
+ if (modulePath.isRedirect) {
37446
+ redirectPathsSpecifiers = append(redirectPathsSpecifiers, local);
37447
+ } else if (pathIsBareSpecifier(local)) {
37507
37448
  pathsSpecifiers = append(pathsSpecifiers, local);
37508
37449
  } else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) {
37509
37450
  relativeSpecifiers = append(relativeSpecifiers, local);
37510
37451
  }
37511
37452
  }
37512
37453
  }
37513
- return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : Debug.checkDefined(relativeSpecifiers);
37454
+ return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? redirectPathsSpecifiers : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : Debug.checkDefined(relativeSpecifiers);
37514
37455
  }
37515
37456
  function getInfo(importingSourceFileName, host) {
37516
37457
  const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
37517
37458
  const sourceDirectory = getDirectoryPath(importingSourceFileName);
37518
37459
  return { getCanonicalFileName, importingSourceFileName, sourceDirectory };
37519
37460
  }
37520
- function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { ending, relativePreference }) {
37461
+ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, { ending, relativePreference }, pathsOnly) {
37521
37462
  const { baseUrl, paths, rootDirs } = compilerOptions;
37463
+ if (pathsOnly && !paths) {
37464
+ return void 0;
37465
+ }
37522
37466
  const { sourceDirectory, getCanonicalFileName } = info;
37523
37467
  const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
37524
37468
  if (!baseUrl && !paths || relativePreference === 0 /* Relative */) {
37525
- return relativePath;
37469
+ return pathsOnly ? void 0 : relativePath;
37526
37470
  }
37527
37471
  const baseDirectory = getNormalizedAbsolutePath(getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory());
37528
37472
  const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
37529
37473
  if (!relativeToBaseUrl) {
37530
- return relativePath;
37474
+ return pathsOnly ? void 0 : relativePath;
37531
37475
  }
37532
37476
  const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
37533
- const nonRelative = fromPaths === void 0 && baseUrl !== void 0 ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
37534
- if (!nonRelative) {
37477
+ if (pathsOnly) {
37478
+ return fromPaths;
37479
+ }
37480
+ const maybeNonRelative = fromPaths === void 0 && baseUrl !== void 0 ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
37481
+ if (!maybeNonRelative) {
37535
37482
  return relativePath;
37536
37483
  }
37537
- if (relativePreference === 1 /* NonRelative */) {
37538
- return nonRelative;
37484
+ if (relativePreference === 1 /* NonRelative */ && !pathIsRelative(maybeNonRelative)) {
37485
+ return maybeNonRelative;
37539
37486
  }
37540
- if (relativePreference === 3 /* ExternalNonRelative */) {
37487
+ if (relativePreference === 3 /* ExternalNonRelative */ && !pathIsRelative(maybeNonRelative)) {
37541
37488
  const projectDirectory = compilerOptions.configFilePath ? toPath(getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory());
37542
37489
  const modulePath = toPath(moduleFileName, projectDirectory, getCanonicalFileName);
37543
37490
  const sourceIsInternal = startsWith(sourceDirectory, projectDirectory);
37544
37491
  const targetIsInternal = startsWith(modulePath, projectDirectory);
37545
37492
  if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
37546
- return nonRelative;
37493
+ return maybeNonRelative;
37547
37494
  }
37548
37495
  const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
37549
37496
  const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
37550
37497
  if (nearestSourcePackageJson !== nearestTargetPackageJson) {
37551
- return nonRelative;
37498
+ return maybeNonRelative;
37552
37499
  }
37553
37500
  return relativePath;
37554
37501
  }
37555
- if (relativePreference !== 2 /* Shortest */)
37556
- Debug.assertNever(relativePreference);
37557
- return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
37502
+ return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
37558
37503
  }
37559
37504
  function countPathComponents(path) {
37560
37505
  let count = 0;
@@ -74189,10 +74134,10 @@ var visitEachChildTable = {
74189
74134
  nodeVisitor(node.initializer, visitor, isExpression)
74190
74135
  );
74191
74136
  },
74192
- [308 /* SourceFile */]: function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) {
74137
+ [308 /* SourceFile */]: function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) {
74193
74138
  return context.factory.updateSourceFile(
74194
74139
  node,
74195
- visitLexicalEnvironment(node.statements, visitor, context, void 0, void 0, nodesVisitor)
74140
+ visitLexicalEnvironment(node.statements, visitor, context)
74196
74141
  );
74197
74142
  },
74198
74143
  [353 /* PartiallyEmittedExpression */]: function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
@@ -92160,7 +92105,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
92160
92105
  const sourceMap = sourceMapGenerator.toString();
92161
92106
  writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
92162
92107
  if (printer.bundleFileInfo)
92163
- printer.bundleFileInfo.mapHash = computeSignature(sourceMap, maybeBind(host, host.createHash));
92108
+ printer.bundleFileInfo.mapHash = computeSignature(sourceMap, host);
92164
92109
  }
92165
92110
  } else {
92166
92111
  writer.writeLine();
@@ -92168,7 +92113,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
92168
92113
  const text = writer.getText();
92169
92114
  writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
92170
92115
  if (printer.bundleFileInfo)
92171
- printer.bundleFileInfo.hash = computeSignature(text, maybeBind(host, host.createHash));
92116
+ printer.bundleFileInfo.hash = computeSignature(text, host);
92172
92117
  writer.clear();
92173
92118
  }
92174
92119
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92314,7 +92259,6 @@ function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
92314
92259
  return result;
92315
92260
  }
92316
92261
  function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransformers) {
92317
- const createHash = maybeBind(host, host.createHash);
92318
92262
  const { buildInfoPath, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(config.options, false);
92319
92263
  const buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
92320
92264
  if (!buildInfo)
@@ -92324,22 +92268,22 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92324
92268
  const jsFileText = host.readFile(Debug.checkDefined(jsFilePath));
92325
92269
  if (!jsFileText)
92326
92270
  return jsFilePath;
92327
- if (computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92271
+ if (computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
92328
92272
  return jsFilePath;
92329
92273
  const sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92330
92274
  if (sourceMapFilePath && !sourceMapText || config.options.inlineSourceMap)
92331
92275
  return sourceMapFilePath || "inline sourcemap decoding";
92332
- if (sourceMapFilePath && computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92276
+ if (sourceMapFilePath && computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
92333
92277
  return sourceMapFilePath;
92334
92278
  const declarationText = declarationFilePath && host.readFile(declarationFilePath);
92335
92279
  if (declarationFilePath && !declarationText)
92336
92280
  return declarationFilePath;
92337
- if (declarationFilePath && computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92281
+ if (declarationFilePath && computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
92338
92282
  return declarationFilePath;
92339
92283
  const declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92340
92284
  if (declarationMapPath && !declarationMapText || config.options.inlineSourceMap)
92341
92285
  return declarationMapPath || "inline sourcemap decoding";
92342
- if (declarationMapPath && computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92286
+ if (declarationMapPath && computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
92343
92287
  return declarationMapPath;
92344
92288
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92345
92289
  const ownPrependInput = createInputFilesWithFileTexts(
@@ -92409,7 +92353,7 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92409
92353
  getBuildInfo: (bundle) => {
92410
92354
  const program = buildInfo.program;
92411
92355
  if (program && changedDtsText !== void 0 && config.options.composite) {
92412
- program.outSignature = computeSignature(changedDtsText, createHash, changedDtsData);
92356
+ program.outSignature = computeSignature(changedDtsText, host, changedDtsData);
92413
92357
  }
92414
92358
  const { js, dts, sourceFiles } = buildInfo.bundle;
92415
92359
  bundle.js.sources = js.sources;
@@ -92422,7 +92366,7 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92422
92366
  getSourceFileFromReference: returnUndefined,
92423
92367
  redirectTargetsMap: createMultiMap(),
92424
92368
  getFileIncludeReasons: notImplemented,
92425
- createHash
92369
+ createHash: maybeBind(host, host.createHash)
92426
92370
  };
92427
92371
  emitFiles(
92428
92372
  notImplementedResolver,
@@ -100479,7 +100423,7 @@ var BuilderState;
100479
100423
  return oldState && !oldState.referencedMap === !newReferencedMap;
100480
100424
  }
100481
100425
  BuilderState2.canReuseOldState = canReuseOldState;
100482
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100426
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100483
100427
  var _a2, _b, _c;
100484
100428
  const fileInfos = /* @__PURE__ */ new Map();
100485
100429
  const options = newProgram.getCompilerOptions();
@@ -100487,6 +100431,7 @@ var BuilderState;
100487
100431
  const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
100488
100432
  const exportedModulesMap = referencedMap ? createManyToManyPathMap() : void 0;
100489
100433
  const useOldState = canReuseOldState(referencedMap, oldState);
100434
+ const getCanonicalFileName = createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100490
100435
  newProgram.getTypeChecker();
100491
100436
  for (const sourceFile of newProgram.getSourceFiles()) {
100492
100437
  const version2 = Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
@@ -100525,30 +100470,29 @@ var BuilderState;
100525
100470
  state.allFileNames = void 0;
100526
100471
  }
100527
100472
  BuilderState2.releaseCache = releaseCache2;
100528
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100473
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100529
100474
  var _a2, _b;
100530
100475
  const result = getFilesAffectedByWithOldState(
100531
100476
  state,
100532
100477
  programOfThisState,
100533
100478
  path,
100534
100479
  cancellationToken,
100535
- computeHash,
100536
- getCanonicalFileName
100480
+ host
100537
100481
  );
100538
100482
  (_a2 = state.oldSignatures) == null ? void 0 : _a2.clear();
100539
100483
  (_b = state.oldExportedModulesMap) == null ? void 0 : _b.clear();
100540
100484
  return result;
100541
100485
  }
100542
100486
  BuilderState2.getFilesAffectedBy = getFilesAffectedBy;
100543
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100487
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100544
100488
  const sourceFile = programOfThisState.getSourceFileByPath(path);
100545
100489
  if (!sourceFile) {
100546
100490
  return emptyArray;
100547
100491
  }
100548
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100492
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100549
100493
  return [sourceFile];
100550
100494
  }
100551
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100495
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100552
100496
  }
100553
100497
  BuilderState2.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100554
100498
  function updateSignatureOfFile(state, signature, path) {
@@ -100556,7 +100500,7 @@ var BuilderState;
100556
100500
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
100557
100501
  }
100558
100502
  BuilderState2.updateSignatureOfFile = updateSignatureOfFile;
100559
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature = state.useFileVersionAsSignature) {
100503
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
100560
100504
  var _a2;
100561
100505
  if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
100562
100506
  return false;
@@ -100569,10 +100513,10 @@ var BuilderState;
100569
100513
  (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
100570
100514
  Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
100571
100515
  latestSignature = computeSignatureWithDiagnostics(
100516
+ programOfThisState,
100572
100517
  sourceFile,
100573
100518
  text,
100574
- computeHash,
100575
- getCanonicalFileName,
100519
+ host,
100576
100520
  data
100577
100521
  );
100578
100522
  if (latestSignature !== prevSignature) {
@@ -100711,7 +100655,7 @@ var BuilderState;
100711
100655
  }
100712
100656
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100713
100657
  }
100714
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
100658
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100715
100659
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100716
100660
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100717
100661
  }
@@ -100727,7 +100671,7 @@ var BuilderState;
100727
100671
  if (!seenFileNamesMap.has(currentPath)) {
100728
100672
  const currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100729
100673
  seenFileNamesMap.set(currentPath, currentSourceFile);
100730
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100674
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100731
100675
  queue.push(...getReferencedByPaths(state, currentSourceFile.resolvedPath));
100732
100676
  }
100733
100677
  }
@@ -100769,9 +100713,9 @@ function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
100769
100713
  function hasSameKeys(map1, map2) {
100770
100714
  return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
100771
100715
  }
100772
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100716
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100773
100717
  var _a2, _b;
100774
- const state = BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
100718
+ const state = BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100775
100719
  state.program = newProgram;
100776
100720
  const compilerOptions = newProgram.getCompilerOptions();
100777
100721
  state.compilerOptions = compilerOptions;
@@ -100815,7 +100759,7 @@ function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, d
100815
100759
  return;
100816
100760
  const diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100817
100761
  if (diagnostics) {
100818
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
100762
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100819
100763
  if (!state.semanticDiagnosticsFromOldState) {
100820
100764
  state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set();
100821
100765
  }
@@ -100875,10 +100819,11 @@ function addFileToChangeSet(state, path) {
100875
100819
  function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature) {
100876
100820
  return !!options.declarationMap === !!oldOptions.declarationMap ? oldEmitSignature : isString(oldEmitSignature) ? [oldEmitSignature] : oldEmitSignature[0];
100877
100821
  }
100878
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100822
+ function convertToDiagnostics(diagnostics, newProgram) {
100879
100823
  if (!diagnostics.length)
100880
100824
  return emptyArray;
100881
- const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
100825
+ let buildInfoDirectory;
100826
+ let getCanonicalFileName;
100882
100827
  return diagnostics.map((diagnostic) => {
100883
100828
  const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3);
100884
100829
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100890,7 +100835,8 @@ function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100890
100835
  return result;
100891
100836
  });
100892
100837
  function toPath3(path) {
100893
- return toPath(path, buildInfoDirectory, getCanonicalFileName);
100838
+ buildInfoDirectory != null ? buildInfoDirectory : buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
100839
+ return toPath(path, buildInfoDirectory, getCanonicalFileName != null ? getCanonicalFileName : getCanonicalFileName = createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames()));
100894
100840
  }
100895
100841
  }
100896
100842
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
@@ -100932,7 +100878,7 @@ function restoreBuilderProgramEmitState(state, savedEmitState) {
100932
100878
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100933
100879
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100934
100880
  }
100935
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
100881
+ function getNextAffectedFile(state, cancellationToken, host) {
100936
100882
  var _a2, _b;
100937
100883
  while (true) {
100938
100884
  const { affectedFiles } = state;
@@ -100948,8 +100894,6 @@ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonical
100948
100894
  state,
100949
100895
  affectedFile,
100950
100896
  cancellationToken,
100951
- computeHash,
100952
- getCanonicalFileName,
100953
100897
  host
100954
100898
  );
100955
100899
  return affectedFile;
@@ -100977,8 +100921,7 @@ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonical
100977
100921
  program,
100978
100922
  nextKey.value,
100979
100923
  cancellationToken,
100980
- computeHash,
100981
- getCanonicalFileName
100924
+ host
100982
100925
  );
100983
100926
  state.currentChangedFilePath = nextKey.value;
100984
100927
  state.affectedFilesIndex = 0;
@@ -101030,7 +100973,7 @@ function removeDiagnosticsOfLibraryFiles(state) {
101030
100973
  );
101031
100974
  }
101032
100975
  }
101033
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100976
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
101034
100977
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
101035
100978
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
101036
100979
  removeDiagnosticsOfLibraryFiles(state);
@@ -101039,8 +100982,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
101039
100982
  Debug.checkDefined(state.program),
101040
100983
  affectedFile,
101041
100984
  cancellationToken,
101042
- computeHash,
101043
- getCanonicalFileName
100985
+ host
101044
100986
  );
101045
100987
  return;
101046
100988
  }
@@ -101050,12 +100992,10 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
101050
100992
  state,
101051
100993
  affectedFile,
101052
100994
  cancellationToken,
101053
- computeHash,
101054
- getCanonicalFileName,
101055
100995
  host
101056
100996
  );
101057
100997
  }
101058
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
100998
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
101059
100999
  removeSemanticDiagnosticsOf(state, path);
101060
101000
  if (!state.changedFilesSet.has(path)) {
101061
101001
  const program = Debug.checkDefined(state.program);
@@ -101066,8 +101006,7 @@ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCa
101066
101006
  program,
101067
101007
  sourceFile,
101068
101008
  cancellationToken,
101069
- computeHash,
101070
- getCanonicalFileName,
101009
+ host,
101071
101010
  !host.disableUseFileVersionAsSignature
101072
101011
  );
101073
101012
  if (getEmitDeclarations(state.compilerOptions)) {
@@ -101089,7 +101028,7 @@ function isChangedSignature(state, path) {
101089
101028
  const newSignature = Debug.checkDefined(state.fileInfos.get(path)).signature;
101090
101029
  return newSignature !== oldSignature;
101091
101030
  }
101092
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
101031
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
101093
101032
  var _a2;
101094
101033
  if (!((_a2 = state.fileInfos.get(filePath)) == null ? void 0 : _a2.affectsGlobalScope))
101095
101034
  return false;
@@ -101097,14 +101036,12 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, com
101097
101036
  state,
101098
101037
  file.resolvedPath,
101099
101038
  cancellationToken,
101100
- computeHash,
101101
- getCanonicalFileName,
101102
101039
  host
101103
101040
  ));
101104
101041
  removeDiagnosticsOfLibraryFiles(state);
101105
101042
  return true;
101106
101043
  }
101107
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101044
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
101108
101045
  var _a2;
101109
101046
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
101110
101047
  return;
@@ -101118,9 +101055,9 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101118
101055
  const currentPath = queue.pop();
101119
101056
  if (!seenFileNamesMap.has(currentPath)) {
101120
101057
  seenFileNamesMap.set(currentPath, true);
101121
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101058
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
101122
101059
  return;
101123
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101060
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
101124
101061
  if (isChangedSignature(state, currentPath)) {
101125
101062
  const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
101126
101063
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -101130,7 +101067,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101130
101067
  }
101131
101068
  const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
101132
101069
  (_a2 = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a2.forEach((exportedFromPath) => {
101133
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101070
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
101134
101071
  return true;
101135
101072
  const references = state.referencedMap.getKeys(exportedFromPath);
101136
101073
  return references && forEachKey(
@@ -101140,28 +101077,24 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101140
101077
  filePath,
101141
101078
  seenFileAndExportsOfFile,
101142
101079
  cancellationToken,
101143
- computeHash,
101144
- getCanonicalFileName,
101145
101080
  host
101146
101081
  )
101147
101082
  );
101148
101083
  });
101149
101084
  }
101150
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101085
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
101151
101086
  var _a2, _b;
101152
101087
  if (!tryAddToSet(seenFileAndExportsOfFile, filePath))
101153
101088
  return void 0;
101154
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101089
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
101155
101090
  return true;
101156
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101091
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
101157
101092
  (_a2 = state.exportedModulesMap.getKeys(filePath)) == null ? void 0 : _a2.forEach(
101158
101093
  (exportedFromPath) => handleDtsMayChangeOfFileAndExportsOfFile(
101159
101094
  state,
101160
101095
  exportedFromPath,
101161
101096
  seenFileAndExportsOfFile,
101162
101097
  cancellationToken,
101163
- computeHash,
101164
- getCanonicalFileName,
101165
101098
  host
101166
101099
  )
101167
101100
  );
@@ -101170,8 +101103,6 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndEx
101170
101103
  state,
101171
101104
  referencingFilePath,
101172
101105
  cancellationToken,
101173
- computeHash,
101174
- getCanonicalFileName,
101175
101106
  host
101176
101107
  )
101177
101108
  );
@@ -101200,9 +101131,10 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
101200
101131
  function isProgramBundleEmitBuildInfo(info) {
101201
101132
  return !!outFile(info.options || {});
101202
101133
  }
101203
- function getBuildInfo2(state, getCanonicalFileName, bundle) {
101134
+ function getBuildInfo2(state, bundle) {
101204
101135
  var _a2, _b, _c;
101205
101136
  const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
101137
+ const getCanonicalFileName = createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101206
101138
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101207
101139
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
101208
101140
  const fileNames = [];
@@ -101421,8 +101353,9 @@ function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldP
101421
101353
  function getTextHandlingSourceMapForSignature(text, data) {
101422
101354
  return (data == null ? void 0 : data.sourceMapUrlPos) !== void 0 ? text.substring(0, data.sourceMapUrlPos) : text;
101423
101355
  }
101424
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
101425
- var _a2;
101356
+ function computeSignatureWithDiagnostics(program, sourceFile, text, host, data) {
101357
+ var _a2, _b;
101358
+ let getCanonicalFileName;
101426
101359
  text = getTextHandlingSourceMapForSignature(text, data);
101427
101360
  let sourceFileDirectory;
101428
101361
  if ((_a2 = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a2.length) {
@@ -101430,7 +101363,7 @@ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanon
101430
101363
  (diagnostic) => `${locationInfo(diagnostic)}${DiagnosticCategory[diagnostic.category]}${diagnostic.code}: ${flattenDiagnosticMessageText2(diagnostic.messageText)}`
101431
101364
  ).join("\n");
101432
101365
  }
101433
- return (computeHash != null ? computeHash : generateDjb2Hash)(text);
101366
+ return ((_b = host.createHash) != null ? _b : generateDjb2Hash)(text);
101434
101367
  function flattenDiagnosticMessageText2(diagnostic) {
101435
101368
  return isString(diagnostic) ? diagnostic : diagnostic === void 0 ? "" : !diagnostic.next ? diagnostic.messageText : diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText2).join("\n");
101436
101369
  }
@@ -101439,11 +101372,16 @@ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanon
101439
101372
  return `(${diagnostic.start},${diagnostic.length})`;
101440
101373
  if (sourceFileDirectory === void 0)
101441
101374
  sourceFileDirectory = getDirectoryPath(sourceFile.resolvedPath);
101442
- return `${ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName))}(${diagnostic.start},${diagnostic.length})`;
101375
+ return `${ensurePathIsNonModuleName(getRelativePathFromDirectory(
101376
+ sourceFileDirectory,
101377
+ diagnostic.file.resolvedPath,
101378
+ getCanonicalFileName != null ? getCanonicalFileName : getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames())
101379
+ ))}(${diagnostic.start},${diagnostic.length})`;
101443
101380
  }
101444
101381
  }
101445
- function computeSignature(text, computeHash, data) {
101446
- return (computeHash != null ? computeHash : generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101382
+ function computeSignature(text, host, data) {
101383
+ var _a2;
101384
+ return ((_a2 = host.createHash) != null ? _a2 : generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
101447
101385
  }
101448
101386
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
101449
101387
  let oldState = oldProgram && oldProgram.getState();
@@ -101452,10 +101390,8 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101452
101390
  oldState = void 0;
101453
101391
  return oldProgram;
101454
101392
  }
101455
- const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101456
- const computeHash = maybeBind(host, host.createHash);
101457
- const state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101458
- newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, getCanonicalFileName, bundle);
101393
+ const state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101394
+ newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
101459
101395
  newProgram = void 0;
101460
101396
  oldProgram = void 0;
101461
101397
  oldState = void 0;
@@ -101489,7 +101425,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101489
101425
  }
101490
101426
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101491
101427
  var _a2, _b, _c, _d, _e;
101492
- let affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101428
+ let affected = getNextAffectedFile(state, cancellationToken, host);
101493
101429
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
101494
101430
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
101495
101431
  if (!affected) {
@@ -101563,10 +101499,10 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101563
101499
  const info = state.fileInfos.get(file.resolvedPath);
101564
101500
  if (info.signature === file.version) {
101565
101501
  const signature = computeSignatureWithDiagnostics(
101502
+ state.program,
101566
101503
  file,
101567
101504
  text,
101568
- computeHash,
101569
- getCanonicalFileName,
101505
+ host,
101570
101506
  data
101571
101507
  );
101572
101508
  if (!((_a2 = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a2.length))
@@ -101610,7 +101546,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101610
101546
  state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
101611
101547
  function handleNewSignature(oldSignatureFormat, newSignature) {
101612
101548
  const oldSignature = !oldSignatureFormat || isString(oldSignatureFormat) ? oldSignatureFormat : oldSignatureFormat[0];
101613
- newSignature != null ? newSignature : newSignature = computeSignature(text, computeHash, data);
101549
+ newSignature != null ? newSignature : newSignature = computeSignature(text, host, data);
101614
101550
  if (newSignature === oldSignature) {
101615
101551
  if (oldSignatureFormat === oldSignature)
101616
101552
  return void 0;
@@ -101666,7 +101602,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101666
101602
  }
101667
101603
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101668
101604
  while (true) {
101669
- const affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101605
+ const affected = getNextAffectedFile(state, cancellationToken, host);
101670
101606
  let result;
101671
101607
  if (!affected)
101672
101608
  return void 0;