typescript 5.0.0-dev.20230109 → 5.0.0-dev.20230111

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.20230109`;
26
+ var version = `${versionMajorMinor}.0-dev.20230111`;
27
27
 
28
28
  // src/compiler/core.ts
29
29
  var emptyArray = [];
@@ -6763,6 +6763,7 @@ var Diagnostics = {
6763
6763
  Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, 1 /* Error */, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."),
6764
6764
  Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
6765
6765
  Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
6766
+ Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
6766
6767
  Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
6767
6768
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
6768
6769
  Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
@@ -7134,6 +7135,9 @@ var Diagnostics = {
7134
7135
  Found_1_error_in_1: diag(6259, 3 /* Message */, "Found_1_error_in_1_6259", "Found 1 error in {1}"),
7135
7136
  Found_0_errors_in_the_same_file_starting_at_Colon_1: diag(6260, 3 /* Message */, "Found_0_errors_in_the_same_file_starting_at_Colon_1_6260", "Found {0} errors in the same file, starting at: {1}"),
7136
7137
  Found_0_errors_in_1_files: diag(6261, 3 /* Message */, "Found_0_errors_in_1_files_6261", "Found {0} errors in {1} files."),
7138
+ File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
7139
+ Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
7140
+ Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
7137
7141
  Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
7138
7142
  Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
7139
7143
  Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
@@ -14253,13 +14257,13 @@ function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirect
14253
14257
  return removeFileExtension(path) + declarationExtension;
14254
14258
  }
14255
14259
  function getDeclarationEmitExtensionForPath(path) {
14256
- return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.json.d.ts` : (
14260
+ return fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : fileExtensionIsOneOf(path, [".json" /* Json */]) ? `.d.json.ts` : (
14257
14261
  // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
14258
14262
  ".d.ts" /* Dts */
14259
14263
  );
14260
14264
  }
14261
14265
  function getPossibleOriginalInputExtensionForExtension(path) {
14262
- return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.json.d.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
14266
+ return fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : fileExtensionIsOneOf(path, [`.d.json.ts`]) ? [".json" /* Json */] : [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
14263
14267
  }
14264
14268
  function outFile(options) {
14265
14269
  return options.outFile || options.out;
@@ -16132,7 +16136,7 @@ function positionIsSynthesized(pos) {
16132
16136
  return !(pos >= 0);
16133
16137
  }
16134
16138
  function extensionIsTS(ext) {
16135
- return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */;
16139
+ return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */ || startsWith(ext, ".d.") && endsWith(ext, ".ts");
16136
16140
  }
16137
16141
  function resolutionExtensionIsTSOrJson(ext) {
16138
16142
  return extensionIsTS(ext) || ext === ".json" /* Json */;
@@ -16634,6 +16638,10 @@ function isOptionalDeclaration(declaration) {
16634
16638
  return false;
16635
16639
  }
16636
16640
  }
16641
+ function isNonNullAccess(node) {
16642
+ const kind = node.kind;
16643
+ return (kind === 208 /* PropertyAccessExpression */ || kind === 209 /* ElementAccessExpression */) && isNonNullExpression(node.expression);
16644
+ }
16637
16645
 
16638
16646
  // src/compiler/factory/baseNodeFactory.ts
16639
16647
  function createBaseNodeFactory() {
@@ -23212,6 +23220,9 @@ function isTypeOfExpression(node) {
23212
23220
  function isVoidExpression(node) {
23213
23221
  return node.kind === 219 /* VoidExpression */;
23214
23222
  }
23223
+ function isAwaitExpression(node) {
23224
+ return node.kind === 220 /* AwaitExpression */;
23225
+ }
23215
23226
  function isPrefixUnaryExpression(node) {
23216
23227
  return node.kind === 221 /* PrefixUnaryExpression */;
23217
23228
  }
@@ -28360,7 +28371,7 @@ var Parser;
28360
28371
  const pos = getNodePos();
28361
28372
  return finishNode(factory2.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
28362
28373
  }
28363
- function isAwaitExpression() {
28374
+ function isAwaitExpression2() {
28364
28375
  if (token() === 133 /* AwaitKeyword */) {
28365
28376
  if (inAwaitContext()) {
28366
28377
  return true;
@@ -28408,7 +28419,7 @@ var Parser;
28408
28419
  case 29 /* LessThanToken */:
28409
28420
  return parseTypeAssertion();
28410
28421
  case 133 /* AwaitKeyword */:
28411
- if (isAwaitExpression()) {
28422
+ if (isAwaitExpression2()) {
28412
28423
  return parseAwaitExpression();
28413
28424
  }
28414
28425
  default:
@@ -32071,7 +32082,7 @@ var IncrementalParser;
32071
32082
  })(InvalidPosition || (InvalidPosition = {}));
32072
32083
  })(IncrementalParser || (IncrementalParser = {}));
32073
32084
  function isDeclarationFileName(fileName) {
32074
- return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions);
32085
+ return fileExtensionIsOneOf(fileName, supportedDeclarationExtensions) || fileExtensionIs(fileName, ".ts" /* Ts */) && stringContains(getBaseFileName(fileName), ".d.");
32075
32086
  }
32076
32087
  function parseResolutionMode(mode, pos, end, reportDiagnostic) {
32077
32088
  if (!mode) {
@@ -33329,6 +33340,14 @@ var commandOptionsWithoutBuild = [
33329
33340
  description: Diagnostics.Enable_importing_json_files,
33330
33341
  defaultValueDescription: false
33331
33342
  },
33343
+ {
33344
+ name: "allowArbitraryExtensions",
33345
+ type: "boolean",
33346
+ affectsModuleResolution: true,
33347
+ category: Diagnostics.Modules,
33348
+ description: Diagnostics.Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present,
33349
+ defaultValueDescription: false
33350
+ },
33332
33351
  {
33333
33352
  name: "out",
33334
33353
  type: "string",
@@ -35758,7 +35777,8 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
35758
35777
  conditions,
35759
35778
  requestContainingDirectory: containingDirectory,
35760
35779
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
35761
- isConfigLookup: false
35780
+ isConfigLookup: false,
35781
+ candidateIsFromPackageJsonField: false
35762
35782
  };
35763
35783
  let resolved = primaryLookup();
35764
35784
  let primary = true;
@@ -36604,7 +36624,8 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
36604
36624
  conditions,
36605
36625
  requestContainingDirectory: containingDirectory,
36606
36626
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
36607
- isConfigLookup
36627
+ isConfigLookup,
36628
+ candidateIsFromPackageJsonField: false
36608
36629
  };
36609
36630
  if (traceEnabled && getEmitModuleResolutionKind(compilerOptions) >= 3 /* Node16 */ && getEmitModuleResolutionKind(compilerOptions) <= 99 /* NodeNext */) {
36610
36631
  trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & 32 /* EsmMode */ ? "ESM" : "CJS", conditions.map((c) => `'${c}'`).join(", "));
@@ -36772,14 +36793,19 @@ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
36772
36793
  }
36773
36794
  }
36774
36795
  function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
36775
- if (hasJSFileExtension(candidate) || extensions & 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */) || extensions & (1 /* TypeScript */ | 4 /* Declaration */) && moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) {
36776
- const extensionless = removeFileExtension(candidate);
36777
- const extension = candidate.substring(extensionless.length);
36778
- if (state.traceEnabled) {
36779
- trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
36780
- }
36781
- return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
36796
+ const filename = getBaseFileName(candidate);
36797
+ if (filename.indexOf(".") === -1) {
36798
+ return void 0;
36799
+ }
36800
+ let extensionless = removeFileExtension(candidate);
36801
+ if (extensionless === candidate) {
36802
+ extensionless = candidate.substring(0, candidate.lastIndexOf("."));
36782
36803
  }
36804
+ const extension = candidate.substring(extensionless.length);
36805
+ if (state.traceEnabled) {
36806
+ trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
36807
+ }
36808
+ return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
36783
36809
  }
36784
36810
  function loadFileNameFromPackageJsonField(extensions, candidate, onlyRecordFailures, state) {
36785
36811
  if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
@@ -36803,42 +36829,27 @@ function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecor
36803
36829
  case ".mjs" /* Mjs */:
36804
36830
  case ".mts" /* Mts */:
36805
36831
  case ".d.mts" /* Dmts */:
36806
- return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
36832
+ return extensions & 1 /* TypeScript */ && tryExtension(".mts" /* Mts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 4 /* Declaration */ && tryExtension(".d.mts" /* Dmts */, originalExtension === ".mts" /* Mts */ || originalExtension === ".d.mts" /* Dmts */) || extensions & 2 /* JavaScript */ && tryExtension(".mjs" /* Mjs */) || void 0;
36807
36833
  case ".cjs" /* Cjs */:
36808
36834
  case ".cts" /* Cts */:
36809
36835
  case ".d.cts" /* Dcts */:
36810
- return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
36836
+ return extensions & 1 /* TypeScript */ && tryExtension(".cts" /* Cts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 4 /* Declaration */ && tryExtension(".d.cts" /* Dcts */, originalExtension === ".cts" /* Cts */ || originalExtension === ".d.cts" /* Dcts */) || extensions & 2 /* JavaScript */ && tryExtension(".cjs" /* Cjs */) || void 0;
36811
36837
  case ".json" /* Json */:
36812
- const originalCandidate = candidate;
36813
- if (extensions & 4 /* Declaration */) {
36814
- candidate += ".json" /* Json */;
36815
- const result = tryExtension(".d.ts" /* Dts */);
36816
- if (result)
36817
- return result;
36818
- }
36819
- if (extensions & 8 /* Json */) {
36820
- candidate = originalCandidate;
36821
- const result = tryExtension(".json" /* Json */);
36822
- if (result)
36823
- return result;
36824
- }
36825
- return void 0;
36826
- case ".ts" /* Ts */:
36838
+ return extensions & 4 /* Declaration */ && tryExtension(".d.json.ts") || extensions & 8 /* Json */ && tryExtension(".json" /* Json */) || void 0;
36827
36839
  case ".tsx" /* Tsx */:
36840
+ case ".jsx" /* Jsx */:
36841
+ return extensions & 1 /* TypeScript */ && (tryExtension(".tsx" /* Tsx */, originalExtension === ".tsx" /* Tsx */) || tryExtension(".ts" /* Ts */, originalExtension === ".tsx" /* Tsx */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".tsx" /* Tsx */) || extensions & 2 /* JavaScript */ && (tryExtension(".jsx" /* Jsx */) || tryExtension(".js" /* Js */)) || void 0;
36842
+ case ".ts" /* Ts */:
36828
36843
  case ".d.ts" /* Dts */:
36829
- if (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && extensionIsOk(extensions, originalExtension)) {
36830
- return tryExtension(
36831
- originalExtension,
36832
- /*resolvedUsingTsExtension*/
36833
- true
36834
- );
36835
- }
36844
+ case ".js" /* Js */:
36845
+ case "":
36846
+ return extensions & 1 /* TypeScript */ && (tryExtension(".ts" /* Ts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || tryExtension(".tsx" /* Tsx */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */)) || extensions & 4 /* Declaration */ && tryExtension(".d.ts" /* Dts */, originalExtension === ".ts" /* Ts */ || originalExtension === ".d.ts" /* Dts */) || extensions & 2 /* JavaScript */ && (tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */)) || state.isConfigLookup && tryExtension(".json" /* Json */) || void 0;
36836
36847
  default:
36837
- 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;
36848
+ return extensions & 4 /* Declaration */ && !isDeclarationFileName(candidate + originalExtension) && tryExtension(`.d${originalExtension}.ts`) || void 0;
36838
36849
  }
36839
36850
  function tryExtension(ext, resolvedUsingTsExtension) {
36840
36851
  const path = tryFile(candidate + ext, onlyRecordFailures, state);
36841
- return path === void 0 ? void 0 : { path, ext, resolvedUsingTsExtension };
36852
+ return path === void 0 ? void 0 : { path, ext, resolvedUsingTsExtension: !state.candidateIsFromPackageJsonField && resolvedUsingTsExtension };
36842
36853
  }
36843
36854
  }
36844
36855
  function tryFile(fileName, onlyRecordFailures, state) {
@@ -36884,7 +36895,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
36884
36895
  conditions: emptyArray,
36885
36896
  requestContainingDirectory: void 0,
36886
36897
  reportDiagnostic: noop,
36887
- isConfigLookup: false
36898
+ isConfigLookup: false,
36899
+ candidateIsFromPackageJsonField: false
36888
36900
  };
36889
36901
  }
36890
36902
  function getPackageScopeForPath(fileName, state) {
@@ -36972,6 +36984,8 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
36972
36984
  }
36973
36985
  const expandedExtensions = extensions2 === 4 /* Declaration */ ? 1 /* TypeScript */ | 4 /* Declaration */ : extensions2;
36974
36986
  const features = state2.features;
36987
+ const candidateIsFromPackageJsonField = state2.candidateIsFromPackageJsonField;
36988
+ state2.candidateIsFromPackageJsonField = true;
36975
36989
  if ((jsonContent == null ? void 0 : jsonContent.type) !== "module") {
36976
36990
  state2.features &= ~32 /* EsmMode */;
36977
36991
  }
@@ -36984,6 +36998,7 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
36984
36998
  false
36985
36999
  );
36986
37000
  state2.features = features;
37001
+ state2.candidateIsFromPackageJsonField = candidateIsFromPackageJsonField;
36987
37002
  return result;
36988
37003
  };
36989
37004
  const onlyRecordFailuresForPackageFile = packageFile ? !directoryProbablyExists(getDirectoryPath(packageFile), state.host) : void 0;
@@ -37057,7 +37072,10 @@ function loadModuleFromSelfNameReference(extensions, moduleName, directory, stat
37057
37072
  return void 0;
37058
37073
  }
37059
37074
  const trailingParts = parts.slice(nameParts.length);
37060
- return loadModuleFromExports(scope, extensions, !length(trailingParts) ? "." : `.${directorySeparator}${trailingParts.join(directorySeparator)}`, state, cache, redirectedReference);
37075
+ const subpath = !length(trailingParts) ? "." : `.${directorySeparator}${trailingParts.join(directorySeparator)}`;
37076
+ const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
37077
+ const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
37078
+ return loadModuleFromExports(scope, priorityExtensions, subpath, state, cache, redirectedReference) || loadModuleFromExports(scope, secondaryExtensions, subpath, state, cache, redirectedReference);
37061
37079
  }
37062
37080
  function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
37063
37081
  if (!scope.contents.packageJsonContent.exports) {
@@ -37559,25 +37577,26 @@ function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, dir
37559
37577
  }
37560
37578
  }
37561
37579
  function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
37562
- var _a2;
37580
+ var _a2, _b, _c;
37563
37581
  const candidate = normalizePath(combinePaths(nodeModulesDirectory, moduleName));
37582
+ const { packageName, rest } = parsePackageName(moduleName);
37583
+ const packageDirectory = combinePaths(nodeModulesDirectory, packageName);
37584
+ let rootPackageInfo;
37564
37585
  let packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
37565
- if (!(state.features & 8 /* Exports */)) {
37566
- if (packageInfo) {
37567
- const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
37568
- if (fromFile) {
37569
- return noPackageId(fromFile);
37570
- }
37571
- const fromDirectory = loadNodeModuleFromDirectoryWorker(
37572
- extensions,
37573
- candidate,
37574
- !nodeModulesDirectoryExists,
37575
- state,
37576
- packageInfo.contents.packageJsonContent,
37577
- getVersionPathsOfPackageJsonInfo(packageInfo, state)
37578
- );
37579
- return withPackageId(packageInfo, fromDirectory);
37586
+ if (rest !== "" && packageInfo && (!(state.features & 8 /* Exports */) || !hasProperty((_b = (_a2 = rootPackageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state)) == null ? void 0 : _a2.contents.packageJsonContent) != null ? _b : emptyArray, "exports"))) {
37587
+ const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
37588
+ if (fromFile) {
37589
+ return noPackageId(fromFile);
37580
37590
  }
37591
+ const fromDirectory = loadNodeModuleFromDirectoryWorker(
37592
+ extensions,
37593
+ candidate,
37594
+ !nodeModulesDirectoryExists,
37595
+ state,
37596
+ packageInfo.contents.packageJsonContent,
37597
+ getVersionPathsOfPackageJsonInfo(packageInfo, state)
37598
+ );
37599
+ return withPackageId(packageInfo, fromDirectory);
37581
37600
  }
37582
37601
  const loader = (extensions2, candidate2, onlyRecordFailures, state2) => {
37583
37602
  let pathAndExtension = loadModuleFromFile(extensions2, candidate2, onlyRecordFailures, state2) || loadNodeModuleFromDirectoryWorker(
@@ -37593,13 +37612,11 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, node
37593
37612
  }
37594
37613
  return withPackageId(packageInfo, pathAndExtension);
37595
37614
  };
37596
- const { packageName, rest } = parsePackageName(moduleName);
37597
- const packageDirectory = combinePaths(nodeModulesDirectory, packageName);
37598
37615
  if (rest !== "") {
37599
- packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
37616
+ packageInfo = rootPackageInfo != null ? rootPackageInfo : getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
37600
37617
  }
37601
37618
  if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & 8 /* Exports */) {
37602
- return (_a2 = loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)) == null ? void 0 : _a2.value;
37619
+ return (_c = loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)) == null ? void 0 : _c.value;
37603
37620
  }
37604
37621
  const versionPaths = rest !== "" && packageInfo ? getVersionPathsOfPackageJsonInfo(packageInfo, state) : void 0;
37605
37622
  if (versionPaths) {
@@ -37716,7 +37733,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
37716
37733
  conditions: [],
37717
37734
  requestContainingDirectory: containingDirectory,
37718
37735
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
37719
- isConfigLookup: false
37736
+ isConfigLookup: false,
37737
+ candidateIsFromPackageJsonField: false
37720
37738
  };
37721
37739
  const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
37722
37740
  return createResolvedModuleWithFailedLookupLocations(
@@ -37773,11 +37791,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
37773
37791
  }
37774
37792
  }
37775
37793
  }
37776
- function moduleResolutionSupportsResolvingTsExtensions(compilerOptions) {
37777
- return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */;
37778
- }
37779
37794
  function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
37780
- return moduleResolutionSupportsResolvingTsExtensions(compilerOptions) && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
37795
+ return getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && (!!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName));
37781
37796
  }
37782
37797
  function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) {
37783
37798
  const traceEnabled = isTraceEnabled(compilerOptions, host);
@@ -37798,7 +37813,8 @@ function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, hos
37798
37813
  conditions: [],
37799
37814
  requestContainingDirectory: void 0,
37800
37815
  reportDiagnostic: (diag2) => void diagnostics.push(diag2),
37801
- isConfigLookup: false
37816
+ isConfigLookup: false,
37817
+ candidateIsFromPackageJsonField: false
37802
37818
  };
37803
37819
  const resolved = loadModuleFromImmediateNodeModulesDirectory(
37804
37820
  4 /* Declaration */,
@@ -41467,6 +41483,8 @@ function processEnding(fileName, allowedEndings, options, host) {
41467
41483
  }
41468
41484
  if (fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) {
41469
41485
  return noExtension + getJSExtensionForFile(fileName, options);
41486
+ } else if (!fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */]) && fileExtensionIsOneOf(fileName, [".ts" /* Ts */]) && stringContains(fileName, ".d.")) {
41487
+ return tryGetRealFileNameForNonJsDeclarationFileName(fileName);
41470
41488
  }
41471
41489
  switch (allowedEndings[0]) {
41472
41490
  case 0 /* Minimal */:
@@ -41490,6 +41508,14 @@ function processEnding(fileName, allowedEndings, options, host) {
41490
41508
  return Debug.assertNever(allowedEndings[0]);
41491
41509
  }
41492
41510
  }
41511
+ function tryGetRealFileNameForNonJsDeclarationFileName(fileName) {
41512
+ const baseName = getBaseFileName(fileName);
41513
+ if (!endsWith(fileName, ".ts" /* Ts */) || !stringContains(baseName, ".d.") || fileExtensionIsOneOf(baseName, [".d.ts" /* Dts */]))
41514
+ return void 0;
41515
+ const noExtension = removeExtension(fileName, ".ts" /* Ts */);
41516
+ const ext = noExtension.substring(noExtension.lastIndexOf("."));
41517
+ return noExtension.substring(0, noExtension.indexOf(".d.")) + ext;
41518
+ }
41493
41519
  function getJSExtensionForFile(fileName, options) {
41494
41520
  var _a2;
41495
41521
  return (_a2 = tryGetJSExtensionForFile(fileName, options)) != null ? _a2 : Debug.fail(`Extension ${extensionFromPath(fileName)} is unsupported:: FileName:: ${fileName}`);
@@ -43915,7 +43941,7 @@ function createTypeChecker(host) {
43915
43941
  const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
43916
43942
  const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
43917
43943
  if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
43918
- if (hasExportAssignmentSymbol(moduleSymbol)) {
43944
+ if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions))) {
43919
43945
  const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
43920
43946
  const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
43921
43947
  const exportAssignment = exportEqualsSymbol.valueDeclaration;
@@ -44710,7 +44736,7 @@ function createTypeChecker(host) {
44710
44736
  const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
44711
44737
  const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
44712
44738
  const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode);
44713
- const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
44739
+ const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
44714
44740
  const sourceFile = resolvedModule && (!resolutionDiagnostic || resolutionDiagnostic === Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set) && host.getSourceFile(resolvedModule.resolvedFileName);
44715
44741
  if (sourceFile) {
44716
44742
  if (resolutionDiagnostic) {
@@ -48664,7 +48690,9 @@ function createTypeChecker(host) {
48664
48690
  case 267 /* NamespaceExportDeclaration */:
48665
48691
  addResult(factory.createNamespaceExportDeclaration(idText(node.name)), 0 /* None */);
48666
48692
  break;
48667
- case 270 /* ImportClause */:
48693
+ case 270 /* ImportClause */: {
48694
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
48695
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
48668
48696
  addResult(factory.createImportDeclaration(
48669
48697
  /*modifiers*/
48670
48698
  void 0,
@@ -48675,15 +48703,14 @@ function createTypeChecker(host) {
48675
48703
  /*namedBindings*/
48676
48704
  void 0
48677
48705
  ),
48678
- // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned
48679
- // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag
48680
- // In such cases, the `target` refers to the module itself already
48681
- factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
48682
- /*assertClause*/
48683
- void 0
48706
+ specifier2,
48707
+ node.parent.assertClause
48684
48708
  ), 0 /* None */);
48685
48709
  break;
48686
- case 271 /* NamespaceImport */:
48710
+ }
48711
+ case 271 /* NamespaceImport */: {
48712
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
48713
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
48687
48714
  addResult(factory.createImportDeclaration(
48688
48715
  /*modifiers*/
48689
48716
  void 0,
@@ -48694,11 +48721,11 @@ function createTypeChecker(host) {
48694
48721
  void 0,
48695
48722
  factory.createNamespaceImport(factory.createIdentifier(localName))
48696
48723
  ),
48697
- factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)),
48698
- /*assertClause*/
48699
- void 0
48724
+ specifier2,
48725
+ node.parent.parent.assertClause
48700
48726
  ), 0 /* None */);
48701
48727
  break;
48728
+ }
48702
48729
  case 277 /* NamespaceExport */:
48703
48730
  addResult(factory.createExportDeclaration(
48704
48731
  /*modifiers*/
@@ -48709,7 +48736,9 @@ function createTypeChecker(host) {
48709
48736
  factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))
48710
48737
  ), 0 /* None */);
48711
48738
  break;
48712
- case 273 /* ImportSpecifier */:
48739
+ case 273 /* ImportSpecifier */: {
48740
+ const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
48741
+ const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
48713
48742
  addResult(factory.createImportDeclaration(
48714
48743
  /*modifiers*/
48715
48744
  void 0,
@@ -48727,11 +48756,11 @@ function createTypeChecker(host) {
48727
48756
  )
48728
48757
  ])
48729
48758
  ),
48730
- factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
48731
- /*assertClause*/
48732
- void 0
48759
+ specifier2,
48760
+ node.parent.parent.parent.assertClause
48733
48761
  ), 0 /* None */);
48734
48762
  break;
48763
+ }
48735
48764
  case 278 /* ExportSpecifier */:
48736
48765
  const specifier = node.parent.parent.moduleSpecifier;
48737
48766
  serializeExportSpecifier(
@@ -50701,7 +50730,17 @@ function createTypeChecker(host) {
50701
50730
  }
50702
50731
  }
50703
50732
  function getOuterTypeParametersOfClassOrInterface(symbol) {
50704
- const declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : getDeclarationOfKind(symbol, 261 /* InterfaceDeclaration */);
50733
+ var _a2;
50734
+ const declaration = symbol.flags & 32 /* Class */ || symbol.flags & 16 /* Function */ ? symbol.valueDeclaration : (_a2 = symbol.declarations) == null ? void 0 : _a2.find((decl) => {
50735
+ if (decl.kind === 261 /* InterfaceDeclaration */) {
50736
+ return true;
50737
+ }
50738
+ if (decl.kind !== 257 /* VariableDeclaration */) {
50739
+ return false;
50740
+ }
50741
+ const initializer = decl.initializer;
50742
+ return !!initializer && (initializer.kind === 215 /* FunctionExpression */ || initializer.kind === 216 /* ArrowFunction */);
50743
+ });
50705
50744
  Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
50706
50745
  return getOuterTypeParameters(declaration);
50707
50746
  }
@@ -62046,7 +62085,7 @@ function createTypeChecker(host) {
62046
62085
  if (signature) {
62047
62086
  const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : void 0;
62048
62087
  if (inference.contraCandidates) {
62049
- const useCovariantType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other === inference || getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeSubtypeOf(t, inferredCovariantType)));
62088
+ const useCovariantType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeSubtypeOf(t, inferredCovariantType)));
62050
62089
  inferredType = useCovariantType ? inferredCovariantType : getContravariantInference(inference);
62051
62090
  } else if (inferredCovariantType) {
62052
62091
  inferredType = inferredCovariantType;
@@ -63522,12 +63561,13 @@ function createTypeChecker(host) {
63522
63561
  if (propName === void 0) {
63523
63562
  return type;
63524
63563
  }
63525
- const removeNullable = strictNullChecks && isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */);
63564
+ const optionalChain = isOptionalChain(access);
63565
+ const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 98304 /* Nullable */);
63526
63566
  let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
63527
63567
  if (!propType) {
63528
63568
  return type;
63529
63569
  }
63530
- propType = removeNullable ? getOptionalType(propType) : propType;
63570
+ propType = removeNullable && optionalChain ? getOptionalType(propType) : propType;
63531
63571
  const narrowedPropType = narrowType2(propType);
63532
63572
  return filterType(type, (t) => {
63533
63573
  const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
@@ -71385,7 +71425,7 @@ function createTypeChecker(host) {
71385
71425
  return getRegularTypeOfObjectLiteral(rightType);
71386
71426
  }
71387
71427
  case 27 /* CommaToken */:
71388
- if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
71428
+ if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isIndirectCall(left.parent)) {
71389
71429
  const sf = getSourceFileOfNode(left);
71390
71430
  const sourceText = sf.text;
71391
71431
  const start = skipTrivia(sourceText, left.pos);
@@ -71427,8 +71467,8 @@ function createTypeChecker(host) {
71427
71467
  }
71428
71468
  }
71429
71469
  }
71430
- function isEvalNode(node) {
71431
- return node.kind === 79 /* Identifier */ && node.escapedText === "eval";
71470
+ function isIndirectCall(node) {
71471
+ return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && (isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
71432
71472
  }
71433
71473
  function checkForDisallowedESSymbolOperand(operator2) {
71434
71474
  const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
@@ -71992,15 +72032,16 @@ function createTypeChecker(host) {
71992
72032
  }
71993
72033
  }
71994
72034
  expr = skipParentheses(node);
72035
+ if (isAwaitExpression(expr)) {
72036
+ const type = getQuickTypeOfExpression(expr.expression);
72037
+ return type ? getAwaitedType(type) : void 0;
72038
+ }
71995
72039
  if (isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !isRequireCall(
71996
72040
  expr,
71997
72041
  /*checkArgumentIsStringLiteralLike*/
71998
72042
  true
71999
72043
  ) && !isSymbolOrSymbolForCall(expr)) {
72000
- const type = isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
72001
- if (type) {
72002
- return type;
72003
- }
72044
+ return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
72004
72045
  } else if (isAssertionExpression(expr) && !isConstTypeReference(expr.type)) {
72005
72046
  return getTypeFromTypeNode(expr.type);
72006
72047
  } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) {
@@ -77167,12 +77208,12 @@ function createTypeChecker(host) {
77167
77208
  if (node.flags & 16777216 /* Ambient */ && !isEntityNameExpression(node.expression)) {
77168
77209
  grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
77169
77210
  }
77170
- if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
77171
- if (moduleKind >= 5 /* ES2015 */ && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */) {
77211
+ if (node.isExportEquals) {
77212
+ if (moduleKind >= 5 /* ES2015 */ && (node.flags & 16777216 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 16777216 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
77172
77213
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
77173
- } else if (moduleKind === 4 /* System */) {
77214
+ } else if (moduleKind === 4 /* System */ && !(node.flags & 16777216 /* Ambient */)) {
77174
77215
  grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
77175
- } else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */) {
77216
+ } else if (getEmitModuleResolutionKind(compilerOptions) === 100 /* Bundler */ && !(node.flags & 16777216 /* Ambient */)) {
77176
77217
  grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_bundler_Consider_using_export_default_or_another_module_format_instead);
77177
77218
  }
77178
77219
  }
@@ -99950,6 +99991,9 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) {
99950
99991
  case 259 /* FunctionDeclaration */:
99951
99992
  diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
99952
99993
  break;
99994
+ case 192 /* InferType */:
99995
+ diagnosticMessage = Diagnostics.Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1;
99996
+ break;
99953
99997
  case 262 /* TypeAliasDeclaration */:
99954
99998
  diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
99955
99999
  break;
@@ -110690,7 +110734,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
110690
110734
  currentNodeModulesDepth++;
110691
110735
  }
110692
110736
  const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
110693
- const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
110737
+ const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(optionsForFile, resolution, file) && !optionsForFile.noResolve && index < file.imports.length && !elideImport && !(isJsFile && !getAllowJSCompilerOption(optionsForFile)) && (isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
110694
110738
  if (elideImport) {
110695
110739
  modulesWithElidedImports.set(file.path, true);
110696
110740
  } else if (shouldAddFile) {
@@ -111033,7 +111077,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
111033
111077
  if (options.preserveValueImports && getEmitModuleKind(options) < 5 /* ES2015 */) {
111034
111078
  createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later);
111035
111079
  }
111036
- if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) {
111080
+ if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly)) {
111037
111081
  createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_bundler_and_either_noEmit_or_emitDeclarationOnly_is_set);
111038
111082
  }
111039
111083
  const moduleResolution = getEmitModuleResolutionKind(options);
@@ -111685,19 +111729,27 @@ function resolveProjectReferencePath(hostOrRef, ref) {
111685
111729
  const passedInRef = ref ? ref : hostOrRef;
111686
111730
  return resolveConfigFileProjectName(passedInRef.path);
111687
111731
  }
111688
- function getResolutionDiagnostic(options, { extension }) {
111732
+ function getResolutionDiagnostic(options, { extension }, { isDeclarationFile }) {
111689
111733
  switch (extension) {
111690
111734
  case ".ts" /* Ts */:
111691
111735
  case ".d.ts" /* Dts */:
111736
+ case ".mts" /* Mts */:
111737
+ case ".d.mts" /* Dmts */:
111738
+ case ".cts" /* Cts */:
111739
+ case ".d.cts" /* Dcts */:
111692
111740
  return void 0;
111693
111741
  case ".tsx" /* Tsx */:
111694
111742
  return needJsx();
111695
111743
  case ".jsx" /* Jsx */:
111696
111744
  return needJsx() || needAllowJs();
111697
111745
  case ".js" /* Js */:
111746
+ case ".mjs" /* Mjs */:
111747
+ case ".cjs" /* Cjs */:
111698
111748
  return needAllowJs();
111699
111749
  case ".json" /* Json */:
111700
111750
  return needResolveJsonModule();
111751
+ default:
111752
+ return needAllowArbitraryExtensions();
111701
111753
  }
111702
111754
  function needJsx() {
111703
111755
  return options.jsx ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
@@ -111708,6 +111760,9 @@ function getResolutionDiagnostic(options, { extension }) {
111708
111760
  function needResolveJsonModule() {
111709
111761
  return getResolveJsonModule(options) ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
111710
111762
  }
111763
+ function needAllowArbitraryExtensions() {
111764
+ return isDeclarationFile || options.allowArbitraryExtensions ? void 0 : Diagnostics.Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set;
111765
+ }
111711
111766
  }
111712
111767
  function getModuleNames({ imports, moduleAugmentations }) {
111713
111768
  const res = imports.map((i) => i);