typescript 5.7.0-dev.20240927 → 5.7.0-dev.20240928

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.7";
21
- var version = `${versionMajorMinor}.0-dev.20240927`;
21
+ var version = `${versionMajorMinor}.0-dev.20240928`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3885,10 +3885,10 @@ var LanguageFeatureMinimumTarget = {
3885
3885
  ClassFields: 9 /* ES2022 */,
3886
3886
  PrivateNamesAndClassStaticBlocks: 9 /* ES2022 */,
3887
3887
  RegularExpressionFlagsHasIndices: 9 /* ES2022 */,
3888
- ShebangComments: 99 /* ESNext */,
3888
+ ShebangComments: 10 /* ES2023 */,
3889
+ RegularExpressionFlagsUnicodeSets: 11 /* ES2024 */,
3889
3890
  UsingAndAwaitUsing: 99 /* ESNext */,
3890
- ClassAndClassElementDecorators: 99 /* ESNext */,
3891
- RegularExpressionFlagsUnicodeSets: 99 /* ESNext */
3891
+ ClassAndClassElementDecorators: 99 /* ESNext */
3892
3892
  };
3893
3893
  var commentPragmas = {
3894
3894
  "reference": {
@@ -6736,6 +6736,10 @@ var Diagnostics = {
6736
6736
  This_kind_of_expression_is_always_falsy: diag(2873, 1 /* Error */, "This_kind_of_expression_is_always_falsy_2873", "This kind of expression is always falsy."),
6737
6737
  This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found: diag(2874, 1 /* Error */, "This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found_2874", "This JSX tag requires '{0}' to be in scope, but it could not be found."),
6738
6738
  This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_for_the_appropriate_package_installed: diag(2875, 1 /* Error */, "This_JSX_tag_requires_the_module_path_0_to_exist_but_none_could_be_found_Make_sure_you_have_types_fo_2875", "This JSX tag requires the module path '{0}' to exist, but none could be found. Make sure you have types for the appropriate package installed."),
6739
+ This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolves_to_0: diag(2876, 1 /* Error */, "This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolv_2876", 'This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "{0}".'),
6740
+ This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_during_emit_because_it_is_not_a_relative_path: diag(2877, 1 /* Error */, "This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_duri_2877", "This import uses a '{0}' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path."),
6741
+ This_import_path_is_unsafe_to_rewrite_because_it_resolves_to_another_project_and_the_relative_path_between_the_projects_output_files_is_not_the_same_as_the_relative_path_between_its_input_files: diag(2878, 1 /* Error */, "This_import_path_is_unsafe_to_rewrite_because_it_resolves_to_another_project_and_the_relative_path_b_2878", "This import path is unsafe to rewrite because it resolves to another project, and the relative path between the projects' output files is not the same as the relative path between its input files."),
6742
+ Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found: diag(2879, 1 /* Error */, "Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found_2879", "Using JSX fragments requires fragment factory '{0}' to be in scope, but it could not be found."),
6739
6743
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6740
6744
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6741
6745
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -7292,6 +7296,7 @@ var Diagnostics = {
7292
7296
  Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0: diag(6418, 3 /* Message */, "Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0_6418", "Searching all ancestor node_modules directories for fallback extensions: {0}."),
7293
7297
  Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors: diag(6419, 3 /* Message */, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_program_needs_to_report_errors_6419", "Project '{0}' is out of date because buildinfo file '{1}' indicates that program needs to report errors."),
7294
7298
  Project_0_is_out_of_date_because_1: diag(6420, 3 /* Message */, "Project_0_is_out_of_date_because_1_6420", "Project '{0}' is out of date because {1}."),
7299
+ Rewrite_ts_tsx_mts_and_cts_file_extensions_in_relative_import_paths_to_their_JavaScript_equivalent_in_output_files: diag(6421, 3 /* Message */, "Rewrite_ts_tsx_mts_and_cts_file_extensions_in_relative_import_paths_to_their_JavaScript_equivalent_i_6421", "Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files."),
7295
7300
  The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, 3 /* Message */, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
7296
7301
  The_expected_type_comes_from_this_index_signature: diag(6501, 3 /* Message */, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
7297
7302
  The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, 3 /* Message */, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
@@ -11817,6 +11822,9 @@ function isTypeOnlyExportDeclaration(node) {
11817
11822
  function isTypeOnlyImportOrExportDeclaration(node) {
11818
11823
  return isTypeOnlyImportDeclaration(node) || isTypeOnlyExportDeclaration(node);
11819
11824
  }
11825
+ function isPartOfTypeOnlyImportOrExportDeclaration(node) {
11826
+ return findAncestor(node, isTypeOnlyImportOrExportDeclaration) !== void 0;
11827
+ }
11820
11828
  function isImportAttributeName(node) {
11821
11829
  return isStringLiteral(node) || isIdentifier(node);
11822
11830
  }
@@ -12074,13 +12082,16 @@ function isCallLikeOrFunctionLikeExpression(node) {
12074
12082
  }
12075
12083
  function isCallLikeExpression(node) {
12076
12084
  switch (node.kind) {
12077
- case 286 /* JsxOpeningElement */:
12078
- case 285 /* JsxSelfClosingElement */:
12079
12085
  case 213 /* CallExpression */:
12080
12086
  case 214 /* NewExpression */:
12081
12087
  case 215 /* TaggedTemplateExpression */:
12082
12088
  case 170 /* Decorator */:
12089
+ case 286 /* JsxOpeningElement */:
12090
+ case 285 /* JsxSelfClosingElement */:
12091
+ case 289 /* JsxOpeningFragment */:
12083
12092
  return true;
12093
+ case 226 /* BinaryExpression */:
12094
+ return node.operatorToken.kind === 104 /* InstanceOfKeyword */;
12084
12095
  default:
12085
12096
  return false;
12086
12097
  }
@@ -12402,6 +12413,10 @@ function isJsxOpeningLikeElement(node) {
12402
12413
  const kind = node.kind;
12403
12414
  return kind === 286 /* JsxOpeningElement */ || kind === 285 /* JsxSelfClosingElement */;
12404
12415
  }
12416
+ function isJsxCallLike(node) {
12417
+ const kind = node.kind;
12418
+ return kind === 286 /* JsxOpeningElement */ || kind === 285 /* JsxSelfClosingElement */ || kind === 289 /* JsxOpeningFragment */;
12419
+ }
12405
12420
  function isCaseOrDefaultClause(node) {
12406
12421
  const kind = node.kind;
12407
12422
  return kind === 296 /* CaseClause */ || kind === 297 /* DefaultClause */;
@@ -12990,11 +13005,45 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
12990
13005
  AsyncIterator: new Map(Object.entries({
12991
13006
  es2015: emptyArray
12992
13007
  })),
13008
+ ArrayBuffer: new Map(Object.entries({
13009
+ es2024: [
13010
+ "maxByteLength",
13011
+ "resizable",
13012
+ "resize",
13013
+ "detached",
13014
+ "transfer",
13015
+ "transferToFixedLength"
13016
+ ]
13017
+ })),
12993
13018
  Atomics: new Map(Object.entries({
12994
- es2017: emptyArray
13019
+ es2017: [
13020
+ "add",
13021
+ "and",
13022
+ "compareExchange",
13023
+ "exchange",
13024
+ "isLockFree",
13025
+ "load",
13026
+ "or",
13027
+ "store",
13028
+ "sub",
13029
+ "wait",
13030
+ "notify",
13031
+ "xor"
13032
+ ],
13033
+ es2024: [
13034
+ "waitAsync"
13035
+ ]
12995
13036
  })),
12996
13037
  SharedArrayBuffer: new Map(Object.entries({
12997
- es2017: emptyArray
13038
+ es2017: [
13039
+ "byteLength",
13040
+ "slice"
13041
+ ],
13042
+ es2024: [
13043
+ "growable",
13044
+ "maxByteLength",
13045
+ "grow"
13046
+ ]
12998
13047
  })),
12999
13048
  AsyncIterable: new Map(Object.entries({
13000
13049
  es2018: emptyArray
@@ -13016,6 +13065,9 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13016
13065
  ],
13017
13066
  es2018: [
13018
13067
  "dotAll"
13068
+ ],
13069
+ es2024: [
13070
+ "unicodeSets"
13019
13071
  ]
13020
13072
  })),
13021
13073
  Reflect: new Map(Object.entries({
@@ -13062,6 +13114,9 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13062
13114
  ],
13063
13115
  es2022: [
13064
13116
  "hasOwn"
13117
+ ],
13118
+ es2024: [
13119
+ "groupBy"
13065
13120
  ]
13066
13121
  })),
13067
13122
  NumberConstructor: new Map(Object.entries({
@@ -13102,11 +13157,25 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13102
13157
  "values"
13103
13158
  ]
13104
13159
  })),
13160
+ MapConstructor: new Map(Object.entries({
13161
+ es2024: [
13162
+ "groupBy"
13163
+ ]
13164
+ })),
13105
13165
  Set: new Map(Object.entries({
13106
13166
  es2015: [
13107
13167
  "entries",
13108
13168
  "keys",
13109
13169
  "values"
13170
+ ],
13171
+ esnext: [
13172
+ "union",
13173
+ "intersection",
13174
+ "difference",
13175
+ "symmetricDifference",
13176
+ "isSubsetOf",
13177
+ "isSupersetOf",
13178
+ "isDisjointFrom"
13110
13179
  ]
13111
13180
  })),
13112
13181
  PromiseConstructor: new Map(Object.entries({
@@ -13121,6 +13190,9 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13121
13190
  ],
13122
13191
  es2021: [
13123
13192
  "any"
13193
+ ],
13194
+ es2024: [
13195
+ "withResolvers"
13124
13196
  ]
13125
13197
  })),
13126
13198
  Symbol: new Map(Object.entries({
@@ -13187,7 +13259,7 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13187
13259
  es2022: [
13188
13260
  "at"
13189
13261
  ],
13190
- esnext: [
13262
+ es2024: [
13191
13263
  "isWellFormed",
13192
13264
  "toWellFormed"
13193
13265
  ]
@@ -13232,6 +13304,11 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13232
13304
  SymbolConstructor: new Map(Object.entries({
13233
13305
  es2020: [
13234
13306
  "matchAll"
13307
+ ],
13308
+ esnext: [
13309
+ "metadata",
13310
+ "dispose",
13311
+ "asyncDispose"
13235
13312
  ]
13236
13313
  })),
13237
13314
  DataView: new Map(Object.entries({
@@ -14404,6 +14481,8 @@ function getInvokedExpression(node) {
14404
14481
  return node.tagName;
14405
14482
  case 226 /* BinaryExpression */:
14406
14483
  return node.right;
14484
+ case 289 /* JsxOpeningFragment */:
14485
+ return node;
14407
14486
  default:
14408
14487
  return node.expression;
14409
14488
  }
@@ -14990,6 +15069,9 @@ function tryGetModuleSpecifierFromDeclaration(node) {
14990
15069
  Debug.assertNever(node);
14991
15070
  }
14992
15071
  }
15072
+ function shouldRewriteModuleSpecifier(specifier, compilerOptions) {
15073
+ return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier);
15074
+ }
14993
15075
  function getExternalModuleName(node) {
14994
15076
  switch (node.kind) {
14995
15077
  case 272 /* ImportDeclaration */:
@@ -17122,6 +17204,12 @@ function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sour
17122
17204
  );
17123
17205
  return getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
17124
17206
  }
17207
+ function rangeContainsRange(r1, r2) {
17208
+ return startEndContainsRange(r1.pos, r1.end, r2);
17209
+ }
17210
+ function startEndContainsRange(start, end, range) {
17211
+ return start <= range.pos && end >= range.end;
17212
+ }
17125
17213
  function getPreviousNonWhitespacePosition(pos, stopPos = 0, sourceFile) {
17126
17214
  while (pos-- > stopPos) {
17127
17215
  if (!isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
@@ -17714,6 +17802,12 @@ function createComputedCompilerOptions(options) {
17714
17802
  return options;
17715
17803
  }
17716
17804
  var _computedOptions = createComputedCompilerOptions({
17805
+ allowImportingTsExtensions: {
17806
+ dependencies: ["rewriteRelativeImportExtensions"],
17807
+ computeValue: (compilerOptions) => {
17808
+ return !!(compilerOptions.allowImportingTsExtensions || compilerOptions.rewriteRelativeImportExtensions);
17809
+ }
17810
+ },
17717
17811
  target: {
17718
17812
  dependencies: ["module"],
17719
17813
  computeValue: (compilerOptions) => {
@@ -17928,6 +18022,7 @@ var _computedOptions = createComputedCompilerOptions({
17928
18022
  }
17929
18023
  });
17930
18024
  var computedOptions = _computedOptions;
18025
+ var getAllowImportingTsExtensions = _computedOptions.allowImportingTsExtensions.computeValue;
17931
18026
  var getEmitScriptTarget = _computedOptions.target.computeValue;
17932
18027
  var getEmitModuleKind = _computedOptions.module.computeValue;
17933
18028
  var getEmitModuleResolutionKind = _computedOptions.moduleResolution.computeValue;
@@ -19702,6 +19797,46 @@ var nodeCoreModules = /* @__PURE__ */ new Set([
19702
19797
  ...unprefixedNodeCoreModulesList.map((name) => `node:${name}`),
19703
19798
  ...exclusivelyPrefixedNodeCoreModules
19704
19799
  ]);
19800
+ function forEachDynamicImportOrRequireCall(file, includeTypeSpaceImports, requireStringLiteralLikeArgument, cb) {
19801
+ const isJavaScriptFile = isInJSFile(file);
19802
+ const r = /import|require/g;
19803
+ while (r.exec(file.text) !== null) {
19804
+ const node = getNodeAtPosition(
19805
+ file,
19806
+ r.lastIndex,
19807
+ /*includeJSDoc*/
19808
+ includeTypeSpaceImports
19809
+ );
19810
+ if (isJavaScriptFile && isRequireCall(node, requireStringLiteralLikeArgument)) {
19811
+ cb(node, node.arguments[0]);
19812
+ } else if (isImportCall(node) && node.arguments.length >= 1 && (!requireStringLiteralLikeArgument || isStringLiteralLike(node.arguments[0]))) {
19813
+ cb(node, node.arguments[0]);
19814
+ } else if (includeTypeSpaceImports && isLiteralImportTypeNode(node)) {
19815
+ cb(node, node.argument.literal);
19816
+ } else if (includeTypeSpaceImports && isJSDocImportTag(node)) {
19817
+ const moduleNameExpr = getExternalModuleName(node);
19818
+ if (moduleNameExpr && isStringLiteral(moduleNameExpr) && moduleNameExpr.text) {
19819
+ cb(node, moduleNameExpr);
19820
+ }
19821
+ }
19822
+ }
19823
+ }
19824
+ function getNodeAtPosition(sourceFile, position, includeJSDoc) {
19825
+ const isJavaScriptFile = isInJSFile(sourceFile);
19826
+ let current = sourceFile;
19827
+ const getContainingChild = (child) => {
19828
+ if (child.pos <= position && (position < child.end || position === child.end && child.kind === 1 /* EndOfFileToken */)) {
19829
+ return child;
19830
+ }
19831
+ };
19832
+ while (true) {
19833
+ const child = isJavaScriptFile && includeJSDoc && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
19834
+ if (!child) {
19835
+ return current;
19836
+ }
19837
+ current = child;
19838
+ }
19839
+ }
19705
19840
 
19706
19841
  // src/compiler/factory/baseNodeFactory.ts
19707
19842
  function createBaseNodeFactory() {
@@ -24987,7 +25122,9 @@ function createEmitHelperFactory(context) {
24987
25122
  createClassPrivateFieldInHelper,
24988
25123
  // 'using' helpers
24989
25124
  createAddDisposableResourceHelper,
24990
- createDisposeResourcesHelper
25125
+ createDisposeResourcesHelper,
25126
+ // --rewriteRelativeImportExtensions helpers
25127
+ createRewriteRelativeImportExtensionsHelper
24991
25128
  };
24992
25129
  function getUnscopedHelperName(name) {
24993
25130
  return setEmitFlags(factory2.createIdentifier(name), 8192 /* HelperName */ | 4 /* AdviseOnEmitNode */);
@@ -25476,6 +25613,15 @@ function createEmitHelperFactory(context) {
25476
25613
  [envBinding]
25477
25614
  );
25478
25615
  }
25616
+ function createRewriteRelativeImportExtensionsHelper(expression) {
25617
+ context.requestEmitHelper(rewriteRelativeImportExtensionsHelper);
25618
+ return factory2.createCallExpression(
25619
+ getUnscopedHelperName("__rewriteRelativeImportExtension"),
25620
+ /*typeArguments*/
25621
+ void 0,
25622
+ context.getCompilerOptions().jsx === 1 /* Preserve */ ? [expression, factory2.createTrue()] : [expression]
25623
+ );
25624
+ }
25479
25625
  }
25480
25626
  function compareEmitHelpers(x, y) {
25481
25627
  if (x === y) return 0 /* EqualTo */;
@@ -25981,6 +26127,20 @@ var disposeResourcesHelper = {
25981
26127
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
25982
26128
  });`
25983
26129
  };
26130
+ var rewriteRelativeImportExtensionsHelper = {
26131
+ name: "typescript:rewriteRelativeImportExtensions",
26132
+ importName: "__rewriteRelativeImportExtension",
26133
+ scoped: false,
26134
+ text: `
26135
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
26136
+ if (typeof path === "string" && /^\\.\\.?\\//.test(path)) {
26137
+ return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
26138
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
26139
+ });
26140
+ }
26141
+ return path;
26142
+ };`
26143
+ };
25984
26144
  var asyncSuperHelper = {
25985
26145
  name: "typescript:async-super",
25986
26146
  scoped: true,
@@ -35827,6 +35987,7 @@ var libEntries = [
35827
35987
  ["es2021", "lib.es2021.d.ts"],
35828
35988
  ["es2022", "lib.es2022.d.ts"],
35829
35989
  ["es2023", "lib.es2023.d.ts"],
35990
+ ["es2024", "lib.es2024.d.ts"],
35830
35991
  ["esnext", "lib.esnext.d.ts"],
35831
35992
  // Host only
35832
35993
  ["dom", "lib.dom.d.ts"],
@@ -35849,6 +36010,7 @@ var libEntries = [
35849
36010
  ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
35850
36011
  ["es2016.array.include", "lib.es2016.array.include.d.ts"],
35851
36012
  ["es2016.intl", "lib.es2016.intl.d.ts"],
36013
+ ["es2017.arraybuffer", "lib.es2017.arraybuffer.d.ts"],
35852
36014
  ["es2017.date", "lib.es2017.date.d.ts"],
35853
36015
  ["es2017.object", "lib.es2017.object.d.ts"],
35854
36016
  ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
@@ -35881,12 +36043,18 @@ var libEntries = [
35881
36043
  ["es2022.error", "lib.es2022.error.d.ts"],
35882
36044
  ["es2022.intl", "lib.es2022.intl.d.ts"],
35883
36045
  ["es2022.object", "lib.es2022.object.d.ts"],
35884
- ["es2022.sharedmemory", "lib.es2022.sharedmemory.d.ts"],
35885
36046
  ["es2022.string", "lib.es2022.string.d.ts"],
35886
36047
  ["es2022.regexp", "lib.es2022.regexp.d.ts"],
35887
36048
  ["es2023.array", "lib.es2023.array.d.ts"],
35888
36049
  ["es2023.collection", "lib.es2023.collection.d.ts"],
35889
36050
  ["es2023.intl", "lib.es2023.intl.d.ts"],
36051
+ ["es2024.arraybuffer", "lib.es2024.arraybuffer.d.ts"],
36052
+ ["es2024.collection", "lib.es2024.collection.d.ts"],
36053
+ ["es2024.object", "lib.es2024.object.d.ts"],
36054
+ ["es2024.promise", "lib.es2024.promise.d.ts"],
36055
+ ["es2024.regexp", "lib.es2024.regexp.d.ts"],
36056
+ ["es2024.sharedmemory", "lib.es2024.sharedmemory.d.ts"],
36057
+ ["es2024.string", "lib.es2024.string.d.ts"],
35890
36058
  ["esnext.array", "lib.es2023.array.d.ts"],
35891
36059
  ["esnext.collection", "lib.esnext.collection.d.ts"],
35892
36060
  ["esnext.symbol", "lib.es2019.symbol.d.ts"],
@@ -35895,13 +36063,13 @@ var libEntries = [
35895
36063
  ["esnext.disposable", "lib.esnext.disposable.d.ts"],
35896
36064
  ["esnext.bigint", "lib.es2020.bigint.d.ts"],
35897
36065
  ["esnext.string", "lib.es2022.string.d.ts"],
35898
- ["esnext.promise", "lib.esnext.promise.d.ts"],
36066
+ ["esnext.promise", "lib.es2024.promise.d.ts"],
35899
36067
  ["esnext.weakref", "lib.es2021.weakref.d.ts"],
35900
36068
  ["esnext.decorators", "lib.esnext.decorators.d.ts"],
35901
- ["esnext.object", "lib.esnext.object.d.ts"],
36069
+ ["esnext.object", "lib.es2024.object.d.ts"],
35902
36070
  ["esnext.array", "lib.esnext.array.d.ts"],
35903
- ["esnext.regexp", "lib.esnext.regexp.d.ts"],
35904
- ["esnext.string", "lib.esnext.string.d.ts"],
36071
+ ["esnext.regexp", "lib.es2024.regexp.d.ts"],
36072
+ ["esnext.string", "lib.es2024.string.d.ts"],
35905
36073
  ["esnext.iterator", "lib.esnext.iterator.d.ts"],
35906
36074
  ["decorators", "lib.decorators.d.ts"],
35907
36075
  ["decorators.legacy", "lib.decorators.legacy.d.ts"]
@@ -36200,6 +36368,7 @@ var targetOptionDeclaration = {
36200
36368
  es2021: 8 /* ES2021 */,
36201
36369
  es2022: 9 /* ES2022 */,
36202
36370
  es2023: 10 /* ES2023 */,
36371
+ es2024: 11 /* ES2024 */,
36203
36372
  esnext: 99 /* ESNext */
36204
36373
  })),
36205
36374
  affectsSourceFile: true,
@@ -36802,6 +36971,15 @@ var commandOptionsWithoutBuild = [
36802
36971
  defaultValueDescription: false,
36803
36972
  transpileOptionValue: void 0
36804
36973
  },
36974
+ {
36975
+ name: "rewriteRelativeImportExtensions",
36976
+ type: "boolean",
36977
+ affectsSemanticDiagnostics: true,
36978
+ affectsBuildInfo: true,
36979
+ category: Diagnostics.Modules,
36980
+ description: Diagnostics.Rewrite_ts_tsx_mts_and_cts_file_extensions_in_relative_import_paths_to_their_JavaScript_equivalent_in_output_files,
36981
+ defaultValueDescription: false
36982
+ },
36805
36983
  {
36806
36984
  name: "resolvePackageJsonExports",
36807
36985
  type: "boolean",
@@ -40435,10 +40613,11 @@ function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecor
40435
40613
  }
40436
40614
  return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
40437
40615
  }
40438
- function loadFileNameFromPackageJsonField(extensions, candidate, onlyRecordFailures, state) {
40616
+ function loadFileNameFromPackageJsonField(extensions, candidate, packageJsonValue, onlyRecordFailures, state) {
40439
40617
  if (extensions & 1 /* TypeScript */ && fileExtensionIsOneOf(candidate, supportedTSImplementationExtensions) || extensions & 4 /* Declaration */ && fileExtensionIsOneOf(candidate, supportedDeclarationExtensions)) {
40440
40618
  const result = tryFile(candidate, onlyRecordFailures, state);
40441
- return result !== void 0 ? { path: candidate, ext: tryExtractTSExtension(candidate), resolvedUsingTsExtension: void 0 } : void 0;
40619
+ const ext = tryExtractTSExtension(candidate);
40620
+ return result !== void 0 ? { path: candidate, ext, resolvedUsingTsExtension: packageJsonValue ? !endsWith(packageJsonValue, ext) : void 0 } : void 0;
40442
40621
  }
40443
40622
  if (state.isConfigLookup && extensions === 8 /* Json */ && fileExtensionIs(candidate, ".json" /* Json */)) {
40444
40623
  const result = tryFile(candidate, onlyRecordFailures, state);
@@ -40627,7 +40806,14 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
40627
40806
  }
40628
40807
  }
40629
40808
  const loader = (extensions2, candidate2, onlyRecordFailures2, state2) => {
40630
- const fromFile = loadFileNameFromPackageJsonField(extensions2, candidate2, onlyRecordFailures2, state2);
40809
+ const fromFile = loadFileNameFromPackageJsonField(
40810
+ extensions2,
40811
+ candidate2,
40812
+ /*packageJsonValue*/
40813
+ void 0,
40814
+ onlyRecordFailures2,
40815
+ state2
40816
+ );
40631
40817
  if (fromFile) {
40632
40818
  return noPackageId(fromFile);
40633
40819
  }
@@ -40983,6 +41169,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
40983
41169
  return toSearchResult(withPackageId(scope, loadFileNameFromPackageJsonField(
40984
41170
  extensions,
40985
41171
  finalPath,
41172
+ target,
40986
41173
  /*onlyRecordFailures*/
40987
41174
  false,
40988
41175
  state
@@ -41095,6 +41282,8 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
41095
41282
  return toSearchResult(withPackageId(scope, loadFileNameFromPackageJsonField(
41096
41283
  extensions,
41097
41284
  possibleInputWithInputExtension,
41285
+ /*packageJsonValue*/
41286
+ void 0,
41098
41287
  /*onlyRecordFailures*/
41099
41288
  false,
41100
41289
  state
@@ -41457,7 +41646,7 @@ function resolveFromTypeRoot(moduleName, state) {
41457
41646
  }
41458
41647
  }
41459
41648
  function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
41460
- return !!compilerOptions.allowImportingTsExtensions || !!fromFileName && isDeclarationFileName(fromFileName);
41649
+ return getAllowImportingTsExtensions(compilerOptions) || !!fromFileName && isDeclarationFileName(fromFileName);
41461
41650
  }
41462
41651
  function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) {
41463
41652
  const traceEnabled = isTraceEnabled(compilerOptions, host);
@@ -46421,6 +46610,15 @@ function createTypeChecker(host) {
46421
46610
  emptyArray
46422
46611
  );
46423
46612
  emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */;
46613
+ var emptyFreshJsxObjectType = createAnonymousType(
46614
+ /*symbol*/
46615
+ void 0,
46616
+ emptySymbols,
46617
+ emptyArray,
46618
+ emptyArray,
46619
+ emptyArray
46620
+ );
46621
+ emptyFreshJsxObjectType.objectFlags |= 2048 /* JsxAttributes */ | 8192 /* FreshLiteral */ | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */;
46424
46622
  var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
46425
46623
  emptyTypeLiteralSymbol.members = createSymbolTable();
46426
46624
  var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, emptyArray);
@@ -48719,6 +48917,36 @@ function createTypeChecker(host) {
48719
48917
  const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
48720
48918
  error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
48721
48919
  }
48920
+ } else if (compilerOptions.rewriteRelativeImportExtensions && !(location.flags & 33554432 /* Ambient */) && !isDeclarationFileName(moduleReference) && !isLiteralImportTypeNode(location) && !isPartOfTypeOnlyImportOrExportDeclaration(location)) {
48921
+ const shouldRewrite = shouldRewriteModuleSpecifier(moduleReference, compilerOptions);
48922
+ if (!resolvedModule.resolvedUsingTsExtension && shouldRewrite) {
48923
+ error(
48924
+ errorNode,
48925
+ Diagnostics.This_relative_import_path_is_unsafe_to_rewrite_because_it_looks_like_a_file_name_but_actually_resolves_to_0,
48926
+ getRelativePathFromFile(getNormalizedAbsolutePath(currentSourceFile.fileName, host.getCurrentDirectory()), resolvedModule.resolvedFileName, hostGetCanonicalFileName(host))
48927
+ );
48928
+ } else if (resolvedModule.resolvedUsingTsExtension && !shouldRewrite && sourceFileMayBeEmitted(sourceFile, host)) {
48929
+ error(
48930
+ errorNode,
48931
+ Diagnostics.This_import_uses_a_0_extension_to_resolve_to_an_input_TypeScript_file_but_will_not_be_rewritten_during_emit_because_it_is_not_a_relative_path,
48932
+ getAnyExtensionFromPath(moduleReference)
48933
+ );
48934
+ } else if (resolvedModule.resolvedUsingTsExtension && shouldRewrite) {
48935
+ const redirect = host.getResolvedProjectReferenceToRedirect(sourceFile.path);
48936
+ if (redirect) {
48937
+ const ignoreCase = !host.useCaseSensitiveFileNames();
48938
+ const ownRootDir = host.getCommonSourceDirectory();
48939
+ const otherRootDir = getCommonSourceDirectoryOfConfig(redirect.commandLine, ignoreCase);
48940
+ const rootDirPath = getRelativePathFromDirectory(ownRootDir, otherRootDir, ignoreCase);
48941
+ const outDirPath = getRelativePathFromDirectory(compilerOptions.outDir || ownRootDir, redirect.commandLine.options.outDir || otherRootDir, ignoreCase);
48942
+ if (rootDirPath !== outDirPath) {
48943
+ error(
48944
+ errorNode,
48945
+ Diagnostics.This_import_path_is_unsafe_to_rewrite_because_it_resolves_to_another_project_and_the_relative_path_between_the_projects_output_files_is_not_the_same_as_the_relative_path_between_its_input_files
48946
+ );
48947
+ }
48948
+ }
48949
+ }
48722
48950
  }
48723
48951
  if (sourceFile.symbol) {
48724
48952
  if (errorNode && resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
@@ -52536,7 +52764,7 @@ function createTypeChecker(host) {
52536
52764
  }
52537
52765
  return factory.updateImportTypeNode(
52538
52766
  node,
52539
- factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)),
52767
+ factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier2(node, node.argument.literal)),
52540
52768
  visitNode(node.attributes, visitExistingNodeTreeSymbols, isImportAttributes),
52541
52769
  visitNode(node.qualifier, visitExistingNodeTreeSymbols, isEntityName),
52542
52770
  visitNodes2(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode),
@@ -52690,7 +52918,7 @@ function createTypeChecker(host) {
52690
52918
  function getNameForJSDocFunctionParameter(p, index) {
52691
52919
  return p.name && isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? `args` : `arg${index}`;
52692
52920
  }
52693
- function rewriteModuleSpecifier(parent, lit) {
52921
+ function rewriteModuleSpecifier2(parent, lit) {
52694
52922
  if (context.bundled || context.enclosingFile !== getSourceFileOfNode(lit)) {
52695
52923
  let name = lit.text;
52696
52924
  const nodeSymbol = getNodeLinks(node).resolvedSymbol;
@@ -72333,7 +72561,7 @@ function createTypeChecker(host) {
72333
72561
  return getContextualTypeForArgumentAtIndex(node, 0);
72334
72562
  }
72335
72563
  function getEffectiveFirstArgumentForJsxSignature(signature, node) {
72336
- return getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node);
72564
+ return isJsxOpeningFragment(node) || getJsxReferenceKind(node) !== 0 /* Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node);
72337
72565
  }
72338
72566
  function getJsxPropsTypeFromCallSignature(sig, context) {
72339
72567
  let propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
@@ -72364,6 +72592,7 @@ function createTypeChecker(host) {
72364
72592
  return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
72365
72593
  }
72366
72594
  function getStaticTypeOfReferencedJsxConstructor(context) {
72595
+ if (isJsxOpeningFragment(context)) return getJSXFragmentType(context);
72367
72596
  if (isJsxIntrinsicTagName(context.tagName)) {
72368
72597
  const result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
72369
72598
  const fakeSignature = createSignatureForJSXIntrinsic(context, result);
@@ -73012,8 +73241,6 @@ function createTypeChecker(host) {
73012
73241
  return node.initializer ? checkExpressionForMutableLocation(node.initializer, checkMode) : trueType;
73013
73242
  }
73014
73243
  function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode = 0 /* Normal */) {
73015
- const attributes = openingLikeElement.attributes;
73016
- const contextualType = getContextualType(attributes, 0 /* None */);
73017
73244
  const allAttributesTable = strictNullChecks ? createSymbolTable() : void 0;
73018
73245
  let attributesTable = createSymbolTable();
73019
73246
  let spread = emptyJsxObjectType;
@@ -73022,96 +73249,105 @@ function createTypeChecker(host) {
73022
73249
  let explicitlySpecifyChildrenAttribute = false;
73023
73250
  let objectFlags = 2048 /* JsxAttributes */;
73024
73251
  const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
73025
- for (const attributeDecl of attributes.properties) {
73026
- const member = attributeDecl.symbol;
73027
- if (isJsxAttribute(attributeDecl)) {
73028
- const exprType = checkJsxAttribute(attributeDecl, checkMode);
73029
- objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
73030
- const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
73031
- attributeSymbol.declarations = member.declarations;
73032
- attributeSymbol.parent = member.parent;
73033
- if (member.valueDeclaration) {
73034
- attributeSymbol.valueDeclaration = member.valueDeclaration;
73035
- }
73036
- attributeSymbol.links.type = exprType;
73037
- attributeSymbol.links.target = member;
73038
- attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
73039
- allAttributesTable == null ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
73040
- if (getEscapedTextOfJsxAttributeName(attributeDecl.name) === jsxChildrenPropertyName) {
73041
- explicitlySpecifyChildrenAttribute = true;
73042
- }
73043
- if (contextualType) {
73044
- const prop = getPropertyOfType(contextualType, member.escapedName);
73045
- if (prop && prop.declarations && isDeprecatedSymbol(prop) && isIdentifier(attributeDecl.name)) {
73046
- addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
73252
+ const isJsxOpenFragment = isJsxOpeningFragment(openingLikeElement);
73253
+ let attributesSymbol;
73254
+ let attributeParent = openingLikeElement;
73255
+ if (!isJsxOpenFragment) {
73256
+ const attributes = openingLikeElement.attributes;
73257
+ attributesSymbol = attributes.symbol;
73258
+ attributeParent = attributes;
73259
+ const contextualType = getContextualType(attributes, 0 /* None */);
73260
+ for (const attributeDecl of attributes.properties) {
73261
+ const member = attributeDecl.symbol;
73262
+ if (isJsxAttribute(attributeDecl)) {
73263
+ const exprType = checkJsxAttribute(attributeDecl, checkMode);
73264
+ objectFlags |= getObjectFlags(exprType) & 458752 /* PropagatingFlags */;
73265
+ const attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName);
73266
+ attributeSymbol.declarations = member.declarations;
73267
+ attributeSymbol.parent = member.parent;
73268
+ if (member.valueDeclaration) {
73269
+ attributeSymbol.valueDeclaration = member.valueDeclaration;
73270
+ }
73271
+ attributeSymbol.links.type = exprType;
73272
+ attributeSymbol.links.target = member;
73273
+ attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
73274
+ allAttributesTable == null ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
73275
+ if (getEscapedTextOfJsxAttributeName(attributeDecl.name) === jsxChildrenPropertyName) {
73276
+ explicitlySpecifyChildrenAttribute = true;
73277
+ }
73278
+ if (contextualType) {
73279
+ const prop = getPropertyOfType(contextualType, member.escapedName);
73280
+ if (prop && prop.declarations && isDeprecatedSymbol(prop) && isIdentifier(attributeDecl.name)) {
73281
+ addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText);
73282
+ }
73283
+ }
73284
+ if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
73285
+ const inferenceContext = getInferenceContext(attributes);
73286
+ Debug.assert(inferenceContext);
73287
+ const inferenceNode = attributeDecl.initializer.expression;
73288
+ addIntraExpressionInferenceSite(inferenceContext, inferenceNode, exprType);
73289
+ }
73290
+ } else {
73291
+ Debug.assert(attributeDecl.kind === 293 /* JsxSpreadAttribute */);
73292
+ if (attributesTable.size > 0) {
73293
+ spread = getSpreadType(
73294
+ spread,
73295
+ createJsxAttributesTypeHelper(),
73296
+ attributes.symbol,
73297
+ objectFlags,
73298
+ /*readonly*/
73299
+ false
73300
+ );
73301
+ attributesTable = createSymbolTable();
73302
+ }
73303
+ const exprType = getReducedType(checkExpression(attributeDecl.expression, checkMode & 2 /* Inferential */));
73304
+ if (isTypeAny(exprType)) {
73305
+ hasSpreadAnyType = true;
73306
+ }
73307
+ if (isValidSpreadType(exprType)) {
73308
+ spread = getSpreadType(
73309
+ spread,
73310
+ exprType,
73311
+ attributes.symbol,
73312
+ objectFlags,
73313
+ /*readonly*/
73314
+ false
73315
+ );
73316
+ if (allAttributesTable) {
73317
+ checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
73318
+ }
73319
+ } else {
73320
+ error(attributeDecl.expression, Diagnostics.Spread_types_may_only_be_created_from_object_types);
73321
+ typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73047
73322
  }
73048
73323
  }
73049
- if (contextualType && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(attributeDecl)) {
73050
- const inferenceContext = getInferenceContext(attributes);
73051
- Debug.assert(inferenceContext);
73052
- const inferenceNode = attributeDecl.initializer.expression;
73053
- addIntraExpressionInferenceSite(inferenceContext, inferenceNode, exprType);
73054
- }
73055
- } else {
73056
- Debug.assert(attributeDecl.kind === 293 /* JsxSpreadAttribute */);
73324
+ }
73325
+ if (!hasSpreadAnyType) {
73057
73326
  if (attributesTable.size > 0) {
73058
73327
  spread = getSpreadType(
73059
73328
  spread,
73060
- createJsxAttributesType(),
73061
- attributes.symbol,
73062
- objectFlags,
73063
- /*readonly*/
73064
- false
73065
- );
73066
- attributesTable = createSymbolTable();
73067
- }
73068
- const exprType = getReducedType(checkExpression(attributeDecl.expression, checkMode & 2 /* Inferential */));
73069
- if (isTypeAny(exprType)) {
73070
- hasSpreadAnyType = true;
73071
- }
73072
- if (isValidSpreadType(exprType)) {
73073
- spread = getSpreadType(
73074
- spread,
73075
- exprType,
73329
+ createJsxAttributesTypeHelper(),
73076
73330
  attributes.symbol,
73077
73331
  objectFlags,
73078
73332
  /*readonly*/
73079
73333
  false
73080
73334
  );
73081
- if (allAttributesTable) {
73082
- checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
73083
- }
73084
- } else {
73085
- error(attributeDecl.expression, Diagnostics.Spread_types_may_only_be_created_from_object_types);
73086
- typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73087
73335
  }
73088
73336
  }
73089
73337
  }
73090
- if (!hasSpreadAnyType) {
73091
- if (attributesTable.size > 0) {
73092
- spread = getSpreadType(
73093
- spread,
73094
- createJsxAttributesType(),
73095
- attributes.symbol,
73096
- objectFlags,
73097
- /*readonly*/
73098
- false
73099
- );
73100
- }
73101
- }
73102
- const parent = openingLikeElement.parent.kind === 284 /* JsxElement */ ? openingLikeElement.parent : void 0;
73103
- if (parent && parent.openingElement === openingLikeElement && getSemanticJsxChildren(parent.children).length > 0) {
73338
+ const parent = openingLikeElement.parent;
73339
+ if ((isJsxElement(parent) && parent.openingElement === openingLikeElement || isJsxFragment(parent) && parent.openingFragment === openingLikeElement) && getSemanticJsxChildren(parent.children).length > 0) {
73104
73340
  const childrenTypes = checkJsxChildren(parent, checkMode);
73105
73341
  if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
73106
73342
  if (explicitlySpecifyChildrenAttribute) {
73107
- error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, unescapeLeadingUnderscores(jsxChildrenPropertyName));
73343
+ error(attributeParent, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, unescapeLeadingUnderscores(jsxChildrenPropertyName));
73108
73344
  }
73109
- const contextualType2 = getApparentTypeOfContextualType(
73345
+ const contextualType = isJsxOpeningElement(openingLikeElement) ? getApparentTypeOfContextualType(
73110
73346
  openingLikeElement.attributes,
73111
73347
  /*contextFlags*/
73112
73348
  void 0
73113
- );
73114
- const childrenContextualType = contextualType2 && getTypeOfPropertyOfContextualType(contextualType2, jsxChildrenPropertyName);
73349
+ ) : void 0;
73350
+ const childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
73115
73351
  const childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
73116
73352
  childrenPropSymbol.links.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes));
73117
73353
  childrenPropSymbol.valueDeclaration = factory.createPropertySignature(
@@ -73123,14 +73359,14 @@ function createTypeChecker(host) {
73123
73359
  /*type*/
73124
73360
  void 0
73125
73361
  );
73126
- setParent(childrenPropSymbol.valueDeclaration, attributes);
73362
+ setParent(childrenPropSymbol.valueDeclaration, attributeParent);
73127
73363
  childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
73128
73364
  const childPropMap = createSymbolTable();
73129
73365
  childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
73130
73366
  spread = getSpreadType(
73131
73367
  spread,
73132
- createAnonymousType(attributes.symbol, childPropMap, emptyArray, emptyArray, emptyArray),
73133
- attributes.symbol,
73368
+ createAnonymousType(attributesSymbol, childPropMap, emptyArray, emptyArray, emptyArray),
73369
+ attributesSymbol,
73134
73370
  objectFlags,
73135
73371
  /*readonly*/
73136
73372
  false
@@ -73143,14 +73379,17 @@ function createTypeChecker(host) {
73143
73379
  if (typeToIntersect && spread !== emptyJsxObjectType) {
73144
73380
  return getIntersectionType([typeToIntersect, spread]);
73145
73381
  }
73146
- return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
73147
- function createJsxAttributesType() {
73382
+ return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesTypeHelper() : spread);
73383
+ function createJsxAttributesTypeHelper() {
73148
73384
  objectFlags |= 8192 /* FreshLiteral */;
73149
- const result = createAnonymousType(attributes.symbol, attributesTable, emptyArray, emptyArray, emptyArray);
73150
- result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */;
73151
- return result;
73385
+ return createJsxAttributesType(objectFlags, attributesSymbol, attributesTable);
73152
73386
  }
73153
73387
  }
73388
+ function createJsxAttributesType(objectFlags, attributesSymbol, attributesTable) {
73389
+ const result = createAnonymousType(attributesSymbol, attributesTable, emptyArray, emptyArray, emptyArray);
73390
+ result.objectFlags |= objectFlags | 8192 /* FreshLiteral */ | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */;
73391
+ return result;
73392
+ }
73154
73393
  function checkJsxChildren(node, checkMode) {
73155
73394
  const childrenTypes = [];
73156
73395
  for (const child of node.children) {
@@ -73456,10 +73695,10 @@ function createTypeChecker(host) {
73456
73695
  }
73457
73696
  checkJsxPreconditions(node);
73458
73697
  markJsxAliasReferenced(node);
73698
+ const sig = getResolvedSignature(node);
73699
+ checkDeprecatedSignature(sig, node);
73459
73700
  if (isNodeOpeningLikeElement) {
73460
73701
  const jsxOpeningLikeNode = node;
73461
- const sig = getResolvedSignature(jsxOpeningLikeNode);
73462
- checkDeprecatedSignature(sig, node);
73463
73702
  const elementTypeConstraint = getJsxElementTypeTypeAt(jsxOpeningLikeNode);
73464
73703
  if (elementTypeConstraint !== void 0) {
73465
73704
  const tagName = jsxOpeningLikeNode.tagName;
@@ -74483,6 +74722,7 @@ function createTypeChecker(host) {
74483
74722
  return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */));
74484
74723
  }
74485
74724
  function hasCorrectArity(node, args, signature, signatureHelpTrailingComma = false) {
74725
+ if (isJsxOpeningFragment(node)) return true;
74486
74726
  let argCount;
74487
74727
  let callIsIncomplete = false;
74488
74728
  let effectiveParameterCount = getParameterCount(signature);
@@ -74756,9 +74996,9 @@ function createTypeChecker(host) {
74756
74996
  }
74757
74997
  return 2 /* Mixed */;
74758
74998
  }
74759
- function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer) {
74999
+ function checkApplicableSignatureForJsxCallLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer) {
74760
75000
  const paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
74761
- const attributesType = checkExpressionWithContextualType(
75001
+ const attributesType = isJsxOpeningFragment(node) ? createJsxAttributesTypeFromAttributesProperty(node) : checkExpressionWithContextualType(
74762
75002
  node.attributes,
74763
75003
  paramType,
74764
75004
  /*inferenceContext*/
@@ -74770,8 +75010,8 @@ function createTypeChecker(host) {
74770
75010
  checkAttributesType,
74771
75011
  paramType,
74772
75012
  relation,
74773
- reportErrors2 ? node.tagName : void 0,
74774
- node.attributes,
75013
+ reportErrors2 ? isJsxOpeningFragment(node) ? node : node.tagName : void 0,
75014
+ isJsxOpeningFragment(node) ? void 0 : node.attributes,
74775
75015
  /*headMessage*/
74776
75016
  void 0,
74777
75017
  containingMessageChain,
@@ -74842,10 +75082,11 @@ function createTypeChecker(host) {
74842
75082
  return true;
74843
75083
  }
74844
75084
  if (reportErrors2) {
74845
- const diag2 = createDiagnosticForNode(node.tagName, Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, entityNameToString(node.tagName), absoluteMinArgCount, entityNameToString(factory2), maxParamCount);
74846
- const tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) == null ? void 0 : _a.valueDeclaration;
75085
+ const tagName = node.tagName;
75086
+ const diag2 = createDiagnosticForNode(tagName, Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, entityNameToString(tagName), absoluteMinArgCount, entityNameToString(factory2), maxParamCount);
75087
+ const tagNameDeclaration = (_a = getSymbolAtLocation(tagName)) == null ? void 0 : _a.valueDeclaration;
74847
75088
  if (tagNameDeclaration) {
74848
- addRelatedInfo(diag2, createDiagnosticForNode(tagNameDeclaration, Diagnostics._0_is_declared_here, entityNameToString(node.tagName)));
75089
+ addRelatedInfo(diag2, createDiagnosticForNode(tagNameDeclaration, Diagnostics._0_is_declared_here, entityNameToString(tagName)));
74849
75090
  }
74850
75091
  if (errorOutputContainer && errorOutputContainer.skipLogging) {
74851
75092
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag2);
@@ -74863,8 +75104,8 @@ function createTypeChecker(host) {
74863
75104
  }
74864
75105
  function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
74865
75106
  const errorOutputContainer = { errors: void 0, skipLogging: true };
74866
- if (isJsxOpeningLikeElement(node)) {
74867
- if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer)) {
75107
+ if (isJsxCallLike(node)) {
75108
+ if (!checkApplicableSignatureForJsxCallLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer)) {
74868
75109
  Debug.assert(!reportErrors2 || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
74869
75110
  return errorOutputContainer.errors || emptyArray;
74870
75111
  }
@@ -74964,6 +75205,9 @@ function createTypeChecker(host) {
74964
75205
  return result;
74965
75206
  }
74966
75207
  function getEffectiveCallArguments(node) {
75208
+ if (isJsxOpeningFragment(node)) {
75209
+ return [createSyntheticExpression(node, emptyFreshJsxObjectType)];
75210
+ }
74967
75211
  if (node.kind === 215 /* TaggedTemplateExpression */) {
74968
75212
  const template = node.template;
74969
75213
  const args2 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
@@ -75248,25 +75492,32 @@ function createTypeChecker(host) {
75248
75492
  const isTaggedTemplate = node.kind === 215 /* TaggedTemplateExpression */;
75249
75493
  const isDecorator2 = node.kind === 170 /* Decorator */;
75250
75494
  const isJsxOpeningOrSelfClosingElement = isJsxOpeningLikeElement(node);
75495
+ const isJsxOpenFragment = isJsxOpeningFragment(node);
75251
75496
  const isInstanceof = node.kind === 226 /* BinaryExpression */;
75252
75497
  const reportErrors2 = !isInferencePartiallyBlocked && !candidatesOutArray;
75498
+ let candidatesForArgumentError;
75499
+ let candidateForArgumentArityError;
75500
+ let candidateForTypeArgumentError;
75501
+ let result;
75502
+ let argCheckMode = 0 /* Normal */;
75503
+ let candidates = [];
75253
75504
  let typeArguments;
75254
- if (!isDecorator2 && !isInstanceof && !isSuperCall(node)) {
75505
+ if (!isDecorator2 && !isInstanceof && !isSuperCall(node) && !isJsxOpenFragment) {
75255
75506
  typeArguments = node.typeArguments;
75256
75507
  if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 108 /* SuperKeyword */) {
75257
75508
  forEach(typeArguments, checkSourceElement);
75258
75509
  }
75259
75510
  }
75260
- const candidates = candidatesOutArray || [];
75511
+ candidates = candidatesOutArray || [];
75261
75512
  reorderCandidates(signatures, candidates, callChainFlags);
75262
- Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
75513
+ if (!isJsxOpenFragment) {
75514
+ Debug.assert(candidates.length, "Revert #54442 and add a testcase with whatever triggered this");
75515
+ }
75263
75516
  const args = getEffectiveCallArguments(node);
75264
75517
  const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75265
- let argCheckMode = !isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75266
- let candidatesForArgumentError;
75267
- let candidateForArgumentArityError;
75268
- let candidateForTypeArgumentError;
75269
- let result;
75518
+ if (!isDecorator2 && !isSingleNonGenericCandidate && some(args, isContextSensitive)) {
75519
+ argCheckMode = 4 /* SkipContextSensitive */;
75520
+ }
75270
75521
  const signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 213 /* CallExpression */ && node.arguments.hasTrailingComma;
75271
75522
  if (candidates.length > 1) {
75272
75523
  result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
@@ -75386,7 +75637,7 @@ function createTypeChecker(host) {
75386
75637
  true,
75387
75638
  headMessage
75388
75639
  );
75389
- } else {
75640
+ } else if (!isJsxOpenFragment) {
75390
75641
  const signaturesWithCorrectTypeArgumentArity = filter(signatures, (s) => hasCorrectTypeArgumentArity(s, typeArguments));
75391
75642
  if (signaturesWithCorrectTypeArgumentArity.length === 0) {
75392
75643
  diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments, headMessage));
@@ -76034,24 +76285,52 @@ function createTypeChecker(host) {
76034
76285
  0 /* None */
76035
76286
  );
76036
76287
  }
76288
+ function getJSXFragmentType(node) {
76289
+ const sourceFileLinks = getNodeLinks(getSourceFileOfNode(node));
76290
+ if (sourceFileLinks.jsxFragmentType !== void 0) return sourceFileLinks.jsxFragmentType;
76291
+ const jsxFragmentFactoryName = getJsxNamespace(node);
76292
+ const jsxFactoryRefErr = diagnostics ? Diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found : void 0;
76293
+ const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName(
76294
+ node,
76295
+ jsxFragmentFactoryName,
76296
+ 111551 /* Value */,
76297
+ /*nameNotFoundMessage*/
76298
+ jsxFactoryRefErr,
76299
+ /*isUse*/
76300
+ true
76301
+ );
76302
+ if (jsxFactorySymbol === void 0) return sourceFileLinks.jsxFragmentType = errorType;
76303
+ if (jsxFactorySymbol.escapedName === ReactNames.Fragment) return sourceFileLinks.jsxFragmentType = getTypeOfSymbol(jsxFactorySymbol);
76304
+ const resolvedAlias = (jsxFactorySymbol.flags & 2097152 /* Alias */) === 0 ? jsxFactorySymbol : resolveAlias(jsxFactorySymbol);
76305
+ const reactExports = jsxFactorySymbol && getExportsOfSymbol(resolvedAlias);
76306
+ const typeSymbol = reactExports && getSymbol(reactExports, ReactNames.Fragment, 2 /* BlockScopedVariable */);
76307
+ const type = typeSymbol && getTypeOfSymbol(typeSymbol);
76308
+ return sourceFileLinks.jsxFragmentType = type === void 0 ? errorType : type;
76309
+ }
76037
76310
  function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
76038
- if (isJsxIntrinsicTagName(node.tagName)) {
76039
- const result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
76040
- const fakeSignature = createSignatureForJSXIntrinsic(node, result);
76041
- checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(
76042
- node.attributes,
76043
- getEffectiveFirstArgumentForJsxSignature(fakeSignature, node),
76044
- /*inferenceContext*/
76045
- void 0,
76046
- 0 /* Normal */
76047
- ), result, node.tagName, node.attributes);
76048
- if (length(node.typeArguments)) {
76049
- forEach(node.typeArguments, checkSourceElement);
76050
- diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), node.typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, 0, length(node.typeArguments)));
76311
+ const isJsxOpenFragment = isJsxOpeningFragment(node);
76312
+ let exprTypes;
76313
+ if (!isJsxOpenFragment) {
76314
+ if (isJsxIntrinsicTagName(node.tagName)) {
76315
+ const result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
76316
+ const fakeSignature = createSignatureForJSXIntrinsic(node, result);
76317
+ checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(
76318
+ node.attributes,
76319
+ getEffectiveFirstArgumentForJsxSignature(fakeSignature, node),
76320
+ /*inferenceContext*/
76321
+ void 0,
76322
+ 0 /* Normal */
76323
+ ), result, node.tagName, node.attributes);
76324
+ if (length(node.typeArguments)) {
76325
+ forEach(node.typeArguments, checkSourceElement);
76326
+ diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), node.typeArguments, Diagnostics.Expected_0_type_arguments_but_got_1, 0, length(node.typeArguments)));
76327
+ }
76328
+ return fakeSignature;
76051
76329
  }
76052
- return fakeSignature;
76330
+ exprTypes = checkExpression(node.tagName);
76331
+ } else {
76332
+ exprTypes = getJSXFragmentType(node);
76053
76333
  }
76054
- const exprTypes = checkExpression(node.tagName);
76055
76334
  const apparentType = getApparentType(exprTypes);
76056
76335
  if (isErrorType(apparentType)) {
76057
76336
  return resolveErrorCall(node);
@@ -76067,7 +76346,11 @@ function createTypeChecker(host) {
76067
76346
  return resolveUntypedCall(node);
76068
76347
  }
76069
76348
  if (signatures.length === 0) {
76070
- error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName));
76349
+ if (isJsxOpenFragment) {
76350
+ error(node, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node));
76351
+ } else {
76352
+ error(node.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(node.tagName));
76353
+ }
76071
76354
  return resolveErrorCall(node);
76072
76355
  }
76073
76356
  return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
@@ -76109,6 +76392,7 @@ function createTypeChecker(host) {
76109
76392
  return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
76110
76393
  case 170 /* Decorator */:
76111
76394
  return resolveDecorator(node, candidatesOutArray, checkMode);
76395
+ case 289 /* JsxOpeningFragment */:
76112
76396
  case 286 /* JsxOpeningElement */:
76113
76397
  case 285 /* JsxSelfClosingElement */:
76114
76398
  return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
@@ -87328,6 +87612,8 @@ function createTypeChecker(host) {
87328
87612
  return ["__propKey"];
87329
87613
  case 16777216 /* AddDisposableResourceAndDisposeResources */:
87330
87614
  return ["__addDisposableResource", "__disposeResources"];
87615
+ case 33554432 /* RewriteRelativeImportExtension */:
87616
+ return ["__rewriteRelativeImportExtension"];
87331
87617
  default:
87332
87618
  return Debug.fail("Unrecognized helper");
87333
87619
  }
@@ -88892,6 +89178,10 @@ var JsxNames;
88892
89178
  JsxNames2.IntrinsicClassAttributes = "IntrinsicClassAttributes";
88893
89179
  JsxNames2.LibraryManagedAttributes = "LibraryManagedAttributes";
88894
89180
  })(JsxNames || (JsxNames = {}));
89181
+ var ReactNames;
89182
+ ((ReactNames2) => {
89183
+ ReactNames2.Fragment = "Fragment";
89184
+ })(ReactNames || (ReactNames = {}));
88895
89185
  function getIterationTypesKeyFromIterationTypeKind(typeKind) {
88896
89186
  switch (typeKind) {
88897
89187
  case 0 /* Yield */:
@@ -88917,7 +89207,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
88917
89207
  var _a;
88918
89208
  return (_a = host.getPackageJsonInfoCache) == null ? void 0 : _a.call(host);
88919
89209
  },
88920
- useCaseSensitiveFileNames: maybeBind(host, host.useCaseSensitiveFileNames),
89210
+ useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
88921
89211
  redirectTargetsMap: host.redirectTargetsMap,
88922
89212
  getProjectReferenceRedirect: (fileName) => host.getProjectReferenceRedirect(fileName),
88923
89213
  isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
@@ -91192,6 +91482,13 @@ function isSimpleParameter(node) {
91192
91482
  function isSimpleParameterList(nodes) {
91193
91483
  return every(nodes, isSimpleParameter);
91194
91484
  }
91485
+ function rewriteModuleSpecifier(node, compilerOptions) {
91486
+ if (!node || !isStringLiteral(node) || !shouldRewriteModuleSpecifier(node.text, compilerOptions)) {
91487
+ return node;
91488
+ }
91489
+ const updatedText = changeExtension(node.text, getOutputExtension(node.text, compilerOptions));
91490
+ return updatedText !== node.text ? setOriginalNode(setTextRange(factory.createStringLiteral(updatedText, node.singleQuote), node), node) : node;
91491
+ }
91195
91492
 
91196
91493
  // src/compiler/transformers/destructuring.ts
91197
91494
  function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
@@ -93510,7 +93807,14 @@ function transformTypeScript(context) {
93510
93807
  return void 0;
93511
93808
  }
93512
93809
  if (!node.exportClause || isNamespaceExport(node.exportClause)) {
93513
- return node;
93810
+ return factory2.updateExportDeclaration(
93811
+ node,
93812
+ node.modifiers,
93813
+ node.isTypeOnly,
93814
+ node.exportClause,
93815
+ node.moduleSpecifier,
93816
+ node.attributes
93817
+ );
93514
93818
  }
93515
93819
  const allowEmpty = !!compilerOptions.verbatimModuleSyntax;
93516
93820
  const exportClause = visitNode(
@@ -93549,8 +93853,10 @@ function transformTypeScript(context) {
93549
93853
  return void 0;
93550
93854
  }
93551
93855
  if (isExternalModuleImportEqualsDeclaration(node)) {
93552
- const isReferenced = shouldEmitAliasDeclaration(node);
93553
- return isReferenced ? visitEachChild(node, visitor, context) : void 0;
93856
+ if (!shouldEmitAliasDeclaration(node)) {
93857
+ return void 0;
93858
+ }
93859
+ return visitEachChild(node, visitor, context);
93554
93860
  }
93555
93861
  if (!shouldEmitImportEqualsDeclaration(node)) {
93556
93862
  return void 0;
@@ -108120,6 +108426,7 @@ function transformModule(context) {
108120
108426
  const moduleInfoMap = [];
108121
108427
  let currentSourceFile;
108122
108428
  let currentModuleInfo;
108429
+ let importsAndRequiresToRewriteOrShim;
108123
108430
  const noSubstitution = [];
108124
108431
  let needUMDDynamicImportHelper;
108125
108432
  return chainBundle(context, transformSourceFile);
@@ -108130,6 +108437,20 @@ function transformModule(context) {
108130
108437
  currentSourceFile = node;
108131
108438
  currentModuleInfo = collectExternalModuleInfo(context, node);
108132
108439
  moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo;
108440
+ if (compilerOptions.rewriteRelativeImportExtensions) {
108441
+ forEachDynamicImportOrRequireCall(
108442
+ node,
108443
+ /*includeTypeSpaceImports*/
108444
+ false,
108445
+ /*requireStringLiteralLikeArgument*/
108446
+ false,
108447
+ (node2) => {
108448
+ if (!isStringLiteralLike(node2.arguments[0]) || shouldRewriteModuleSpecifier(node2.arguments[0].text, compilerOptions)) {
108449
+ importsAndRequiresToRewriteOrShim = append(importsAndRequiresToRewriteOrShim, node2);
108450
+ }
108451
+ }
108452
+ );
108453
+ }
108133
108454
  const transformModule2 = getTransformModuleDelegate(moduleKind);
108134
108455
  const updated = transformModule2(node);
108135
108456
  currentSourceFile = void 0;
@@ -108601,7 +108922,7 @@ function transformModule(context) {
108601
108922
  }
108602
108923
  }
108603
108924
  function visitorWorker(node, valueIsDiscarded) {
108604
- if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
108925
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */)) && !(importsAndRequiresToRewriteOrShim == null ? void 0 : importsAndRequiresToRewriteOrShim.length)) {
108605
108926
  return node;
108606
108927
  }
108607
108928
  switch (node.kind) {
@@ -108618,8 +108939,14 @@ function transformModule(context) {
108618
108939
  case 355 /* PartiallyEmittedExpression */:
108619
108940
  return visitPartiallyEmittedExpression(node, valueIsDiscarded);
108620
108941
  case 213 /* CallExpression */:
108942
+ const needsRewrite = node === firstOrUndefined(importsAndRequiresToRewriteOrShim);
108943
+ if (needsRewrite) {
108944
+ importsAndRequiresToRewriteOrShim.shift();
108945
+ }
108621
108946
  if (isImportCall(node) && host.shouldTransformImportCall(currentSourceFile)) {
108622
- return visitImportCallExpression(node);
108947
+ return visitImportCallExpression(node, needsRewrite);
108948
+ } else if (needsRewrite) {
108949
+ return shimOrRewriteImportOrRequireCall(node);
108623
108950
  }
108624
108951
  break;
108625
108952
  case 226 /* BinaryExpression */:
@@ -108911,13 +109238,27 @@ function transformModule(context) {
108911
109238
  }
108912
109239
  return visitEachChild(node, visitor, context);
108913
109240
  }
108914
- function visitImportCallExpression(node) {
109241
+ function shimOrRewriteImportOrRequireCall(node) {
109242
+ return factory2.updateCallExpression(
109243
+ node,
109244
+ node.expression,
109245
+ /*typeArguments*/
109246
+ void 0,
109247
+ visitNodes2(node.arguments, (arg) => {
109248
+ if (arg === node.arguments[0]) {
109249
+ return isStringLiteralLike(arg) ? rewriteModuleSpecifier(arg, compilerOptions) : emitHelpers().createRewriteRelativeImportExtensionsHelper(arg);
109250
+ }
109251
+ return visitor(arg);
109252
+ }, isExpression)
109253
+ );
109254
+ }
109255
+ function visitImportCallExpression(node, rewriteOrShim) {
108915
109256
  if (moduleKind === 0 /* None */ && languageVersion >= 7 /* ES2020 */) {
108916
109257
  return visitEachChild(node, visitor, context);
108917
109258
  }
108918
109259
  const externalModuleName = getExternalModuleNameLiteral(factory2, node, currentSourceFile, host, resolver, compilerOptions);
108919
109260
  const firstArgument = visitNode(firstOrUndefined(node.arguments), visitor, isExpression);
108920
- const argument = externalModuleName && (!firstArgument || !isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
109261
+ const argument = externalModuleName && (!firstArgument || !isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument && rewriteOrShim ? isStringLiteral(firstArgument) ? rewriteModuleSpecifier(firstArgument, compilerOptions) : emitHelpers().createRewriteRelativeImportExtensionsHelper(firstArgument) : firstArgument;
108921
109262
  const containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
108922
109263
  switch (compilerOptions.module) {
108923
109264
  case 2 /* AMD */:
@@ -109248,7 +109589,7 @@ function transformModule(context) {
109248
109589
  const moduleName = getExternalModuleNameLiteral(factory2, importNode, currentSourceFile, host, resolver, compilerOptions);
109249
109590
  const args = [];
109250
109591
  if (moduleName) {
109251
- args.push(moduleName);
109592
+ args.push(rewriteModuleSpecifier(moduleName, compilerOptions));
109252
109593
  }
109253
109594
  return factory2.createCallExpression(
109254
109595
  factory2.createIdentifier("require"),
@@ -111344,6 +111685,7 @@ function transformECMAScriptModule(context) {
111344
111685
  context.enableEmitNotification(307 /* SourceFile */);
111345
111686
  context.enableSubstitution(80 /* Identifier */);
111346
111687
  const noSubstitution = /* @__PURE__ */ new Set();
111688
+ let importsAndRequiresToRewriteOrShim;
111347
111689
  let helperNameSubstitutions;
111348
111690
  let currentSourceFile;
111349
111691
  let importRequireStatements;
@@ -111355,7 +111697,22 @@ function transformECMAScriptModule(context) {
111355
111697
  if (isExternalModule(node) || getIsolatedModules(compilerOptions)) {
111356
111698
  currentSourceFile = node;
111357
111699
  importRequireStatements = void 0;
111700
+ if (compilerOptions.rewriteRelativeImportExtensions && (currentSourceFile.flags & 4194304 /* PossiblyContainsDynamicImport */ || isInJSFile(node))) {
111701
+ forEachDynamicImportOrRequireCall(
111702
+ node,
111703
+ /*includeTypeSpaceImports*/
111704
+ false,
111705
+ /*requireStringLiteralLikeArgument*/
111706
+ false,
111707
+ (node2) => {
111708
+ if (!isStringLiteralLike(node2.arguments[0]) || shouldRewriteModuleSpecifier(node2.arguments[0].text, compilerOptions)) {
111709
+ importsAndRequiresToRewriteOrShim = append(importsAndRequiresToRewriteOrShim, node2);
111710
+ }
111711
+ }
111712
+ );
111713
+ }
111358
111714
  let result = updateExternalModule(node);
111715
+ addEmitHelpers(result, context.readEmitHelpers());
111359
111716
  currentSourceFile = void 0;
111360
111717
  if (importRequireStatements) {
111361
111718
  result = factory2.updateSourceFile(
@@ -111397,14 +111754,52 @@ function transformECMAScriptModule(context) {
111397
111754
  case 278 /* ExportDeclaration */:
111398
111755
  const exportDecl = node;
111399
111756
  return visitExportDeclaration(exportDecl);
111757
+ case 272 /* ImportDeclaration */:
111758
+ return visitImportDeclaration(node);
111759
+ case 213 /* CallExpression */:
111760
+ if (node === (importsAndRequiresToRewriteOrShim == null ? void 0 : importsAndRequiresToRewriteOrShim[0])) {
111761
+ return visitImportOrRequireCall(importsAndRequiresToRewriteOrShim.shift());
111762
+ }
111763
+ break;
111764
+ default:
111765
+ if ((importsAndRequiresToRewriteOrShim == null ? void 0 : importsAndRequiresToRewriteOrShim.length) && rangeContainsRange(node, importsAndRequiresToRewriteOrShim[0])) {
111766
+ return visitEachChild(node, visitor, context);
111767
+ }
111400
111768
  }
111401
111769
  return node;
111402
111770
  }
111771
+ function visitImportDeclaration(node) {
111772
+ if (!compilerOptions.rewriteRelativeImportExtensions) {
111773
+ return node;
111774
+ }
111775
+ const updatedModuleSpecifier = rewriteModuleSpecifier(node.moduleSpecifier, compilerOptions);
111776
+ if (updatedModuleSpecifier === node.moduleSpecifier) {
111777
+ return node;
111778
+ }
111779
+ return factory2.updateImportDeclaration(
111780
+ node,
111781
+ node.modifiers,
111782
+ node.importClause,
111783
+ updatedModuleSpecifier,
111784
+ node.attributes
111785
+ );
111786
+ }
111787
+ function visitImportOrRequireCall(node) {
111788
+ return factory2.updateCallExpression(
111789
+ node,
111790
+ node.expression,
111791
+ node.typeArguments,
111792
+ [
111793
+ isStringLiteralLike(node.arguments[0]) ? rewriteModuleSpecifier(node.arguments[0], compilerOptions) : emitHelpers().createRewriteRelativeImportExtensionsHelper(node.arguments[0]),
111794
+ ...node.arguments.slice(1)
111795
+ ]
111796
+ );
111797
+ }
111403
111798
  function createRequireCall(importNode) {
111404
111799
  const moduleName = getExternalModuleNameLiteral(factory2, importNode, Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
111405
111800
  const args = [];
111406
111801
  if (moduleName) {
111407
- args.push(moduleName);
111802
+ args.push(rewriteModuleSpecifier(moduleName, compilerOptions));
111408
111803
  }
111409
111804
  if (getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
111410
111805
  return factory2.createCallExpression(
@@ -111549,11 +111944,16 @@ function transformECMAScriptModule(context) {
111549
111944
  return node;
111550
111945
  }
111551
111946
  function visitExportDeclaration(node) {
111552
- if (compilerOptions.module !== void 0 && compilerOptions.module > 5 /* ES2015 */) {
111553
- return node;
111554
- }
111555
- if (!node.exportClause || !isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
111556
- return node;
111947
+ const updatedModuleSpecifier = rewriteModuleSpecifier(node.moduleSpecifier, compilerOptions);
111948
+ if (compilerOptions.module !== void 0 && compilerOptions.module > 5 /* ES2015 */ || !node.exportClause || !isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
111949
+ return !node.moduleSpecifier || updatedModuleSpecifier === node.moduleSpecifier ? node : factory2.updateExportDeclaration(
111950
+ node,
111951
+ node.modifiers,
111952
+ node.isTypeOnly,
111953
+ node.exportClause,
111954
+ updatedModuleSpecifier,
111955
+ node.attributes
111956
+ );
111557
111957
  }
111558
111958
  const oldIdentifier = node.exportClause.name;
111559
111959
  const synthName = factory2.getGeneratedNameForNode(oldIdentifier);
@@ -111569,7 +111969,7 @@ function transformECMAScriptModule(context) {
111569
111969
  synthName
111570
111970
  )
111571
111971
  ),
111572
- node.moduleSpecifier,
111972
+ updatedModuleSpecifier,
111573
111973
  node.attributes
111574
111974
  );
111575
111975
  setOriginalNode(importDecl, node.exportClause);
@@ -112728,7 +113128,7 @@ function transformDeclarations(context) {
112728
113128
  }
112729
113129
  return setCommentRange(updated, getCommentRange(original));
112730
113130
  }
112731
- function rewriteModuleSpecifier(parent, input) {
113131
+ function rewriteModuleSpecifier2(parent, input) {
112732
113132
  if (!input) return void 0;
112733
113133
  resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 267 /* ModuleDeclaration */ && parent.kind !== 205 /* ImportType */;
112734
113134
  if (isStringLiteralLike(input)) {
@@ -112750,7 +113150,7 @@ function transformDeclarations(context) {
112750
113150
  decl.modifiers,
112751
113151
  decl.isTypeOnly,
112752
113152
  decl.name,
112753
- factory2.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))
113153
+ factory2.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier2(decl, specifier))
112754
113154
  );
112755
113155
  } else {
112756
113156
  const oldDiag = getSymbolAccessibilityDiagnostic;
@@ -112766,7 +113166,7 @@ function transformDeclarations(context) {
112766
113166
  decl,
112767
113167
  decl.modifiers,
112768
113168
  decl.importClause,
112769
- rewriteModuleSpecifier(decl, decl.moduleSpecifier),
113169
+ rewriteModuleSpecifier2(decl, decl.moduleSpecifier),
112770
113170
  tryGetResolutionModeOverride(decl.attributes)
112771
113171
  );
112772
113172
  }
@@ -112782,7 +113182,7 @@ function transformDeclarations(context) {
112782
113182
  /*namedBindings*/
112783
113183
  void 0
112784
113184
  ),
112785
- rewriteModuleSpecifier(decl, decl.moduleSpecifier),
113185
+ rewriteModuleSpecifier2(decl, decl.moduleSpecifier),
112786
113186
  tryGetResolutionModeOverride(decl.attributes)
112787
113187
  );
112788
113188
  }
@@ -112800,7 +113200,7 @@ function transformDeclarations(context) {
112800
113200
  visibleDefaultBinding,
112801
113201
  namedBindings
112802
113202
  ),
112803
- rewriteModuleSpecifier(decl, decl.moduleSpecifier),
113203
+ rewriteModuleSpecifier2(decl, decl.moduleSpecifier),
112804
113204
  tryGetResolutionModeOverride(decl.attributes)
112805
113205
  ) : void 0;
112806
113206
  }
@@ -112815,7 +113215,7 @@ function transformDeclarations(context) {
112815
113215
  visibleDefaultBinding,
112816
113216
  bindingList && bindingList.length ? factory2.updateNamedImports(decl.importClause.namedBindings, bindingList) : void 0
112817
113217
  ),
112818
- rewriteModuleSpecifier(decl, decl.moduleSpecifier),
113218
+ rewriteModuleSpecifier2(decl, decl.moduleSpecifier),
112819
113219
  tryGetResolutionModeOverride(decl.attributes)
112820
113220
  );
112821
113221
  }
@@ -112828,7 +113228,7 @@ function transformDeclarations(context) {
112828
113228
  decl.modifiers,
112829
113229
  /*importClause*/
112830
113230
  void 0,
112831
- rewriteModuleSpecifier(decl, decl.moduleSpecifier),
113231
+ rewriteModuleSpecifier2(decl, decl.moduleSpecifier),
112832
113232
  tryGetResolutionModeOverride(decl.attributes)
112833
113233
  );
112834
113234
  }
@@ -113142,7 +113542,7 @@ function transformDeclarations(context) {
113142
113542
  if (!isLiteralImportTypeNode(input)) return cleanup(input);
113143
113543
  return cleanup(factory2.updateImportTypeNode(
113144
113544
  input,
113145
- factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)),
113545
+ factory2.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier2(input, input.argument.literal)),
113146
113546
  input.attributes,
113147
113547
  input.qualifier,
113148
113548
  visitNodes2(input.typeArguments, visitDeclarationSubtree, isTypeNode),
@@ -113195,7 +113595,7 @@ function transformDeclarations(context) {
113195
113595
  input.modifiers,
113196
113596
  input.isTypeOnly,
113197
113597
  input.exportClause,
113198
- rewriteModuleSpecifier(input, input.moduleSpecifier),
113598
+ rewriteModuleSpecifier2(input, input.moduleSpecifier),
113199
113599
  tryGetResolutionModeOverride(input.attributes)
113200
113600
  );
113201
113601
  }
@@ -113445,7 +113845,7 @@ function transformDeclarations(context) {
113445
113845
  return cleanup(updateModuleDeclarationAndKeyword(
113446
113846
  input,
113447
113847
  mods,
113448
- isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name,
113848
+ isExternalModuleAugmentation(input) ? rewriteModuleSpecifier2(input, input.name) : input.name,
113449
113849
  body
113450
113850
  ));
113451
113851
  } else {
@@ -122092,7 +122492,21 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122092
122492
  );
122093
122493
  }
122094
122494
  if (file.flags & 4194304 /* PossiblyContainsDynamicImport */ || isJavaScriptFile) {
122095
- collectDynamicImportOrRequireOrJsDocImportCalls(file);
122495
+ forEachDynamicImportOrRequireCall(
122496
+ file,
122497
+ /*includeTypeSpaceImports*/
122498
+ true,
122499
+ /*requireStringLiteralLikeArgument*/
122500
+ true,
122501
+ (node, moduleSpecifier) => {
122502
+ setParentRecursive(
122503
+ node,
122504
+ /*incremental*/
122505
+ false
122506
+ );
122507
+ imports = append(imports, moduleSpecifier);
122508
+ }
122509
+ );
122096
122510
  }
122097
122511
  file.imports = imports || emptyArray;
122098
122512
  file.moduleAugmentations = moduleAugmentations || emptyArray;
@@ -122140,63 +122554,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122140
122554
  }
122141
122555
  }
122142
122556
  }
122143
- function collectDynamicImportOrRequireOrJsDocImportCalls(file2) {
122144
- const r = /import|require/g;
122145
- while (r.exec(file2.text) !== null) {
122146
- const node = getNodeAtPosition(file2, r.lastIndex);
122147
- if (isJavaScriptFile && isRequireCall(
122148
- node,
122149
- /*requireStringLiteralLikeArgument*/
122150
- true
122151
- )) {
122152
- setParentRecursive(
122153
- node,
122154
- /*incremental*/
122155
- false
122156
- );
122157
- imports = append(imports, node.arguments[0]);
122158
- } else if (isImportCall(node) && node.arguments.length >= 1 && isStringLiteralLike(node.arguments[0])) {
122159
- setParentRecursive(
122160
- node,
122161
- /*incremental*/
122162
- false
122163
- );
122164
- imports = append(imports, node.arguments[0]);
122165
- } else if (isLiteralImportTypeNode(node)) {
122166
- setParentRecursive(
122167
- node,
122168
- /*incremental*/
122169
- false
122170
- );
122171
- imports = append(imports, node.argument.literal);
122172
- } else if (isJavaScriptFile && isJSDocImportTag(node)) {
122173
- const moduleNameExpr = getExternalModuleName(node);
122174
- if (moduleNameExpr && isStringLiteral(moduleNameExpr) && moduleNameExpr.text) {
122175
- setParentRecursive(
122176
- node,
122177
- /*incremental*/
122178
- false
122179
- );
122180
- imports = append(imports, moduleNameExpr);
122181
- }
122182
- }
122183
- }
122184
- }
122185
- function getNodeAtPosition(sourceFile, position) {
122186
- let current = sourceFile;
122187
- const getContainingChild = (child) => {
122188
- if (child.pos <= position && (position < child.end || position === child.end && child.kind === 1 /* EndOfFileToken */)) {
122189
- return child;
122190
- }
122191
- };
122192
- while (true) {
122193
- const child = isJavaScriptFile && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
122194
- if (!child) {
122195
- return current;
122196
- }
122197
- current = child;
122198
- }
122199
- }
122200
122557
  }
122201
122558
  function getLibFileFromReference(ref) {
122202
122559
  var _a2;
@@ -123021,7 +123378,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123021
123378
  createDiagnosticForOptionName(Diagnostics.Option_verbatimModuleSyntax_cannot_be_used_when_module_is_set_to_UMD_AMD_or_System, "verbatimModuleSyntax");
123022
123379
  }
123023
123380
  }
123024
- if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly)) {
123381
+ if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly || options.rewriteRelativeImportExtensions)) {
123025
123382
  createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set);
123026
123383
  }
123027
123384
  const moduleResolution = getEmitModuleResolutionKind(options);