typescript 5.0.0-dev.20221114 → 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.20221114`;
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;
33794
33724
  }
33795
- case 3 /* TSConfig */:
33796
- case 2 /* Json */:
33797
- return tryExtension(".json" /* Json */);
33725
+ if (extensions & 8 /* Json */) {
33726
+ candidate = originalCandidate;
33727
+ const result = tryExtension(".json" /* Json */);
33728
+ if (result)
33729
+ return result;
33730
+ }
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;
@@ -41783,25 +41728,22 @@ function createTypeChecker(host) {
41783
41728
  const context = {
41784
41729
  enclosingDeclaration,
41785
41730
  flags: flags || 0 /* None */,
41786
- tracker: tracker && tracker.trackSymbol ? tracker : {
41787
- trackSymbol: () => false,
41788
- moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? {
41789
- getCommonSourceDirectory: !!host.getCommonSourceDirectory ? () => host.getCommonSourceDirectory() : () => "",
41790
- getCurrentDirectory: () => host.getCurrentDirectory(),
41791
- getSymlinkCache: maybeBind(host, host.getSymlinkCache),
41792
- getPackageJsonInfoCache: () => {
41793
- var _a3;
41794
- return (_a3 = host.getPackageJsonInfoCache) == null ? void 0 : _a3.call(host);
41795
- },
41796
- useCaseSensitiveFileNames: maybeBind(host, host.useCaseSensitiveFileNames),
41797
- redirectTargetsMap: host.redirectTargetsMap,
41798
- getProjectReferenceRedirect: (fileName) => host.getProjectReferenceRedirect(fileName),
41799
- isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
41800
- fileExists: (fileName) => host.fileExists(fileName),
41801
- getFileIncludeReasons: () => host.getFileIncludeReasons(),
41802
- readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
41803
- } : void 0
41804
- },
41731
+ tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: () => false, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? {
41732
+ getCommonSourceDirectory: !!host.getCommonSourceDirectory ? () => host.getCommonSourceDirectory() : () => "",
41733
+ getCurrentDirectory: () => host.getCurrentDirectory(),
41734
+ getSymlinkCache: maybeBind(host, host.getSymlinkCache),
41735
+ getPackageJsonInfoCache: () => {
41736
+ var _a3;
41737
+ return (_a3 = host.getPackageJsonInfoCache) == null ? void 0 : _a3.call(host);
41738
+ },
41739
+ useCaseSensitiveFileNames: maybeBind(host, host.useCaseSensitiveFileNames),
41740
+ redirectTargetsMap: host.redirectTargetsMap,
41741
+ getProjectReferenceRedirect: (fileName) => host.getProjectReferenceRedirect(fileName),
41742
+ isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
41743
+ fileExists: (fileName) => host.fileExists(fileName),
41744
+ getFileIncludeReasons: () => host.getFileIncludeReasons(),
41745
+ readFile: host.readFile ? (fileName) => host.readFile(fileName) : void 0
41746
+ } : void 0 },
41805
41747
  encounteredError: false,
41806
41748
  reportedDiagnostic: false,
41807
41749
  visitedTypes: void 0,
@@ -68177,8 +68119,9 @@ function createTypeChecker(host) {
68177
68119
  });
68178
68120
  const containsArguments = containsArgumentsReference(node);
68179
68121
  if (containsArguments) {
68180
- const lastJSDocParam = lastOrUndefined(jsdocParameters);
68181
- if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression && lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
68122
+ const lastJSDocParamIndex = jsdocParameters.length - 1;
68123
+ const lastJSDocParam = jsdocParameters[lastJSDocParamIndex];
68124
+ if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression && lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !excludedParameters.has(lastJSDocParamIndex) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
68182
68125
  error(lastJSDocParam.name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, idText(lastJSDocParam.name));
68183
68126
  }
68184
68127
  } else {
@@ -74191,10 +74134,10 @@ var visitEachChildTable = {
74191
74134
  nodeVisitor(node.initializer, visitor, isExpression)
74192
74135
  );
74193
74136
  },
74194
- [308 /* SourceFile */]: function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) {
74137
+ [308 /* SourceFile */]: function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) {
74195
74138
  return context.factory.updateSourceFile(
74196
74139
  node,
74197
- visitLexicalEnvironment(node.statements, visitor, context, void 0, void 0, nodesVisitor)
74140
+ visitLexicalEnvironment(node.statements, visitor, context)
74198
74141
  );
74199
74142
  },
74200
74143
  [353 /* PartiallyEmittedExpression */]: function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
@@ -92162,7 +92105,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
92162
92105
  const sourceMap = sourceMapGenerator.toString();
92163
92106
  writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
92164
92107
  if (printer.bundleFileInfo)
92165
- printer.bundleFileInfo.mapHash = computeSignature(sourceMap, maybeBind(host, host.createHash));
92108
+ printer.bundleFileInfo.mapHash = computeSignature(sourceMap, host);
92166
92109
  }
92167
92110
  } else {
92168
92111
  writer.writeLine();
@@ -92170,7 +92113,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
92170
92113
  const text = writer.getText();
92171
92114
  writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos, diagnostics: transform.diagnostics });
92172
92115
  if (printer.bundleFileInfo)
92173
- printer.bundleFileInfo.hash = computeSignature(text, maybeBind(host, host.createHash));
92116
+ printer.bundleFileInfo.hash = computeSignature(text, host);
92174
92117
  writer.clear();
92175
92118
  }
92176
92119
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -92316,7 +92259,6 @@ function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
92316
92259
  return result;
92317
92260
  }
92318
92261
  function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransformers) {
92319
- const createHash = maybeBind(host, host.createHash);
92320
92262
  const { buildInfoPath, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(config.options, false);
92321
92263
  const buildInfo = host.getBuildInfo(buildInfoPath, config.options.configFilePath);
92322
92264
  if (!buildInfo)
@@ -92326,22 +92268,22 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92326
92268
  const jsFileText = host.readFile(Debug.checkDefined(jsFilePath));
92327
92269
  if (!jsFileText)
92328
92270
  return jsFilePath;
92329
- if (computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
92271
+ if (computeSignature(jsFileText, host) !== buildInfo.bundle.js.hash)
92330
92272
  return jsFilePath;
92331
92273
  const sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
92332
92274
  if (sourceMapFilePath && !sourceMapText || config.options.inlineSourceMap)
92333
92275
  return sourceMapFilePath || "inline sourcemap decoding";
92334
- if (sourceMapFilePath && computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
92276
+ if (sourceMapFilePath && computeSignature(sourceMapText, host) !== buildInfo.bundle.js.mapHash)
92335
92277
  return sourceMapFilePath;
92336
92278
  const declarationText = declarationFilePath && host.readFile(declarationFilePath);
92337
92279
  if (declarationFilePath && !declarationText)
92338
92280
  return declarationFilePath;
92339
- if (declarationFilePath && computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
92281
+ if (declarationFilePath && computeSignature(declarationText, host) !== buildInfo.bundle.dts.hash)
92340
92282
  return declarationFilePath;
92341
92283
  const declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
92342
92284
  if (declarationMapPath && !declarationMapText || config.options.inlineSourceMap)
92343
92285
  return declarationMapPath || "inline sourcemap decoding";
92344
- if (declarationMapPath && computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
92286
+ if (declarationMapPath && computeSignature(declarationMapText, host) !== buildInfo.bundle.dts.mapHash)
92345
92287
  return declarationMapPath;
92346
92288
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
92347
92289
  const ownPrependInput = createInputFilesWithFileTexts(
@@ -92411,7 +92353,7 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92411
92353
  getBuildInfo: (bundle) => {
92412
92354
  const program = buildInfo.program;
92413
92355
  if (program && changedDtsText !== void 0 && config.options.composite) {
92414
- program.outSignature = computeSignature(changedDtsText, createHash, changedDtsData);
92356
+ program.outSignature = computeSignature(changedDtsText, host, changedDtsData);
92415
92357
  }
92416
92358
  const { js, dts, sourceFiles } = buildInfo.bundle;
92417
92359
  bundle.js.sources = js.sources;
@@ -92424,7 +92366,7 @@ function emitUsingBuildInfoWorker(config, host, getCommandLine, customTransforme
92424
92366
  getSourceFileFromReference: returnUndefined,
92425
92367
  redirectTargetsMap: createMultiMap(),
92426
92368
  getFileIncludeReasons: notImplemented,
92427
- createHash
92369
+ createHash: maybeBind(host, host.createHash)
92428
92370
  };
92429
92371
  emitFiles(
92430
92372
  notImplementedResolver,
@@ -100481,7 +100423,7 @@ var BuilderState;
100481
100423
  return oldState && !oldState.referencedMap === !newReferencedMap;
100482
100424
  }
100483
100425
  BuilderState2.canReuseOldState = canReuseOldState;
100484
- function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100426
+ function create(newProgram, oldState, disableUseFileVersionAsSignature) {
100485
100427
  var _a2, _b, _c;
100486
100428
  const fileInfos = /* @__PURE__ */ new Map();
100487
100429
  const options = newProgram.getCompilerOptions();
@@ -100489,6 +100431,7 @@ var BuilderState;
100489
100431
  const referencedMap = options.module !== 0 /* None */ && !isOutFile ? createManyToManyPathMap() : void 0;
100490
100432
  const exportedModulesMap = referencedMap ? createManyToManyPathMap() : void 0;
100491
100433
  const useOldState = canReuseOldState(referencedMap, oldState);
100434
+ const getCanonicalFileName = createGetCanonicalFileName(newProgram.useCaseSensitiveFileNames());
100492
100435
  newProgram.getTypeChecker();
100493
100436
  for (const sourceFile of newProgram.getSourceFiles()) {
100494
100437
  const version2 = Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
@@ -100527,30 +100470,29 @@ var BuilderState;
100527
100470
  state.allFileNames = void 0;
100528
100471
  }
100529
100472
  BuilderState2.releaseCache = releaseCache2;
100530
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100473
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, host) {
100531
100474
  var _a2, _b;
100532
100475
  const result = getFilesAffectedByWithOldState(
100533
100476
  state,
100534
100477
  programOfThisState,
100535
100478
  path,
100536
100479
  cancellationToken,
100537
- computeHash,
100538
- getCanonicalFileName
100480
+ host
100539
100481
  );
100540
100482
  (_a2 = state.oldSignatures) == null ? void 0 : _a2.clear();
100541
100483
  (_b = state.oldExportedModulesMap) == null ? void 0 : _b.clear();
100542
100484
  return result;
100543
100485
  }
100544
100486
  BuilderState2.getFilesAffectedBy = getFilesAffectedBy;
100545
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
100487
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, host) {
100546
100488
  const sourceFile = programOfThisState.getSourceFileByPath(path);
100547
100489
  if (!sourceFile) {
100548
100490
  return emptyArray;
100549
100491
  }
100550
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100492
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host)) {
100551
100493
  return [sourceFile];
100552
100494
  }
100553
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
100495
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, host);
100554
100496
  }
100555
100497
  BuilderState2.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
100556
100498
  function updateSignatureOfFile(state, signature, path) {
@@ -100558,7 +100500,7 @@ var BuilderState;
100558
100500
  (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = /* @__PURE__ */ new Set())).add(path);
100559
100501
  }
100560
100502
  BuilderState2.updateSignatureOfFile = updateSignatureOfFile;
100561
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature = state.useFileVersionAsSignature) {
100503
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, host, useFileVersionAsSignature = state.useFileVersionAsSignature) {
100562
100504
  var _a2;
100563
100505
  if ((_a2 = state.hasCalledUpdateShapeSignature) == null ? void 0 : _a2.has(sourceFile.resolvedPath))
100564
100506
  return false;
@@ -100571,10 +100513,10 @@ var BuilderState;
100571
100513
  (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) => {
100572
100514
  Debug.assert(isDeclarationFileName(fileName), `File extension for signature expected to be dts: Got:: ${fileName}`);
100573
100515
  latestSignature = computeSignatureWithDiagnostics(
100516
+ programOfThisState,
100574
100517
  sourceFile,
100575
100518
  text,
100576
- computeHash,
100577
- getCanonicalFileName,
100519
+ host,
100578
100520
  data
100579
100521
  );
100580
100522
  if (latestSignature !== prevSignature) {
@@ -100713,7 +100655,7 @@ var BuilderState;
100713
100655
  }
100714
100656
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100715
100657
  }
100716
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
100658
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, host) {
100717
100659
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
100718
100660
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
100719
100661
  }
@@ -100729,7 +100671,7 @@ var BuilderState;
100729
100671
  if (!seenFileNamesMap.has(currentPath)) {
100730
100672
  const currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
100731
100673
  seenFileNamesMap.set(currentPath, currentSourceFile);
100732
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
100674
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, host)) {
100733
100675
  queue.push(...getReferencedByPaths(state, currentSourceFile.resolvedPath));
100734
100676
  }
100735
100677
  }
@@ -100771,9 +100713,9 @@ function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
100771
100713
  function hasSameKeys(map1, map2) {
100772
100714
  return map1 === map2 || map1 !== void 0 && map2 !== void 0 && map1.size === map2.size && !forEachKey(map1, (key) => !map2.has(key));
100773
100715
  }
100774
- function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) {
100716
+ function createBuilderProgramState(newProgram, oldState, disableUseFileVersionAsSignature) {
100775
100717
  var _a2, _b;
100776
- const state = BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature);
100718
+ const state = BuilderState.create(newProgram, oldState, disableUseFileVersionAsSignature);
100777
100719
  state.program = newProgram;
100778
100720
  const compilerOptions = newProgram.getCompilerOptions();
100779
100721
  state.compilerOptions = compilerOptions;
@@ -100817,7 +100759,7 @@ function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, d
100817
100759
  return;
100818
100760
  const diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
100819
100761
  if (diagnostics) {
100820
- state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
100762
+ state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram) : diagnostics);
100821
100763
  if (!state.semanticDiagnosticsFromOldState) {
100822
100764
  state.semanticDiagnosticsFromOldState = /* @__PURE__ */ new Set();
100823
100765
  }
@@ -100877,10 +100819,11 @@ function addFileToChangeSet(state, path) {
100877
100819
  function getEmitSignatureFromOldSignature(options, oldOptions, oldEmitSignature) {
100878
100820
  return !!options.declarationMap === !!oldOptions.declarationMap ? oldEmitSignature : isString(oldEmitSignature) ? [oldEmitSignature] : oldEmitSignature[0];
100879
100821
  }
100880
- function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100822
+ function convertToDiagnostics(diagnostics, newProgram) {
100881
100823
  if (!diagnostics.length)
100882
100824
  return emptyArray;
100883
- const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
100825
+ let buildInfoDirectory;
100826
+ let getCanonicalFileName;
100884
100827
  return diagnostics.map((diagnostic) => {
100885
100828
  const result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3);
100886
100829
  result.reportsUnnecessary = diagnostic.reportsUnnecessary;
@@ -100892,7 +100835,8 @@ function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
100892
100835
  return result;
100893
100836
  });
100894
100837
  function toPath3(path) {
100895
- 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()));
100896
100840
  }
100897
100841
  }
100898
100842
  function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath3) {
@@ -100934,7 +100878,7 @@ function restoreBuilderProgramEmitState(state, savedEmitState) {
100934
100878
  function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
100935
100879
  Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
100936
100880
  }
100937
- function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
100881
+ function getNextAffectedFile(state, cancellationToken, host) {
100938
100882
  var _a2, _b;
100939
100883
  while (true) {
100940
100884
  const { affectedFiles } = state;
@@ -100950,8 +100894,6 @@ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonical
100950
100894
  state,
100951
100895
  affectedFile,
100952
100896
  cancellationToken,
100953
- computeHash,
100954
- getCanonicalFileName,
100955
100897
  host
100956
100898
  );
100957
100899
  return affectedFile;
@@ -100979,8 +100921,7 @@ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonical
100979
100921
  program,
100980
100922
  nextKey.value,
100981
100923
  cancellationToken,
100982
- computeHash,
100983
- getCanonicalFileName
100924
+ host
100984
100925
  );
100985
100926
  state.currentChangedFilePath = nextKey.value;
100986
100927
  state.affectedFilesIndex = 0;
@@ -101032,7 +100973,7 @@ function removeDiagnosticsOfLibraryFiles(state) {
101032
100973
  );
101033
100974
  }
101034
100975
  }
101035
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
100976
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, host) {
101036
100977
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
101037
100978
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
101038
100979
  removeDiagnosticsOfLibraryFiles(state);
@@ -101041,8 +100982,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
101041
100982
  Debug.checkDefined(state.program),
101042
100983
  affectedFile,
101043
100984
  cancellationToken,
101044
- computeHash,
101045
- getCanonicalFileName
100985
+ host
101046
100986
  );
101047
100987
  return;
101048
100988
  }
@@ -101052,12 +100992,10 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
101052
100992
  state,
101053
100993
  affectedFile,
101054
100994
  cancellationToken,
101055
- computeHash,
101056
- getCanonicalFileName,
101057
100995
  host
101058
100996
  );
101059
100997
  }
101060
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
100998
+ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
101061
100999
  removeSemanticDiagnosticsOf(state, path);
101062
101000
  if (!state.changedFilesSet.has(path)) {
101063
101001
  const program = Debug.checkDefined(state.program);
@@ -101068,8 +101006,7 @@ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCa
101068
101006
  program,
101069
101007
  sourceFile,
101070
101008
  cancellationToken,
101071
- computeHash,
101072
- getCanonicalFileName,
101009
+ host,
101073
101010
  !host.disableUseFileVersionAsSignature
101074
101011
  );
101075
101012
  if (getEmitDeclarations(state.compilerOptions)) {
@@ -101091,7 +101028,7 @@ function isChangedSignature(state, path) {
101091
101028
  const newSignature = Debug.checkDefined(state.fileInfos.get(path)).signature;
101092
101029
  return newSignature !== oldSignature;
101093
101030
  }
101094
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
101031
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
101095
101032
  var _a2;
101096
101033
  if (!((_a2 = state.fileInfos.get(filePath)) == null ? void 0 : _a2.affectsGlobalScope))
101097
101034
  return false;
@@ -101099,14 +101036,12 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, com
101099
101036
  state,
101100
101037
  file.resolvedPath,
101101
101038
  cancellationToken,
101102
- computeHash,
101103
- getCanonicalFileName,
101104
101039
  host
101105
101040
  ));
101106
101041
  removeDiagnosticsOfLibraryFiles(state);
101107
101042
  return true;
101108
101043
  }
101109
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101044
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
101110
101045
  var _a2;
101111
101046
  if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
101112
101047
  return;
@@ -101120,9 +101055,9 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101120
101055
  const currentPath = queue.pop();
101121
101056
  if (!seenFileNamesMap.has(currentPath)) {
101122
101057
  seenFileNamesMap.set(currentPath, true);
101123
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
101058
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, host))
101124
101059
  return;
101125
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
101060
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, host);
101126
101061
  if (isChangedSignature(state, currentPath)) {
101127
101062
  const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
101128
101063
  queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -101132,7 +101067,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101132
101067
  }
101133
101068
  const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
101134
101069
  (_a2 = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _a2.forEach((exportedFromPath) => {
101135
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
101070
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, host))
101136
101071
  return true;
101137
101072
  const references = state.referencedMap.getKeys(exportedFromPath);
101138
101073
  return references && forEachKey(
@@ -101142,28 +101077,24 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
101142
101077
  filePath,
101143
101078
  seenFileAndExportsOfFile,
101144
101079
  cancellationToken,
101145
- computeHash,
101146
- getCanonicalFileName,
101147
101080
  host
101148
101081
  )
101149
101082
  );
101150
101083
  });
101151
101084
  }
101152
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
101085
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
101153
101086
  var _a2, _b;
101154
101087
  if (!tryAddToSet(seenFileAndExportsOfFile, filePath))
101155
101088
  return void 0;
101156
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
101089
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host))
101157
101090
  return true;
101158
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
101091
+ handleDtsMayChangeOf(state, filePath, cancellationToken, host);
101159
101092
  (_a2 = state.exportedModulesMap.getKeys(filePath)) == null ? void 0 : _a2.forEach(
101160
101093
  (exportedFromPath) => handleDtsMayChangeOfFileAndExportsOfFile(
101161
101094
  state,
101162
101095
  exportedFromPath,
101163
101096
  seenFileAndExportsOfFile,
101164
101097
  cancellationToken,
101165
- computeHash,
101166
- getCanonicalFileName,
101167
101098
  host
101168
101099
  )
101169
101100
  );
@@ -101172,8 +101103,6 @@ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndEx
101172
101103
  state,
101173
101104
  referencingFilePath,
101174
101105
  cancellationToken,
101175
- computeHash,
101176
- getCanonicalFileName,
101177
101106
  host
101178
101107
  )
101179
101108
  );
@@ -101202,9 +101131,10 @@ function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationTok
101202
101131
  function isProgramBundleEmitBuildInfo(info) {
101203
101132
  return !!outFile(info.options || {});
101204
101133
  }
101205
- function getBuildInfo2(state, getCanonicalFileName, bundle) {
101134
+ function getBuildInfo2(state, bundle) {
101206
101135
  var _a2, _b, _c;
101207
101136
  const currentDirectory = Debug.checkDefined(state.program).getCurrentDirectory();
101137
+ const getCanonicalFileName = createGetCanonicalFileName(state.program.useCaseSensitiveFileNames());
101208
101138
  const buildInfoDirectory = getDirectoryPath(getNormalizedAbsolutePath(getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
101209
101139
  const latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : void 0;
101210
101140
  const fileNames = [];
@@ -101423,8 +101353,9 @@ function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldP
101423
101353
  function getTextHandlingSourceMapForSignature(text, data) {
101424
101354
  return (data == null ? void 0 : data.sourceMapUrlPos) !== void 0 ? text.substring(0, data.sourceMapUrlPos) : text;
101425
101355
  }
101426
- function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
101427
- var _a2;
101356
+ function computeSignatureWithDiagnostics(program, sourceFile, text, host, data) {
101357
+ var _a2, _b;
101358
+ let getCanonicalFileName;
101428
101359
  text = getTextHandlingSourceMapForSignature(text, data);
101429
101360
  let sourceFileDirectory;
101430
101361
  if ((_a2 = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a2.length) {
@@ -101432,7 +101363,7 @@ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanon
101432
101363
  (diagnostic) => `${locationInfo(diagnostic)}${DiagnosticCategory[diagnostic.category]}${diagnostic.code}: ${flattenDiagnosticMessageText2(diagnostic.messageText)}`
101433
101364
  ).join("\n");
101434
101365
  }
101435
- return (computeHash != null ? computeHash : generateDjb2Hash)(text);
101366
+ return ((_b = host.createHash) != null ? _b : generateDjb2Hash)(text);
101436
101367
  function flattenDiagnosticMessageText2(diagnostic) {
101437
101368
  return isString(diagnostic) ? diagnostic : diagnostic === void 0 ? "" : !diagnostic.next ? diagnostic.messageText : diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText2).join("\n");
101438
101369
  }
@@ -101441,11 +101372,16 @@ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanon
101441
101372
  return `(${diagnostic.start},${diagnostic.length})`;
101442
101373
  if (sourceFileDirectory === void 0)
101443
101374
  sourceFileDirectory = getDirectoryPath(sourceFile.resolvedPath);
101444
- 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})`;
101445
101380
  }
101446
101381
  }
101447
- function computeSignature(text, computeHash, data) {
101448
- 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));
101449
101385
  }
101450
101386
  function createBuilderProgram(kind, { newProgram, host, oldProgram, configFileParsingDiagnostics }) {
101451
101387
  let oldState = oldProgram && oldProgram.getState();
@@ -101454,10 +101390,8 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101454
101390
  oldState = void 0;
101455
101391
  return oldProgram;
101456
101392
  }
101457
- const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
101458
- const computeHash = maybeBind(host, host.createHash);
101459
- const state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature);
101460
- newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, getCanonicalFileName, bundle);
101393
+ const state = createBuilderProgramState(newProgram, oldState, host.disableUseFileVersionAsSignature);
101394
+ newProgram.getBuildInfo = (bundle) => getBuildInfo2(state, bundle);
101461
101395
  newProgram = void 0;
101462
101396
  oldProgram = void 0;
101463
101397
  oldState = void 0;
@@ -101491,7 +101425,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101491
101425
  }
101492
101426
  function emitNextAffectedFile(writeFile2, cancellationToken, emitOnlyDtsFiles, customTransformers) {
101493
101427
  var _a2, _b, _c, _d, _e;
101494
- let affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101428
+ let affected = getNextAffectedFile(state, cancellationToken, host);
101495
101429
  const programEmitKind = getBuilderFileEmit(state.compilerOptions);
101496
101430
  let emitKind = emitOnlyDtsFiles ? programEmitKind & 24 /* AllDts */ : programEmitKind;
101497
101431
  if (!affected) {
@@ -101565,10 +101499,10 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101565
101499
  const info = state.fileInfos.get(file.resolvedPath);
101566
101500
  if (info.signature === file.version) {
101567
101501
  const signature = computeSignatureWithDiagnostics(
101502
+ state.program,
101568
101503
  file,
101569
101504
  text,
101570
- computeHash,
101571
- getCanonicalFileName,
101505
+ host,
101572
101506
  data
101573
101507
  );
101574
101508
  if (!((_a2 = data == null ? void 0 : data.diagnostics) == null ? void 0 : _a2.length))
@@ -101612,7 +101546,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101612
101546
  state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
101613
101547
  function handleNewSignature(oldSignatureFormat, newSignature) {
101614
101548
  const oldSignature = !oldSignatureFormat || isString(oldSignatureFormat) ? oldSignatureFormat : oldSignatureFormat[0];
101615
- newSignature != null ? newSignature : newSignature = computeSignature(text, computeHash, data);
101549
+ newSignature != null ? newSignature : newSignature = computeSignature(text, host, data);
101616
101550
  if (newSignature === oldSignature) {
101617
101551
  if (oldSignatureFormat === oldSignature)
101618
101552
  return void 0;
@@ -101668,7 +101602,7 @@ function createBuilderProgram(kind, { newProgram, host, oldProgram, configFilePa
101668
101602
  }
101669
101603
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
101670
101604
  while (true) {
101671
- const affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
101605
+ const affected = getNextAffectedFile(state, cancellationToken, host);
101672
101606
  let result;
101673
101607
  if (!affected)
101674
101608
  return void 0;