typescript 5.4.0-dev.20240116 → 5.4.0-dev.20240118

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/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.4";
38
- version = `${versionMajorMinor}.0-dev.20240116`;
38
+ version = `${versionMajorMinor}.0-dev.20240118`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -4769,7 +4769,6 @@ ${lanes.join("\n")}
4769
4769
  CharacterCodes2[CharacterCodes2["ideographicSpace"] = 12288] = "ideographicSpace";
4770
4770
  CharacterCodes2[CharacterCodes2["mathematicalSpace"] = 8287] = "mathematicalSpace";
4771
4771
  CharacterCodes2[CharacterCodes2["ogham"] = 5760] = "ogham";
4772
- CharacterCodes2[CharacterCodes2["replacementCharacter"] = 65533] = "replacementCharacter";
4773
4772
  CharacterCodes2[CharacterCodes2["_"] = 95] = "_";
4774
4773
  CharacterCodes2[CharacterCodes2["$"] = 36] = "$";
4775
4774
  CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
@@ -8480,6 +8479,8 @@ ${lanes.join("\n")}
8480
8479
  Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6276, 3 /* Message */, "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276", "Export specifier '{0}' does not exist in package.json scope at path '{1}'."),
8481
8480
  Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update: diag(6277, 3 /* Message */, "Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_i_6277", "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update."),
8482
8481
  There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings: diag(6278, 3 /* Message */, "There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The__6278", `There are types at '{0}', but this result could not be resolved when respecting package.json "exports". The '{1}' library may need to update its package.json or typings.`),
8482
+ Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_need_configuration_update: diag(6279, 3 /* Message */, "Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_ne_6279", "Resolution of non-relative name failed; trying with '--moduleResolution bundler' to see if project may need configuration update."),
8483
+ There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setting_Consider_updating_to_node16_nodenext_or_bundler: diag(6280, 3 /* Message */, "There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setti_6280", "There are types at '{0}', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'."),
8483
8484
  Enable_project_compilation: diag(6302, 3 /* Message */, "Enable_project_compilation_6302", "Enable project compilation"),
8484
8485
  Composite_projects_may_not_disable_declaration_emit: diag(6304, 1 /* Error */, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."),
8485
8486
  Output_file_0_has_not_been_built_from_source_file_1: diag(6305, 1 /* Error */, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."),
@@ -10307,7 +10308,7 @@ ${lanes.join("\n")}
10307
10308
  }
10308
10309
  const ch = codePointAt(text, pos);
10309
10310
  if (pos === 0) {
10310
- if (ch === 65533 /* replacementCharacter */) {
10311
+ if (text.slice(0, 256).includes("\uFFFD")) {
10311
10312
  error2(Diagnostics.File_appears_to_be_binary);
10312
10313
  pos = end;
10313
10314
  return token = 8 /* NonTextFileMarkerTrivia */;
@@ -13084,17 +13085,20 @@ ${lanes.join("\n")}
13084
13085
  return oldRef.path === newRef.path && !oldRef.prepend === !newRef.prepend && !oldRef.circular === !newRef.circular;
13085
13086
  }
13086
13087
  function moduleResolutionIsEqualTo(oldResolution, newResolution) {
13087
- return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.node10Result === newResolution.node10Result;
13088
+ return oldResolution === newResolution || oldResolution.resolvedModule === newResolution.resolvedModule || !!oldResolution.resolvedModule && !!newResolution.resolvedModule && oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId) && oldResolution.alternateResult === newResolution.alternateResult;
13088
13089
  }
13089
13090
  function createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageName) {
13090
13091
  var _a;
13091
- const node10Result = (_a = host.getResolvedModule(sourceFile, moduleReference, mode)) == null ? void 0 : _a.node10Result;
13092
- const result = node10Result ? chainDiagnosticMessages(
13092
+ const alternateResult = (_a = host.getResolvedModule(sourceFile, moduleReference, mode)) == null ? void 0 : _a.alternateResult;
13093
+ const alternateResultMessage = alternateResult && (getEmitModuleResolutionKind(host.getCompilerOptions()) === 2 /* Node10 */ ? [Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setting_Consider_updating_to_node16_nodenext_or_bundler, [alternateResult]] : [
13094
+ Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings,
13095
+ [alternateResult, alternateResult.includes(nodeModulesPathPart + "@types/") ? `@types/${mangleScopedPackageName(packageName)}` : packageName]
13096
+ ]);
13097
+ const result = alternateResultMessage ? chainDiagnosticMessages(
13093
13098
  /*details*/
13094
13099
  void 0,
13095
- Diagnostics.There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings,
13096
- node10Result,
13097
- node10Result.includes(nodeModulesPathPart + "@types/") ? `@types/${mangleScopedPackageName(packageName)}` : packageName
13100
+ alternateResultMessage[0],
13101
+ ...alternateResultMessage[1]
13098
13102
  ) : host.typesPackageExists(packageName) ? chainDiagnosticMessages(
13099
13103
  /*details*/
13100
13104
  void 0,
@@ -39571,7 +39575,7 @@ ${lanes.join("\n")}
39571
39575
  Debug.assert(extensionIsTS(resolved.extension));
39572
39576
  return { fileName: resolved.path, packageId: resolved.packageId };
39573
39577
  }
39574
- function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) {
39578
+ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, alternateResult) {
39575
39579
  if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) {
39576
39580
  const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled);
39577
39581
  if (originalPath)
@@ -39585,10 +39589,10 @@ ${lanes.join("\n")}
39585
39589
  diagnostics,
39586
39590
  state.resultFromCache,
39587
39591
  cache,
39588
- legacyResult
39592
+ alternateResult
39589
39593
  );
39590
39594
  }
39591
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) {
39595
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, alternateResult) {
39592
39596
  if (resultFromCache) {
39593
39597
  if (!(cache == null ? void 0 : cache.isReadonly)) {
39594
39598
  resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
@@ -39616,7 +39620,7 @@ ${lanes.join("\n")}
39616
39620
  failedLookupLocations: initializeResolutionField(failedLookupLocations),
39617
39621
  affectingLocations: initializeResolutionField(affectingLocations),
39618
39622
  resolutionDiagnostics: initializeResolutionField(diagnostics),
39619
- node10Result: legacyResult
39623
+ alternateResult
39620
39624
  };
39621
39625
  }
39622
39626
  function initializeResolutionField(value) {
@@ -39833,7 +39837,8 @@ ${lanes.join("\n")}
39833
39837
  requestContainingDirectory: containingDirectory,
39834
39838
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
39835
39839
  isConfigLookup: false,
39836
- candidateIsFromPackageJsonField: false
39840
+ candidateIsFromPackageJsonField: false,
39841
+ resolvedPackageDirectory: false
39837
39842
  };
39838
39843
  let resolved = primaryLookup();
39839
39844
  let primary = true;
@@ -40711,7 +40716,7 @@ ${lanes.join("\n")}
40711
40716
  );
40712
40717
  }
40713
40718
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, isConfigLookup, redirectedReference, conditions) {
40714
- var _a, _b, _c, _d;
40719
+ var _a, _b, _c, _d, _e;
40715
40720
  const traceEnabled = isTraceEnabled(compilerOptions, host);
40716
40721
  const failedLookupLocations = [];
40717
40722
  const affectingLocations = [];
@@ -40733,7 +40738,8 @@ ${lanes.join("\n")}
40733
40738
  requestContainingDirectory: containingDirectory,
40734
40739
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
40735
40740
  isConfigLookup,
40736
- candidateIsFromPackageJsonField: false
40741
+ candidateIsFromPackageJsonField: false,
40742
+ resolvedPackageDirectory: false
40737
40743
  };
40738
40744
  if (traceEnabled && moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
40739
40745
  trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & 32 /* EsmMode */ ? "ESM" : "CJS", state.conditions.map((c) => `'${c}'`).join(", "));
@@ -40746,29 +40752,46 @@ ${lanes.join("\n")}
40746
40752
  } else {
40747
40753
  result = tryResolve(extensions, state);
40748
40754
  }
40749
- let legacyResult;
40750
- if (((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.isExternalLibraryImport) && !isConfigLookup && extensions & (1 /* TypeScript */ | 4 /* Declaration */) && features & 8 /* Exports */ && !isExternalModuleNameRelative(moduleName) && !extensionIsOk(1 /* TypeScript */ | 4 /* Declaration */, result.value.resolved.extension) && (conditions == null ? void 0 : conditions.includes("import"))) {
40751
- traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update);
40752
- const diagnosticState = {
40753
- ...state,
40754
- features: state.features & ~8 /* Exports */,
40755
- reportDiagnostic: noop
40756
- };
40757
- const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
40758
- if ((_b = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _b.isExternalLibraryImport) {
40759
- legacyResult = diagnosticResult.value.resolved.path;
40755
+ let alternateResult;
40756
+ if (state.resolvedPackageDirectory && !isConfigLookup && !isExternalModuleNameRelative(moduleName)) {
40757
+ const wantedTypesButGotJs = (result == null ? void 0 : result.value) && extensions & (1 /* TypeScript */ | 4 /* Declaration */) && !extensionIsOk(1 /* TypeScript */ | 4 /* Declaration */, result.value.resolved.extension);
40758
+ if (((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.isExternalLibraryImport) && wantedTypesButGotJs && features & 8 /* Exports */ && (conditions == null ? void 0 : conditions.includes("import"))) {
40759
+ traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update);
40760
+ const diagnosticState = {
40761
+ ...state,
40762
+ features: state.features & ~8 /* Exports */,
40763
+ reportDiagnostic: noop
40764
+ };
40765
+ const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
40766
+ if ((_b = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _b.isExternalLibraryImport) {
40767
+ alternateResult = diagnosticResult.value.resolved.path;
40768
+ }
40769
+ } else if ((!(result == null ? void 0 : result.value) || wantedTypesButGotJs) && moduleResolution === 2 /* Node10 */) {
40770
+ traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_need_configuration_update);
40771
+ const diagnosticsCompilerOptions = { ...state.compilerOptions, moduleResolution: 100 /* Bundler */ };
40772
+ const diagnosticState = {
40773
+ ...state,
40774
+ compilerOptions: diagnosticsCompilerOptions,
40775
+ features: 30 /* BundlerDefault */,
40776
+ conditions: getConditions(diagnosticsCompilerOptions),
40777
+ reportDiagnostic: noop
40778
+ };
40779
+ const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
40780
+ if ((_c = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _c.isExternalLibraryImport) {
40781
+ alternateResult = diagnosticResult.value.resolved.path;
40782
+ }
40760
40783
  }
40761
40784
  }
40762
40785
  return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
40763
40786
  moduleName,
40764
- (_c = result == null ? void 0 : result.value) == null ? void 0 : _c.resolved,
40765
- (_d = result == null ? void 0 : result.value) == null ? void 0 : _d.isExternalLibraryImport,
40787
+ (_d = result == null ? void 0 : result.value) == null ? void 0 : _d.resolved,
40788
+ (_e = result == null ? void 0 : result.value) == null ? void 0 : _e.isExternalLibraryImport,
40766
40789
  failedLookupLocations,
40767
40790
  affectingLocations,
40768
40791
  diagnostics,
40769
40792
  state,
40770
40793
  cache,
40771
- legacyResult
40794
+ alternateResult
40772
40795
  );
40773
40796
  function tryResolve(extensions2, state2) {
40774
40797
  const loader = (extensions3, candidate, onlyRecordFailures, state3) => nodeLoadModuleByRelativeName(
@@ -41133,7 +41156,8 @@ ${lanes.join("\n")}
41133
41156
  requestContainingDirectory: void 0,
41134
41157
  reportDiagnostic: noop,
41135
41158
  isConfigLookup: false,
41136
- candidateIsFromPackageJsonField: false
41159
+ candidateIsFromPackageJsonField: false,
41160
+ resolvedPackageDirectory: false
41137
41161
  };
41138
41162
  }
41139
41163
  function getPackageScopeForPath(fileName, state) {
@@ -41859,6 +41883,9 @@ ${lanes.join("\n")}
41859
41883
  if (rest !== "") {
41860
41884
  packageInfo = rootPackageInfo ?? getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
41861
41885
  }
41886
+ if (packageInfo) {
41887
+ state.resolvedPackageDirectory = true;
41888
+ }
41862
41889
  if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & 8 /* Exports */) {
41863
41890
  return (_b = loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)) == null ? void 0 : _b.value;
41864
41891
  }
@@ -41977,7 +42004,8 @@ ${lanes.join("\n")}
41977
42004
  requestContainingDirectory: containingDirectory,
41978
42005
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
41979
42006
  isConfigLookup: false,
41980
- candidateIsFromPackageJsonField: false
42007
+ candidateIsFromPackageJsonField: false,
42008
+ resolvedPackageDirectory: false
41981
42009
  };
41982
42010
  const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
41983
42011
  return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
@@ -42086,7 +42114,8 @@ ${lanes.join("\n")}
42086
42114
  requestContainingDirectory: void 0,
42087
42115
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
42088
42116
  isConfigLookup: false,
42089
- candidateIsFromPackageJsonField: false
42117
+ candidateIsFromPackageJsonField: false,
42118
+ resolvedPackageDirectory: false
42090
42119
  };
42091
42120
  const resolved = loadModuleFromImmediateNodeModulesDirectory(
42092
42121
  4 /* Declaration */,
@@ -49375,7 +49404,7 @@ ${lanes.join("\n")}
49375
49404
  return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
49376
49405
  }
49377
49406
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
49378
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
49407
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
49379
49408
  if (startsWith(moduleReference, "@types/")) {
49380
49409
  const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
49381
49410
  const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
@@ -49544,7 +49573,17 @@ ${lanes.join("\n")}
49544
49573
  error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
49545
49574
  }
49546
49575
  } else {
49547
- error2(errorNode, moduleNotFoundError, moduleReference);
49576
+ if ((_k = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _k.alternateResult) {
49577
+ const errorInfo = createModuleNotFoundChain(currentSourceFile, host, moduleReference, mode, moduleReference);
49578
+ errorOrSuggestion(
49579
+ /*isError*/
49580
+ true,
49581
+ errorNode,
49582
+ chainDiagnosticMessages(errorInfo, moduleNotFoundError, moduleReference)
49583
+ );
49584
+ } else {
49585
+ error2(errorNode, moduleNotFoundError, moduleReference);
49586
+ }
49548
49587
  }
49549
49588
  }
49550
49589
  }
@@ -126181,10 +126220,10 @@ ${lanes.join("\n")}
126181
126220
  }
126182
126221
  function watchFailedLookupLocationOfResolution(resolution) {
126183
126222
  Debug.assert(!!resolution.refCount);
126184
- const { failedLookupLocations, affectingLocations, node10Result } = resolution;
126185
- if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !node10Result)
126223
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
126224
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !alternateResult)
126186
126225
  return;
126187
- if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || node10Result)
126226
+ if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || alternateResult)
126188
126227
  resolutionsWithFailedLookups.add(resolution);
126189
126228
  let setAtRoot = false;
126190
126229
  if (failedLookupLocations) {
@@ -126192,8 +126231,8 @@ ${lanes.join("\n")}
126192
126231
  setAtRoot = watchFailedLookupLocation(failedLookupLocation, setAtRoot);
126193
126232
  }
126194
126233
  }
126195
- if (node10Result)
126196
- setAtRoot = watchFailedLookupLocation(node10Result, setAtRoot);
126234
+ if (alternateResult)
126235
+ setAtRoot = watchFailedLookupLocation(alternateResult, setAtRoot);
126197
126236
  if (setAtRoot) {
126198
126237
  setDirectoryWatcher(
126199
126238
  rootDir,
@@ -126202,7 +126241,7 @@ ${lanes.join("\n")}
126202
126241
  true
126203
126242
  );
126204
126243
  }
126205
- watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !node10Result);
126244
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !alternateResult);
126206
126245
  }
126207
126246
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
126208
126247
  Debug.assert(!!resolution.refCount);
@@ -126340,7 +126379,7 @@ ${lanes.join("\n")}
126340
126379
  if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size)
126341
126380
  resolvedFileToResolution.delete(key);
126342
126381
  }
126343
- const { failedLookupLocations, affectingLocations, node10Result } = resolution;
126382
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
126344
126383
  if (resolutionsWithFailedLookups.delete(resolution)) {
126345
126384
  let removeAtRoot = false;
126346
126385
  if (failedLookupLocations) {
@@ -126348,8 +126387,8 @@ ${lanes.join("\n")}
126348
126387
  removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot, syncDirWatcherRemove);
126349
126388
  }
126350
126389
  }
126351
- if (node10Result)
126352
- removeAtRoot = stopWatchFailedLookupLocation(node10Result, removeAtRoot, syncDirWatcherRemove);
126390
+ if (alternateResult)
126391
+ removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot, syncDirWatcherRemove);
126353
126392
  if (removeAtRoot)
126354
126393
  removeDirectoryWatcher(rootPath, syncDirWatcherRemove);
126355
126394
  } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
@@ -126516,7 +126555,7 @@ ${lanes.join("\n")}
126516
126555
  return true;
126517
126556
  if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
126518
126557
  return false;
126519
- return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)))) || !!resolution.node10Result && isInvalidatedFailedLookup(resolutionHost.toPath(resolution.node10Result));
126558
+ return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)))) || !!resolution.alternateResult && isInvalidatedFailedLookup(resolutionHost.toPath(resolution.alternateResult));
126520
126559
  }
126521
126560
  function isInvalidatedFailedLookup(locationPath) {
126522
126561
  return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (dirPath) => locationPath.length > dirPath.length && startsWith(locationPath, dirPath) && (isDiskPathRoot(dirPath) || locationPath[dirPath.length] === directorySeparator) ? true : void 0);
@@ -133890,7 +133929,7 @@ ${lanes.join("\n")}
133890
133929
  const pattern = getPatternFromSpec(spec, "", "exclude");
133891
133930
  return pattern ? getRegexFromPattern(pattern, useCaseSensitiveFileNames2) : void 0;
133892
133931
  });
133893
- forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, (module2, file) => cb(
133932
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, host, (module2, file) => cb(
133894
133933
  module2,
133895
133934
  file,
133896
133935
  program,
@@ -133901,7 +133940,7 @@ ${lanes.join("\n")}
133901
133940
  if (autoImportProvider) {
133902
133941
  const start = timestamp();
133903
133942
  const checker = program.getTypeChecker();
133904
- forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, (module2, file) => {
133943
+ forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, host, (module2, file) => {
133905
133944
  if (file && !program.getSourceFile(file.fileName) || !file && !checker.resolveName(
133906
133945
  module2.name,
133907
133946
  /*location*/
@@ -133922,11 +133961,26 @@ ${lanes.join("\n")}
133922
133961
  (_b = host.log) == null ? void 0 : _b.call(host, `forEachExternalModuleToImportFrom autoImportProvider: ${timestamp() - start}`);
133923
133962
  }
133924
133963
  }
133925
- function forEachExternalModule(checker, allSourceFiles, excludePatterns, cb) {
133926
- var _a;
133927
- const isExcluded = excludePatterns && ((fileName) => excludePatterns.some((p) => p.test(fileName)));
133964
+ function forEachExternalModule(checker, allSourceFiles, excludePatterns, host, cb) {
133965
+ var _a, _b;
133966
+ const realpathsWithSymlinks = (_a = host.getSymlinkCache) == null ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
133967
+ const isExcluded = excludePatterns && (({ fileName, path }) => {
133968
+ if (excludePatterns.some((p) => p.test(fileName)))
133969
+ return true;
133970
+ if ((realpathsWithSymlinks == null ? void 0 : realpathsWithSymlinks.size) && pathContainsNodeModules(fileName)) {
133971
+ let dir = getDirectoryPath(fileName);
133972
+ return forEachAncestorDirectory(getDirectoryPath(path), (dirPath) => {
133973
+ const symlinks = realpathsWithSymlinks.get(ensureTrailingDirectorySeparator(dirPath));
133974
+ if (symlinks) {
133975
+ return symlinks.some((s) => excludePatterns.some((p) => p.test(fileName.replace(dir, s))));
133976
+ }
133977
+ dir = getDirectoryPath(dir);
133978
+ }) ?? false;
133979
+ }
133980
+ return false;
133981
+ });
133928
133982
  for (const ambient of checker.getAmbientModules()) {
133929
- if (!ambient.name.includes("*") && !(excludePatterns && ((_a = ambient.declarations) == null ? void 0 : _a.every((d) => isExcluded(d.getSourceFile().fileName))))) {
133983
+ if (!ambient.name.includes("*") && !(excludePatterns && ((_b = ambient.declarations) == null ? void 0 : _b.every((d) => isExcluded(d.getSourceFile()))))) {
133930
133984
  cb(
133931
133985
  ambient,
133932
133986
  /*sourceFile*/
@@ -133935,7 +133989,7 @@ ${lanes.join("\n")}
133935
133989
  }
133936
133990
  }
133937
133991
  for (const sourceFile of allSourceFiles) {
133938
- if (isExternalOrCommonJsModule(sourceFile) && !(isExcluded == null ? void 0 : isExcluded(sourceFile.fileName))) {
133992
+ if (isExternalOrCommonJsModule(sourceFile) && !(isExcluded == null ? void 0 : isExcluded(sourceFile))) {
133939
133993
  cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
133940
133994
  }
133941
133995
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.4";
57
- var version = `${versionMajorMinor}.0-dev.20240116`;
57
+ var version = `${versionMajorMinor}.0-dev.20240118`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -6519,6 +6519,8 @@ var Diagnostics = {
6519
6519
  Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6276, 3 /* Message */, "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276", "Export specifier '{0}' does not exist in package.json scope at path '{1}'."),
6520
6520
  Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update: diag(6277, 3 /* Message */, "Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_i_6277", "Resolution of non-relative name failed; trying with modern Node resolution features disabled to see if npm library needs configuration update."),
6521
6521
  There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The_1_library_may_need_to_update_its_package_json_or_typings: diag(6278, 3 /* Message */, "There_are_types_at_0_but_this_result_could_not_be_resolved_when_respecting_package_json_exports_The__6278", `There are types at '{0}', but this result could not be resolved when respecting package.json "exports". The '{1}' library may need to update its package.json or typings.`),
6522
+ Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_need_configuration_update: diag(6279, 3 /* Message */, "Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_ne_6279", "Resolution of non-relative name failed; trying with '--moduleResolution bundler' to see if project may need configuration update."),
6523
+ There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setting_Consider_updating_to_node16_nodenext_or_bundler: diag(6280, 3 /* Message */, "There_are_types_at_0_but_this_result_could_not_be_resolved_under_your_current_moduleResolution_setti_6280", "There are types at '{0}', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'."),
6522
6524
  Enable_project_compilation: diag(6302, 3 /* Message */, "Enable_project_compilation_6302", "Enable project compilation"),
6523
6525
  Composite_projects_may_not_disable_declaration_emit: diag(6304, 1 /* Error */, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."),
6524
6526
  Output_file_0_has_not_been_built_from_source_file_1: diag(6305, 1 /* Error */, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."),
@@ -8428,7 +8430,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
8428
8430
  }
8429
8431
  const ch = codePointAt(text, pos);
8430
8432
  if (pos === 0) {
8431
- if (ch === 65533 /* replacementCharacter */) {
8433
+ if (text.slice(0, 256).includes("\uFFFD")) {
8432
8434
  error(Diagnostics.File_appears_to_be_binary);
8433
8435
  pos = end;
8434
8436
  return token = 8 /* NonTextFileMarkerTrivia */;
@@ -27655,7 +27657,7 @@ function formatExtensions(extensions) {
27655
27657
  result.push("JSON");
27656
27658
  return result.join(", ");
27657
27659
  }
27658
- function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, legacyResult) {
27660
+ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, cache, alternateResult) {
27659
27661
  if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) {
27660
27662
  const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled);
27661
27663
  if (originalPath)
@@ -27669,10 +27671,10 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName
27669
27671
  diagnostics,
27670
27672
  state.resultFromCache,
27671
27673
  cache,
27672
- legacyResult
27674
+ alternateResult
27673
27675
  );
27674
27676
  }
27675
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, legacyResult) {
27677
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, alternateResult) {
27676
27678
  if (resultFromCache) {
27677
27679
  if (!(cache == null ? void 0 : cache.isReadonly)) {
27678
27680
  resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
@@ -27700,7 +27702,7 @@ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibra
27700
27702
  failedLookupLocations: initializeResolutionField(failedLookupLocations),
27701
27703
  affectingLocations: initializeResolutionField(affectingLocations),
27702
27704
  resolutionDiagnostics: initializeResolutionField(diagnostics),
27703
- node10Result: legacyResult
27705
+ alternateResult
27704
27706
  };
27705
27707
  }
27706
27708
  function initializeResolutionField(value) {
@@ -28177,7 +28179,7 @@ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, hos
28177
28179
  return nodeModuleNameResolverWorker(conditions ? 30 /* AllFeatures */ : 0 /* None */, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, !!isConfigLookup, redirectedReference, conditions);
28178
28180
  }
28179
28181
  function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, isConfigLookup, redirectedReference, conditions) {
28180
- var _a, _b, _c, _d;
28182
+ var _a, _b, _c, _d, _e;
28181
28183
  const traceEnabled = isTraceEnabled(compilerOptions, host);
28182
28184
  const failedLookupLocations = [];
28183
28185
  const affectingLocations = [];
@@ -28199,7 +28201,8 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
28199
28201
  requestContainingDirectory: containingDirectory,
28200
28202
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
28201
28203
  isConfigLookup,
28202
- candidateIsFromPackageJsonField: false
28204
+ candidateIsFromPackageJsonField: false,
28205
+ resolvedPackageDirectory: false
28203
28206
  };
28204
28207
  if (traceEnabled && moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
28205
28208
  trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & 32 /* EsmMode */ ? "ESM" : "CJS", state.conditions.map((c) => `'${c}'`).join(", "));
@@ -28212,29 +28215,46 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
28212
28215
  } else {
28213
28216
  result = tryResolve(extensions, state);
28214
28217
  }
28215
- let legacyResult;
28216
- if (((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.isExternalLibraryImport) && !isConfigLookup && extensions & (1 /* TypeScript */ | 4 /* Declaration */) && features & 8 /* Exports */ && !isExternalModuleNameRelative(moduleName) && !extensionIsOk(1 /* TypeScript */ | 4 /* Declaration */, result.value.resolved.extension) && (conditions == null ? void 0 : conditions.includes("import"))) {
28217
- traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update);
28218
- const diagnosticState = {
28219
- ...state,
28220
- features: state.features & ~8 /* Exports */,
28221
- reportDiagnostic: noop
28222
- };
28223
- const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
28224
- if ((_b = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _b.isExternalLibraryImport) {
28225
- legacyResult = diagnosticResult.value.resolved.path;
28218
+ let alternateResult;
28219
+ if (state.resolvedPackageDirectory && !isConfigLookup && !isExternalModuleNameRelative(moduleName)) {
28220
+ const wantedTypesButGotJs = (result == null ? void 0 : result.value) && extensions & (1 /* TypeScript */ | 4 /* Declaration */) && !extensionIsOk(1 /* TypeScript */ | 4 /* Declaration */, result.value.resolved.extension);
28221
+ if (((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.isExternalLibraryImport) && wantedTypesButGotJs && features & 8 /* Exports */ && (conditions == null ? void 0 : conditions.includes("import"))) {
28222
+ traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update);
28223
+ const diagnosticState = {
28224
+ ...state,
28225
+ features: state.features & ~8 /* Exports */,
28226
+ reportDiagnostic: noop
28227
+ };
28228
+ const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
28229
+ if ((_b = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _b.isExternalLibraryImport) {
28230
+ alternateResult = diagnosticResult.value.resolved.path;
28231
+ }
28232
+ } else if ((!(result == null ? void 0 : result.value) || wantedTypesButGotJs) && moduleResolution === 2 /* Node10 */) {
28233
+ traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_moduleResolution_bundler_to_see_if_project_may_need_configuration_update);
28234
+ const diagnosticsCompilerOptions = { ...state.compilerOptions, moduleResolution: 100 /* Bundler */ };
28235
+ const diagnosticState = {
28236
+ ...state,
28237
+ compilerOptions: diagnosticsCompilerOptions,
28238
+ features: 30 /* BundlerDefault */,
28239
+ conditions: getConditions(diagnosticsCompilerOptions),
28240
+ reportDiagnostic: noop
28241
+ };
28242
+ const diagnosticResult = tryResolve(extensions & (1 /* TypeScript */ | 4 /* Declaration */), diagnosticState);
28243
+ if ((_c = diagnosticResult == null ? void 0 : diagnosticResult.value) == null ? void 0 : _c.isExternalLibraryImport) {
28244
+ alternateResult = diagnosticResult.value.resolved.path;
28245
+ }
28226
28246
  }
28227
28247
  }
28228
28248
  return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
28229
28249
  moduleName,
28230
- (_c = result == null ? void 0 : result.value) == null ? void 0 : _c.resolved,
28231
- (_d = result == null ? void 0 : result.value) == null ? void 0 : _d.isExternalLibraryImport,
28250
+ (_d = result == null ? void 0 : result.value) == null ? void 0 : _d.resolved,
28251
+ (_e = result == null ? void 0 : result.value) == null ? void 0 : _e.isExternalLibraryImport,
28232
28252
  failedLookupLocations,
28233
28253
  affectingLocations,
28234
28254
  diagnostics,
28235
28255
  state,
28236
28256
  cache,
28237
- legacyResult
28257
+ alternateResult
28238
28258
  );
28239
28259
  function tryResolve(extensions2, state2) {
28240
28260
  const loader = (extensions3, candidate, onlyRecordFailures, state3) => nodeLoadModuleByRelativeName(
@@ -29196,6 +29216,9 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, node
29196
29216
  if (rest !== "") {
29197
29217
  packageInfo = rootPackageInfo ?? getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
29198
29218
  }
29219
+ if (packageInfo) {
29220
+ state.resolvedPackageDirectory = true;
29221
+ }
29199
29222
  if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & 8 /* Exports */) {
29200
29223
  return (_b = loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)) == null ? void 0 : _b.value;
29201
29224
  }
@@ -29302,7 +29325,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
29302
29325
  requestContainingDirectory: containingDirectory,
29303
29326
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
29304
29327
  isConfigLookup: false,
29305
- candidateIsFromPackageJsonField: false
29328
+ candidateIsFromPackageJsonField: false,
29329
+ resolvedPackageDirectory: false
29306
29330
  };
29307
29331
  const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
29308
29332
  return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.4.0-dev.20240116",
5
+ "version": "5.4.0-dev.20240118",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "cf33fd0cde22905effce371bb02484a9f2009023"
116
+ "gitHead": "6add96fd18d126d1505de5d96f0df6a86e5f2c21"
117
117
  }