typescript 4.7.0-dev.20220505 → 4.8.0-dev.20220508

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
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  var ts;
70
70
  (function (ts) {
71
- ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220505";
71
+ ts.versionMajorMinor = "4.8";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220508";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5593,6 +5593,8 @@ var ts;
5593
5593
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true),
5594
5594
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
5595
5595
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
5596
+ The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
5597
+ The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
5596
5598
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5597
5599
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
5598
5600
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -6182,6 +6184,7 @@ var ts;
6182
6184
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
6183
6185
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
6184
6186
  Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6187
+ Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6185
6188
  The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
6186
6189
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
6187
6190
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -14050,6 +14053,10 @@ var ts;
14050
14053
  return indentStrings[1].length;
14051
14054
  }
14052
14055
  ts.getIndentSize = getIndentSize;
14056
+ function isNightly() {
14057
+ return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
14058
+ }
14059
+ ts.isNightly = isNightly;
14053
14060
  function createTextWriter(newLine) {
14054
14061
  var output;
14055
14062
  var indent;
@@ -14276,6 +14283,13 @@ var ts;
14276
14283
  ".d.ts";
14277
14284
  }
14278
14285
  ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
14286
+ function getPossibleOriginalInputExtensionForExtension(path) {
14287
+ return ts.fileExtensionIsOneOf(path, [".d.mts", ".mjs", ".mts"]) ? [".mts", ".mjs"] :
14288
+ ts.fileExtensionIsOneOf(path, [".d.cts", ".cjs", ".cts"]) ? [".cts", ".cjs"] :
14289
+ ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json"] :
14290
+ [".tsx", ".ts", ".jsx", ".js"];
14291
+ }
14292
+ ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
14279
14293
  function outFile(options) {
14280
14294
  return options.outFile || options.out;
14281
14295
  }
@@ -26455,6 +26469,7 @@ var ts;
26455
26469
  var startPos = scanner.getStartPos();
26456
26470
  var result = parseListElement(kind, parseElement);
26457
26471
  if (!result) {
26472
+ parsingContext = saveParsingContext;
26458
26473
  return undefined;
26459
26474
  }
26460
26475
  list.push(result);
@@ -31465,6 +31480,7 @@ var ts;
31465
31480
  ["es2021.intl", "lib.es2021.intl.d.ts"],
31466
31481
  ["es2022.array", "lib.es2022.array.d.ts"],
31467
31482
  ["es2022.error", "lib.es2022.error.d.ts"],
31483
+ ["es2022.intl", "lib.es2022.intl.d.ts"],
31468
31484
  ["es2022.object", "lib.es2022.object.d.ts"],
31469
31485
  ["es2022.string", "lib.es2022.string.d.ts"],
31470
31486
  ["esnext.array", "lib.es2022.array.d.ts"],
@@ -34356,7 +34372,7 @@ var ts;
34356
34372
  ts.Debug.assert(ts.extensionIsTS(resolved.extension));
34357
34373
  return { fileName: resolved.path, packageId: resolved.packageId };
34358
34374
  }
34359
- function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
34375
+ function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
34360
34376
  var _a;
34361
34377
  if (resultFromCache) {
34362
34378
  (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
@@ -34364,7 +34380,8 @@ var ts;
34364
34380
  }
34365
34381
  return {
34366
34382
  resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
34367
- failedLookupLocations: failedLookupLocations
34383
+ failedLookupLocations: failedLookupLocations,
34384
+ resolutionDiagnostics: diagnostics
34368
34385
  };
34369
34386
  }
34370
34387
  function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
@@ -34545,7 +34562,18 @@ var ts;
34545
34562
  features |= NodeResolutionFeatures.EsmMode;
34546
34563
  }
34547
34564
  var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
34548
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
34565
+ var diagnostics = [];
34566
+ var moduleResolutionState = {
34567
+ compilerOptions: options,
34568
+ host: host,
34569
+ traceEnabled: traceEnabled,
34570
+ failedLookupLocations: failedLookupLocations,
34571
+ packageJsonInfoCache: cache,
34572
+ features: features,
34573
+ conditions: conditions,
34574
+ requestContainingDirectory: containingDirectory,
34575
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
34576
+ };
34549
34577
  var resolved = primaryLookup();
34550
34578
  var primary = true;
34551
34579
  if (!resolved) {
@@ -34564,7 +34592,7 @@ var ts;
34564
34592
  isExternalLibraryImport: pathContainsNodeModules(fileName),
34565
34593
  };
34566
34594
  }
34567
- result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
34595
+ result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
34568
34596
  perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
34569
34597
  if (traceEnabled)
34570
34598
  traceResult(result);
@@ -34641,6 +34669,8 @@ var ts;
34641
34669
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
34642
34670
  conditions: ts.emptyArray,
34643
34671
  features: NodeResolutionFeatures.None,
34672
+ requestContainingDirectory: containingDirectory,
34673
+ reportDiagnostic: ts.noop
34644
34674
  };
34645
34675
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
34646
34676
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
@@ -35169,6 +35199,7 @@ var ts;
35169
35199
  if (compilerOptions.noDtsResolution) {
35170
35200
  conditions.pop();
35171
35201
  }
35202
+ var diagnostics = [];
35172
35203
  var state = {
35173
35204
  compilerOptions: compilerOptions,
35174
35205
  host: host,
@@ -35177,9 +35208,11 @@ var ts;
35177
35208
  packageJsonInfoCache: cache,
35178
35209
  features: features,
35179
35210
  conditions: conditions,
35211
+ requestContainingDirectory: containingDirectory,
35212
+ reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
35180
35213
  };
35181
35214
  var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
35182
- return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
35215
+ return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
35183
35216
  function tryResolve(extensions) {
35184
35217
  var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
35185
35218
  var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
@@ -35321,9 +35354,9 @@ var ts;
35321
35354
  }
35322
35355
  }
35323
35356
  function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
35324
- if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.isDeclarationFileName(candidate)) {
35357
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
35325
35358
  var result = tryFile(candidate, onlyRecordFailures, state);
35326
- return result !== undefined ? { path: candidate, ext: ts.forEach(ts.supportedDeclarationExtensions, function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
35359
+ return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
35327
35360
  }
35328
35361
  return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
35329
35362
  }
@@ -35440,6 +35473,8 @@ var ts;
35440
35473
  packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
35441
35474
  conditions: ["node", "require", "types"],
35442
35475
  features: features,
35476
+ requestContainingDirectory: packageJsonInfo.packageDirectory,
35477
+ reportDiagnostic: ts.noop
35443
35478
  };
35444
35479
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
35445
35480
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
@@ -35519,6 +35554,8 @@ var ts;
35519
35554
  packageJsonInfoCache: packageJsonInfoCache,
35520
35555
  features: 0,
35521
35556
  conditions: [],
35557
+ requestContainingDirectory: undefined,
35558
+ reportDiagnostic: ts.noop
35522
35559
  };
35523
35560
  var parts = ts.getPathComponents(fileName);
35524
35561
  parts.pop();
@@ -35793,7 +35830,6 @@ var ts;
35793
35830
  function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
35794
35831
  return loadModuleFromTargetImportOrExport;
35795
35832
  function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
35796
- var _a, _b;
35797
35833
  if (typeof target === "string") {
35798
35834
  if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
35799
35835
  if (state.traceEnabled) {
@@ -35828,13 +35864,16 @@ var ts;
35828
35864
  }
35829
35865
  return toSearchResult(undefined);
35830
35866
  }
35831
- var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
35867
+ var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
35868
+ var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
35869
+ if (inputLink)
35870
+ return inputLink;
35832
35871
  return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, false, state)));
35833
35872
  }
35834
35873
  else if (typeof target === "object" && target !== null) {
35835
35874
  if (!Array.isArray(target)) {
35836
- for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
35837
- var key = _c[_i];
35875
+ for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
35876
+ var key = _a[_i];
35838
35877
  if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
35839
35878
  var subTarget = target[key];
35840
35879
  var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
@@ -35852,8 +35891,8 @@ var ts;
35852
35891
  }
35853
35892
  return toSearchResult(undefined);
35854
35893
  }
35855
- for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
35856
- var elem = target_2[_d];
35894
+ for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
35895
+ var elem = target_2[_b];
35857
35896
  var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
35858
35897
  if (result) {
35859
35898
  return result;
@@ -35871,6 +35910,94 @@ var ts;
35871
35910
  trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
35872
35911
  }
35873
35912
  return toSearchResult(undefined);
35913
+ function toAbsolutePath(path) {
35914
+ var _a, _b;
35915
+ if (path === undefined)
35916
+ return path;
35917
+ return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
35918
+ }
35919
+ function combineDirectoryPath(root, dir) {
35920
+ return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
35921
+ }
35922
+ function useCaseSensitiveFileNames() {
35923
+ return !state.host.useCaseSensitiveFileNames ? true :
35924
+ typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
35925
+ state.host.useCaseSensitiveFileNames();
35926
+ }
35927
+ function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
35928
+ var _a, _b, _c, _d;
35929
+ if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
35930
+ && (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
35931
+ && finalPath.indexOf("/node_modules/") === -1
35932
+ && (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
35933
+ var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
35934
+ var commonSourceDirGuesses = [];
35935
+ if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
35936
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
35937
+ commonSourceDirGuesses.push(commonDir);
35938
+ }
35939
+ else if (state.requestContainingDirectory) {
35940
+ var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
35941
+ var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName));
35942
+ commonSourceDirGuesses.push(commonDir);
35943
+ var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
35944
+ while (fragment && fragment.length > 1) {
35945
+ var parts = ts.getPathComponents(fragment);
35946
+ parts.pop();
35947
+ var commonDir_1 = ts.getPathFromPathComponents(parts);
35948
+ commonSourceDirGuesses.unshift(commonDir_1);
35949
+ fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
35950
+ }
35951
+ }
35952
+ if (commonSourceDirGuesses.length > 1) {
35953
+ state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
35954
+ ? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
35955
+ : ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, packagePath));
35956
+ }
35957
+ for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
35958
+ var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
35959
+ var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
35960
+ for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
35961
+ var candidateDir = candidateDirectories_1[_e];
35962
+ if (ts.startsWith(finalPath, candidateDir)) {
35963
+ var pathFragment = finalPath.slice(candidateDir.length + 1);
35964
+ var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
35965
+ var jsAndDtsExtensions = [".mjs", ".cjs", ".js", ".json", ".d.mts", ".d.cts", ".d.ts"];
35966
+ for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
35967
+ var ext = jsAndDtsExtensions_1[_f];
35968
+ if (ts.fileExtensionIs(possibleInputBase, ext)) {
35969
+ var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
35970
+ for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
35971
+ var possibleExt = inputExts_1[_g];
35972
+ var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
35973
+ if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
35974
+ (extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
35975
+ continue;
35976
+ }
35977
+ if (state.host.fileExists(possibleInputWithInputExtension)) {
35978
+ return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, false, state)));
35979
+ }
35980
+ }
35981
+ }
35982
+ }
35983
+ }
35984
+ }
35985
+ }
35986
+ }
35987
+ return undefined;
35988
+ function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
35989
+ var _a, _b;
35990
+ var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
35991
+ var candidateDirectories = [];
35992
+ if (state.compilerOptions.declarationDir) {
35993
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
35994
+ }
35995
+ if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
35996
+ candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
35997
+ }
35998
+ return candidateDirectories;
35999
+ }
36000
+ }
35874
36001
  }
35875
36002
  }
35876
36003
  function isApplicableVersionedTypesKey(conditions, key) {
@@ -36045,10 +36172,11 @@ var ts;
36045
36172
  function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
36046
36173
  var traceEnabled = isTraceEnabled(compilerOptions, host);
36047
36174
  var failedLookupLocations = [];
36048
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
36049
36175
  var containingDirectory = ts.getDirectoryPath(containingFile);
36176
+ var diagnostics = [];
36177
+ var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
36050
36178
  var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
36051
- return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
36179
+ return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, diagnostics, state.resultFromCache);
36052
36180
  function tryResolve(extensions) {
36053
36181
  var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
36054
36182
  if (resolvedUsingSettings) {
@@ -36084,9 +36212,10 @@ var ts;
36084
36212
  trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
36085
36213
  }
36086
36214
  var failedLookupLocations = [];
36087
- var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
36215
+ var diagnostics = [];
36216
+ var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
36088
36217
  var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false, undefined, undefined);
36089
- return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
36218
+ return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, diagnostics, state.resultFromCache);
36090
36219
  }
36091
36220
  ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
36092
36221
  function toSearchResult(value) {
@@ -47928,7 +48057,8 @@ var ts;
47928
48057
  if (symbol === globalThisSymbol) {
47929
48058
  var varsOnly_1 = new ts.Map();
47930
48059
  members.forEach(function (p) {
47931
- if (!(p.flags & 418)) {
48060
+ var _a;
48061
+ if (!(p.flags & 418) && !(p.flags & 512 && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) {
47932
48062
  varsOnly_1.set(p.escapedName, p);
47933
48063
  }
47934
48064
  });
@@ -71083,6 +71213,9 @@ var ts;
71083
71213
  var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
71084
71214
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
71085
71215
  if (validForTypeAssertions && override) {
71216
+ if (!ts.isNightly()) {
71217
+ grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
71218
+ }
71086
71219
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
71087
71220
  return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
71088
71221
  }
@@ -72289,7 +72422,7 @@ var ts;
72289
72422
  }
72290
72423
  if (ts.isDeclaration(node)) {
72291
72424
  var symbol = getSymbolOfNode(node);
72292
- return getTypeOfSymbol(symbol);
72425
+ return symbol ? getTypeOfSymbol(symbol) : errorType;
72293
72426
  }
72294
72427
  if (isDeclarationNameOrImportPropertyName(node)) {
72295
72428
  var symbol = getSymbolAtLocation(node);
@@ -88732,24 +88865,34 @@ var ts;
88732
88865
  }
88733
88866
  function transformImportDeclaration(decl) {
88734
88867
  if (!decl.importClause) {
88735
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88868
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88736
88869
  }
88737
88870
  var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
88738
88871
  if (!decl.importClause.namedBindings) {
88739
- return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88872
+ return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88740
88873
  }
88741
88874
  if (decl.importClause.namedBindings.kind === 268) {
88742
88875
  var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
88743
- return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined) : undefined;
88876
+ return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
88744
88877
  }
88745
88878
  var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
88746
88879
  if ((bindingList && bindingList.length) || visibleDefaultBinding) {
88747
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88880
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88748
88881
  }
88749
88882
  if (resolver.isImportRequiredByAugmentation(decl)) {
88750
- return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), ts.getResolutionModeOverrideForClause(decl.assertClause) ? decl.assertClause : undefined);
88883
+ return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
88751
88884
  }
88752
88885
  }
88886
+ function getResolutionModeOverrideForClauseInNightly(assertClause) {
88887
+ var mode = ts.getResolutionModeOverrideForClause(assertClause);
88888
+ if (mode !== undefined) {
88889
+ if (!ts.isNightly()) {
88890
+ context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
88891
+ }
88892
+ return assertClause;
88893
+ }
88894
+ return undefined;
88895
+ }
88753
88896
  function transformAndReplaceLatePaintedStatements(statements) {
88754
88897
  while (ts.length(lateMarkedStatements)) {
88755
88898
  var i = lateMarkedStatements.shift();
@@ -95781,7 +95924,6 @@ var ts;
95781
95924
  ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
95782
95925
  ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
95783
95926
  ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
95784
- ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
95785
95927
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
95786
95928
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
95787
95929
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
@@ -96120,6 +96262,34 @@ var ts;
96120
96262
  ts.performance.measure("Program", "beforeProgram", "afterProgram");
96121
96263
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
96122
96264
  return program;
96265
+ function addResolutionDiagnostics(list) {
96266
+ if (!list)
96267
+ return;
96268
+ for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
96269
+ var elem = list_3[_i];
96270
+ programDiagnostics.add(elem);
96271
+ }
96272
+ }
96273
+ function pullDiagnosticsFromCache(names, containingFile) {
96274
+ var _a;
96275
+ if (!moduleResolutionCache)
96276
+ return;
96277
+ var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
96278
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
96279
+ var containingDir = ts.getDirectoryPath(containingFileName);
96280
+ var redirectedReference = getRedirectReferenceForResolution(containingFile);
96281
+ var i = 0;
96282
+ for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
96283
+ var n = names_4[_i];
96284
+ var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
96285
+ var name = typeof n === "string" ? n : n.fileName;
96286
+ i++;
96287
+ if (ts.isExternalModuleNameRelative(name))
96288
+ continue;
96289
+ var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
96290
+ addResolutionDiagnostics(diags);
96291
+ }
96292
+ }
96123
96293
  function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
96124
96294
  if (!moduleNames.length)
96125
96295
  return ts.emptyArray;
@@ -96131,6 +96301,7 @@ var ts;
96131
96301
  ts.performance.mark("afterResolveModule");
96132
96302
  ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
96133
96303
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
96304
+ pullDiagnosticsFromCache(moduleNames, containingFile);
96134
96305
  return result;
96135
96306
  }
96136
96307
  function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
@@ -99933,8 +100104,8 @@ var ts;
99933
100104
  !!redirectedReference;
99934
100105
  var seenNamesInFile = ts.createModeAwareCache();
99935
100106
  var i = 0;
99936
- for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
99937
- var entry = names_4[_i];
100107
+ for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
100108
+ var entry = names_5[_i];
99938
100109
  var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
99939
100110
  var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
99940
100111
  containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
@@ -100460,14 +100631,14 @@ var ts;
100460
100631
  if (options === void 0) { options = {}; }
100461
100632
  var info = getInfo(importingSourceFile.path, host);
100462
100633
  var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
100463
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, true, options.overrideImportMode); });
100634
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, true, options.overrideImportMode); });
100464
100635
  }
100465
100636
  moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
100466
100637
  function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
100467
100638
  if (options === void 0) { options = {}; }
100468
100639
  var info = getInfo(importingSourceFileName, host);
100469
100640
  var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
100470
- return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode); }) ||
100641
+ return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) ||
100471
100642
  getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
100472
100643
  }
100473
100644
  function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
@@ -100533,7 +100704,7 @@ var ts;
100533
100704
  var relativeSpecifiers;
100534
100705
  for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
100535
100706
  var modulePath = modulePaths_1[_i];
100536
- var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, undefined, options.overrideImportMode);
100707
+ var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode);
100537
100708
  nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
100538
100709
  if (specifier && modulePath.isRedirect) {
100539
100710
  return nodeModulesSpecifiers;
@@ -100864,7 +101035,7 @@ var ts;
100864
101035
  ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
100865
101036
  : ts.removeFileExtension(relativePath);
100866
101037
  }
100867
- function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
101038
+ function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
100868
101039
  var path = _a.path, isRedirect = _a.isRedirect;
100869
101040
  var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
100870
101041
  if (!host.fileExists || !host.readFile) {
@@ -100877,8 +101048,9 @@ var ts;
100877
101048
  var moduleSpecifier = path;
100878
101049
  var isPackageRootPath = false;
100879
101050
  if (!packageNameOnly) {
101051
+ var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
100880
101052
  var packageRootIndex = parts.packageRootIndex;
100881
- var moduleFileNameForExtensionless = void 0;
101053
+ var moduleFileName = void 0;
100882
101054
  while (true) {
100883
101055
  var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
100884
101056
  if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
@@ -100894,11 +101066,11 @@ var ts;
100894
101066
  isPackageRootPath = true;
100895
101067
  break;
100896
101068
  }
100897
- if (!moduleFileNameForExtensionless)
100898
- moduleFileNameForExtensionless = moduleFileToTry;
101069
+ if (!moduleFileName)
101070
+ moduleFileName = moduleFileToTry;
100899
101071
  packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
100900
101072
  if (packageRootIndex === -1) {
100901
- moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
101073
+ moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
100902
101074
  break;
100903
101075
  }
100904
101076
  }
@@ -100947,7 +101119,7 @@ var ts;
100947
101119
  moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
100948
101120
  }
100949
101121
  }
100950
- var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
101122
+ var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
100951
101123
  if (ts.isString(mainFileRelative)) {
100952
101124
  var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
100953
101125
  if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
@@ -100955,14 +101127,13 @@ var ts;
100955
101127
  }
100956
101128
  }
100957
101129
  }
100958
- return { moduleFileToTry: moduleFileToTry };
100959
- }
100960
- function getExtensionlessFileName(path) {
100961
- var fullModulePathWithoutExtension = ts.removeFileExtension(path);
100962
- if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
100963
- return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
101130
+ else {
101131
+ var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
101132
+ if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
101133
+ return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
101134
+ }
100964
101135
  }
100965
- return fullModulePathWithoutExtension;
101136
+ return { moduleFileToTry: moduleFileToTry };
100966
101137
  }
100967
101138
  }
100968
101139
  function tryGetAnyFileFromPath(host, path) {
@@ -100983,7 +101154,7 @@ var ts;
100983
101154
  return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
100984
101155
  });
100985
101156
  }
100986
- function removeExtensionAndIndexPostFix(fileName, ending, options) {
101157
+ function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
100987
101158
  if (ts.fileExtensionIsOneOf(fileName, [".json", ".mjs", ".cjs"]))
100988
101159
  return fileName;
100989
101160
  var noExtension = ts.removeFileExtension(fileName);
@@ -100991,7 +101162,11 @@ var ts;
100991
101162
  return noExtension + getJSExtensionForFile(fileName, options);
100992
101163
  switch (ending) {
100993
101164
  case 0:
100994
- return ts.removeSuffix(noExtension, "/index");
101165
+ var withoutIndex = ts.removeSuffix(noExtension, "/index");
101166
+ if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
101167
+ return noExtension;
101168
+ }
101169
+ return withoutIndex;
100995
101170
  case 1:
100996
101171
  return noExtension;
100997
101172
  case 2: