typescript 5.7.2 → 5.8.0-beta

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
@@ -17,8 +17,8 @@ and limitations under the License.
17
17
  "use strict";
18
18
 
19
19
  // src/compiler/corePublic.ts
20
- var versionMajorMinor = "5.7";
21
- var version = "5.7.2";
20
+ var versionMajorMinor = "5.8";
21
+ var version = "5.8.0-beta";
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -3680,6 +3680,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
3680
3680
  ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
3681
3681
  ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
3682
3682
  ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
3683
+ ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
3683
3684
  ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
3684
3685
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
3685
3686
  ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
@@ -3733,6 +3734,7 @@ var ModuleKind = /* @__PURE__ */ ((ModuleKind2) => {
3733
3734
  ModuleKind2[ModuleKind2["ES2022"] = 7] = "ES2022";
3734
3735
  ModuleKind2[ModuleKind2["ESNext"] = 99] = "ESNext";
3735
3736
  ModuleKind2[ModuleKind2["Node16"] = 100] = "Node16";
3737
+ ModuleKind2[ModuleKind2["Node18"] = 101] = "Node18";
3736
3738
  ModuleKind2[ModuleKind2["NodeNext"] = 199] = "NodeNext";
3737
3739
  ModuleKind2[ModuleKind2["Preserve"] = 200] = "Preserve";
3738
3740
  return ModuleKind2;
@@ -5499,23 +5501,105 @@ function resolvePath(path, ...paths) {
5499
5501
  function getNormalizedPathComponents(path, currentDirectory) {
5500
5502
  return reducePathComponents(getPathComponents(path, currentDirectory));
5501
5503
  }
5502
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
5503
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
5504
+ function getNormalizedAbsolutePath(path, currentDirectory) {
5505
+ let rootLength = getRootLength(path);
5506
+ if (rootLength === 0 && currentDirectory) {
5507
+ path = combinePaths(currentDirectory, path);
5508
+ rootLength = getRootLength(path);
5509
+ } else {
5510
+ path = normalizeSlashes(path);
5511
+ }
5512
+ const simpleNormalized = simpleNormalizePath(path);
5513
+ if (simpleNormalized !== void 0) {
5514
+ return simpleNormalized.length > rootLength ? removeTrailingDirectorySeparator(simpleNormalized) : simpleNormalized;
5515
+ }
5516
+ const length2 = path.length;
5517
+ const root = path.substring(0, rootLength);
5518
+ let normalized;
5519
+ let index = rootLength;
5520
+ let segmentStart = index;
5521
+ let normalizedUpTo = index;
5522
+ let seenNonDotDotSegment = rootLength !== 0;
5523
+ while (index < length2) {
5524
+ segmentStart = index;
5525
+ let ch = path.charCodeAt(index);
5526
+ while (ch === 47 /* slash */ && index + 1 < length2) {
5527
+ index++;
5528
+ ch = path.charCodeAt(index);
5529
+ }
5530
+ if (index > segmentStart) {
5531
+ normalized ?? (normalized = path.substring(0, segmentStart - 1));
5532
+ segmentStart = index;
5533
+ }
5534
+ let segmentEnd = path.indexOf(directorySeparator, index + 1);
5535
+ if (segmentEnd === -1) {
5536
+ segmentEnd = length2;
5537
+ }
5538
+ const segmentLength = segmentEnd - segmentStart;
5539
+ if (segmentLength === 1 && path.charCodeAt(index) === 46 /* dot */) {
5540
+ normalized ?? (normalized = path.substring(0, normalizedUpTo));
5541
+ } else if (segmentLength === 2 && path.charCodeAt(index) === 46 /* dot */ && path.charCodeAt(index + 1) === 46 /* dot */) {
5542
+ if (!seenNonDotDotSegment) {
5543
+ if (normalized !== void 0) {
5544
+ normalized += normalized.length === rootLength ? ".." : "/..";
5545
+ } else {
5546
+ normalizedUpTo = index + 2;
5547
+ }
5548
+ } else if (normalized === void 0) {
5549
+ if (normalizedUpTo - 2 >= 0) {
5550
+ normalized = path.substring(0, Math.max(rootLength, path.lastIndexOf(directorySeparator, normalizedUpTo - 2)));
5551
+ } else {
5552
+ normalized = path.substring(0, normalizedUpTo);
5553
+ }
5554
+ } else {
5555
+ const lastSlash = normalized.lastIndexOf(directorySeparator);
5556
+ if (lastSlash !== -1) {
5557
+ normalized = normalized.substring(0, Math.max(rootLength, lastSlash));
5558
+ } else {
5559
+ normalized = root;
5560
+ }
5561
+ if (normalized.length === rootLength) {
5562
+ seenNonDotDotSegment = rootLength !== 0;
5563
+ }
5564
+ }
5565
+ } else if (normalized !== void 0) {
5566
+ if (normalized.length !== rootLength) {
5567
+ normalized += directorySeparator;
5568
+ }
5569
+ seenNonDotDotSegment = true;
5570
+ normalized += path.substring(segmentStart, segmentEnd);
5571
+ } else {
5572
+ seenNonDotDotSegment = true;
5573
+ normalizedUpTo = segmentEnd;
5574
+ }
5575
+ index = segmentEnd + 1;
5576
+ }
5577
+ return normalized ?? (length2 > rootLength ? removeTrailingDirectorySeparator(path) : path);
5504
5578
  }
5505
5579
  function normalizePath(path) {
5506
5580
  path = normalizeSlashes(path);
5581
+ let normalized = simpleNormalizePath(path);
5582
+ if (normalized !== void 0) {
5583
+ return normalized;
5584
+ }
5585
+ normalized = getNormalizedAbsolutePath(path, "");
5586
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
5587
+ }
5588
+ function simpleNormalizePath(path) {
5507
5589
  if (!relativePathSegmentRegExp.test(path)) {
5508
5590
  return path;
5509
5591
  }
5510
- const simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
5592
+ let simplified = path.replace(/\/\.\//g, "/");
5593
+ if (simplified.startsWith("./")) {
5594
+ simplified = simplified.slice(2);
5595
+ }
5511
5596
  if (simplified !== path) {
5512
5597
  path = simplified;
5513
5598
  if (!relativePathSegmentRegExp.test(path)) {
5514
5599
  return path;
5515
5600
  }
5516
5601
  }
5517
- const normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
5518
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
5602
+ return void 0;
5519
5603
  }
5520
5604
  function getPathWithoutRoot(pathComponents2) {
5521
5605
  if (pathComponents2.length === 0) return "";
@@ -5937,6 +6021,7 @@ var Diagnostics = {
5937
6021
  _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_import_type_where_0_is_imported: diag(1291, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1291", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'import type' where '{0}' is imported."),
5938
6022
  _0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enabled_Consider_using_export_type_0_as_default: diag(1292, 1 /* Error */, "_0_resolves_to_a_type_and_must_be_marked_type_only_in_this_file_before_re_exporting_when_1_is_enable_1292", "'{0}' resolves to a type and must be marked type-only in this file before re-exporting when '{1}' is enabled. Consider using 'export type { {0} as default }'."),
5939
6023
  ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve: diag(1293, 1 /* Error */, "ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_module_is_set_to_preserve_1293", "ESM syntax is not allowed in a CommonJS module when 'module' is set to 'preserve'."),
6024
+ This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled: diag(1294, 1 /* Error */, "This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled_1294", "This syntax is not allowed when 'erasableSyntaxOnly' is enabled."),
5940
6025
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, 1 /* Error */, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5941
6026
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, 1 /* Error */, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5942
6027
  The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level: diag(1309, 1 /* Error */, "The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level_1309", "The current file is a CommonJS module and cannot use 'await' at the top level."),
@@ -5951,8 +6036,8 @@ var Diagnostics = {
5951
6036
  Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, 1 /* Error */, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
5952
6037
  Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, 1 /* Error */, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
5953
6038
  Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, 1 /* Error */, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
5954
- Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext: diag(1323, 1 /* Error */, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'."),
5955
- Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_nodenext_or_preserve: diag(1324, 1 /* Error */, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_nodene_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'nodenext', or 'preserve'."),
6039
+ Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_node18_or_nodenext: diag(1323, 1 /* Error */, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', 'node18', or 'nodenext'."),
6040
+ Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_node18_nodenext_or_preserve: diag(1324, 1 /* Error */, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_node18_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', 'node18', 'nodenext', or 'preserve'."),
5956
6041
  Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, 1 /* Error */, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
5957
6042
  This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments: diag(1326, 1 /* Error */, "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326", "This use of 'import' is invalid. 'import()' calls can be written, but they must have parentheses and cannot have type arguments."),
5958
6043
  String_literal_with_double_quotes_expected: diag(1327, 1 /* Error */, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
@@ -5969,7 +6054,7 @@ var Diagnostics = {
5969
6054
  Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, 1 /* Error */, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
5970
6055
  Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, 1 /* Error */, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"),
5971
6056
  Class_constructor_may_not_be_an_accessor: diag(1341, 1 /* Error */, "Class_constructor_may_not_be_an_accessor_1341", "Class constructor may not be an accessor."),
5972
- The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext: diag(1343, 1 /* Error */, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', or 'nodenext'."),
6057
+ The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_node18_or_nodenext: diag(1343, 1 /* Error */, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', or 'nodenext'."),
5973
6058
  A_label_is_not_allowed_here: diag(1344, 1 /* Error */, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
5974
6059
  An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, 1 /* Error */, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."),
5975
6060
  This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, 1 /* Error */, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
@@ -5999,7 +6084,7 @@ var Diagnostics = {
5999
6084
  await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, 1 /* Error */, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
6000
6085
  _0_was_imported_here: diag(1376, 3 /* Message */, "_0_was_imported_here_1376", "'{0}' was imported here."),
6001
6086
  _0_was_exported_here: diag(1377, 3 /* Message */, "_0_was_exported_here_1377", "'{0}' was exported here."),
6002
- Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, 1 /* Error */, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6087
+ Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, 1 /* Error */, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6003
6088
  An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, 1 /* Error */, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
6004
6089
  An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, 1 /* Error */, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
6005
6090
  Unexpected_token_Did_you_mean_or_rbrace: diag(1381, 1 /* Error */, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `&rbrace;`?"),
@@ -6050,7 +6135,7 @@ var Diagnostics = {
6050
6135
  File_redirects_to_file_0: diag(1429, 3 /* Message */, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
6051
6136
  The_file_is_in_the_program_because_Colon: diag(1430, 3 /* Message */, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
6052
6137
  for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, 1 /* Error */, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
6053
- Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, 1 /* Error */, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6138
+ Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, 1 /* Error */, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6054
6139
  Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters: diag(1433, 1 /* Error */, "Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters_1433", "Neither decorators nor modifiers may be applied to 'this' parameters."),
6055
6140
  Unexpected_keyword_or_identifier: diag(1434, 1 /* Error */, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
6056
6141
  Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, 1 /* Error */, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
@@ -6692,9 +6777,9 @@ var Diagnostics = {
6692
6777
  Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, 1 /* Error */, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."),
6693
6778
  Namespace_name_cannot_be_0: diag(2819, 1 /* Error */, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
6694
6779
  Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, 1 /* Error */, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"),
6695
- Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve: diag(2821, 1 /* Error */, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve_2821", "Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'."),
6780
+ Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_preserve: diag(2821, 1 /* Error */, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_pres_2821", "Import assertions are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'."),
6696
6781
  Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, 1 /* Error */, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
6697
- Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve: diag(2823, 1 /* Error */, "Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve_2823", "Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'."),
6782
+ Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_preserve: diag(2823, 1 /* Error */, "Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_pres_2823", "Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'."),
6698
6783
  Cannot_find_namespace_0_Did_you_mean_1: diag(2833, 1 /* Error */, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
6699
6784
  Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, 1 /* Error */, "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."),
6700
6785
  Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, 1 /* Error */, "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"),
@@ -6714,7 +6799,7 @@ var Diagnostics = {
6714
6799
  The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_Symbol_dispose_method_or_be_null_or_undefined: diag(2851, 1 /* Error */, "The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_2851", "The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'."),
6715
6800
  await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
6716
6801
  await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
6717
- Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6802
+ Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'node18', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
6718
6803
  Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super: diag(2855, 1 /* Error */, "Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super_2855", "Class field '{0}' defined by the parent class is not accessible in the child class via super."),
6719
6804
  Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls: diag(2856, 1 /* Error */, "Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls_2856", "Import attributes are not allowed on statements that compile to CommonJS 'require' calls."),
6720
6805
  Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
@@ -6740,6 +6825,7 @@ var Diagnostics = {
6740
6825
  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
6826
  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
6827
  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."),
6828
+ Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_asserts: diag(2880, 1 /* Error */, "Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_asserts_2880", "Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'."),
6743
6829
  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}'."),
6744
6830
  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}'."),
6745
6831
  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}'."),
@@ -6849,6 +6935,8 @@ var Diagnostics = {
6849
6935
  Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, 1 /* Error */, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6850
6936
  Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given: diag(4125, 1 /* Error */, "Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given_4125", "Each declaration of '{0}.{1}' differs in its value, where '{2}' was expected but '{3}' was given."),
6851
6937
  One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value: diag(4126, 1 /* Error */, "One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value_4126", "One value of '{0}.{1}' is the string '{2}', and the other is assumed to be an unknown numeric value."),
6938
+ This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic: diag(4127, 1 /* Error */, "This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic_4127", "This member cannot have an 'override' modifier because its name is dynamic."),
6939
+ This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic: diag(4128, 1 /* Error */, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic_4128", "This member cannot have a JSDoc comment with an '@override' tag because its name is dynamic."),
6852
6940
  The_current_host_does_not_support_the_0_option: diag(5001, 1 /* Error */, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
6853
6941
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, 1 /* Error */, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
6854
6942
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, 1 /* Error */, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -7421,11 +7509,13 @@ var Diagnostics = {
7421
7509
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
7422
7510
  Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files: diag(6719, 3 /* Message */, "Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files_6719", "Require sufficient annotation on exports so other tools can trivially generate declaration files."),
7423
7511
  Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any: diag(6720, 3 /* Message */, "Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any_6720", "Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'."),
7512
+ Do_not_allow_runtime_constructs_that_are_not_part_of_ECMAScript: diag(6721, 3 /* Message */, "Do_not_allow_runtime_constructs_that_are_not_part_of_ECMAScript_6721", "Do not allow runtime constructs that are not part of ECMAScript."),
7424
7513
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
7425
7514
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
7426
7515
  Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported: diag(6805, 3 /* Message */, "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805", "Disable full type checking (only critical parse and emit errors will be reported)."),
7427
7516
  Check_side_effect_imports: diag(6806, 3 /* Message */, "Check_side_effect_imports_6806", "Check side effect imports."),
7428
7517
  This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2: diag(6807, 1 /* Error */, "This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2_6807", "This operation can be simplified. This shift is identical to `{0} {1} {2}`."),
7518
+ Enable_lib_replacement: diag(6808, 3 /* Message */, "Enable_lib_replacement_6808", "Enable lib replacement."),
7429
7519
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
7430
7520
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
7431
7521
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -11143,6 +11233,7 @@ function sortAndDeduplicateDiagnostics(diagnostics) {
11143
11233
  }
11144
11234
  var targetToLibMap = /* @__PURE__ */ new Map([
11145
11235
  [99 /* ESNext */, "lib.esnext.full.d.ts"],
11236
+ [11 /* ES2024 */, "lib.es2024.full.d.ts"],
11146
11237
  [10 /* ES2023 */, "lib.es2023.full.d.ts"],
11147
11238
  [9 /* ES2022 */, "lib.es2022.full.d.ts"],
11148
11239
  [8 /* ES2021 */, "lib.es2021.full.d.ts"],
@@ -11158,6 +11249,7 @@ function getDefaultLibFileName(options) {
11158
11249
  const target = getEmitScriptTarget(options);
11159
11250
  switch (target) {
11160
11251
  case 99 /* ESNext */:
11252
+ case 11 /* ES2024 */:
11161
11253
  case 10 /* ES2023 */:
11162
11254
  case 9 /* ES2022 */:
11163
11255
  case 8 /* ES2021 */:
@@ -13148,6 +13240,9 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13148
13240
  "trunc",
13149
13241
  "fround",
13150
13242
  "cbrt"
13243
+ ],
13244
+ esnext: [
13245
+ "f16round"
13151
13246
  ]
13152
13247
  })),
13153
13248
  Map: new Map(Object.entries({
@@ -13317,6 +13412,10 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13317
13412
  "setBigUint64",
13318
13413
  "getBigInt64",
13319
13414
  "getBigUint64"
13415
+ ],
13416
+ esnext: [
13417
+ "setFloat16",
13418
+ "getFloat16"
13320
13419
  ]
13321
13420
  })),
13322
13421
  BigInt: new Map(Object.entries({
@@ -13420,6 +13519,9 @@ var getScriptTargetFeatures = /* @__PURE__ */ memoize(
13420
13519
  "with"
13421
13520
  ]
13422
13521
  })),
13522
+ Float16Array: new Map(Object.entries({
13523
+ esnext: emptyArray
13524
+ })),
13423
13525
  Float32Array: new Map(Object.entries({
13424
13526
  es2022: [
13425
13527
  "at"
@@ -13588,7 +13690,7 @@ function getNonAugmentationDeclaration(symbol) {
13588
13690
  return (_a = symbol.declarations) == null ? void 0 : _a.find((d) => !isExternalModuleAugmentation(d) && !(isModuleDeclaration(d) && isGlobalScopeAugmentation(d)));
13589
13691
  }
13590
13692
  function isCommonJSContainingModuleKind(kind) {
13591
- return kind === 1 /* CommonJS */ || kind === 100 /* Node16 */ || kind === 199 /* NodeNext */;
13693
+ return kind === 1 /* CommonJS */ || 100 /* Node16 */ <= kind && kind <= 199 /* NodeNext */;
13592
13694
  }
13593
13695
  function isEffectiveExternalModule(node, compilerOptions) {
13594
13696
  return isExternalModule(node) || isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator;
@@ -14256,9 +14358,6 @@ function forEachPropertyAssignment(objectLiteral, key, callback, key2) {
14256
14358
  return key === propName || key2 && key2 === propName ? callback(property) : void 0;
14257
14359
  });
14258
14360
  }
14259
- function getPropertyArrayElementValue(objectLiteral, propKey, elementValue) {
14260
- return forEachPropertyAssignment(objectLiteral, propKey, (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
14261
- }
14262
14361
  function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
14263
14362
  if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
14264
14363
  const expression = tsConfigSourceFile.statements[0].expression;
@@ -17816,7 +17915,7 @@ var _computedOptions = createComputedCompilerOptions({
17816
17915
  dependencies: ["module"],
17817
17916
  computeValue: (compilerOptions) => {
17818
17917
  const target = compilerOptions.target === 0 /* ES3 */ ? void 0 : compilerOptions.target;
17819
- return target ?? (compilerOptions.module === 100 /* Node16 */ && 9 /* ES2022 */ || compilerOptions.module === 199 /* NodeNext */ && 99 /* ESNext */ || 1 /* ES5 */);
17918
+ return target ?? (compilerOptions.module === 100 /* Node16 */ && 9 /* ES2022 */ || compilerOptions.module === 101 /* Node18 */ && 9 /* ES2022 */ || compilerOptions.module === 199 /* NodeNext */ && 99 /* ESNext */ || 1 /* ES5 */);
17820
17919
  }
17821
17920
  },
17822
17921
  module: {
@@ -17835,6 +17934,7 @@ var _computedOptions = createComputedCompilerOptions({
17835
17934
  moduleResolution = 2 /* Node10 */;
17836
17935
  break;
17837
17936
  case 100 /* Node16 */:
17937
+ case 101 /* Node18 */:
17838
17938
  moduleResolution = 3 /* Node16 */;
17839
17939
  break;
17840
17940
  case 199 /* NodeNext */:
@@ -17854,7 +17954,11 @@ var _computedOptions = createComputedCompilerOptions({
17854
17954
  moduleDetection: {
17855
17955
  dependencies: ["module", "target"],
17856
17956
  computeValue: (compilerOptions) => {
17857
- return compilerOptions.moduleDetection || (_computedOptions.module.computeValue(compilerOptions) === 100 /* Node16 */ || _computedOptions.module.computeValue(compilerOptions) === 199 /* NodeNext */ ? 3 /* Force */ : 2 /* Auto */);
17957
+ if (compilerOptions.moduleDetection !== void 0) {
17958
+ return compilerOptions.moduleDetection;
17959
+ }
17960
+ const moduleKind = _computedOptions.module.computeValue(compilerOptions);
17961
+ return 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ ? 3 /* Force */ : 2 /* Auto */;
17858
17962
  }
17859
17963
  },
17860
17964
  isolatedModules: {
@@ -17871,6 +17975,7 @@ var _computedOptions = createComputedCompilerOptions({
17871
17975
  }
17872
17976
  switch (_computedOptions.module.computeValue(compilerOptions)) {
17873
17977
  case 100 /* Node16 */:
17978
+ case 101 /* Node18 */:
17874
17979
  case 199 /* NodeNext */:
17875
17980
  case 200 /* Preserve */:
17876
17981
  return true;
@@ -18064,6 +18169,9 @@ function unusedLabelIsError(options) {
18064
18169
  function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
18065
18170
  return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
18066
18171
  }
18172
+ function moduleSupportsImportAttributes(moduleKind) {
18173
+ return 101 /* Node18 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ || moduleKind === 200 /* Preserve */ || moduleKind === 99 /* ESNext */;
18174
+ }
18067
18175
  function getStrictOptionValue(compilerOptions, flag) {
18068
18176
  return compilerOptions[flag] === void 0 ? !!compilerOptions.strict : !!compilerOptions[flag];
18069
18177
  }
@@ -18781,7 +18889,7 @@ function isValidBigIntString(s, roundTripOnly) {
18781
18889
  return success && result === 10 /* BigIntLiteral */ && scanner.getTokenEnd() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner.getTokenValue()) }));
18782
18890
  }
18783
18891
  function isValidTypeOnlyAliasUseSite(useSite) {
18784
- return !!(useSite.flags & 33554432 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
18892
+ return !!(useSite.flags & 33554432 /* Ambient */) || isInJSDoc(useSite) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
18785
18893
  }
18786
18894
  function isShorthandPropertyNameUseSite(useSite) {
18787
18895
  return isIdentifier(useSite) && isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
@@ -19847,6 +19955,64 @@ function getNodeAtPosition(sourceFile, position, includeJSDoc) {
19847
19955
  function isNewScopeNode(node) {
19848
19956
  return isFunctionLike(node) || isJSDocSignature(node) || isMappedTypeNode(node);
19849
19957
  }
19958
+ function getLibNameFromLibReference(libReference) {
19959
+ return toFileNameLowerCase(libReference.fileName);
19960
+ }
19961
+ function getLibFileNameFromLibReference(libReference) {
19962
+ const libName = getLibNameFromLibReference(libReference);
19963
+ return libMap.get(libName);
19964
+ }
19965
+ function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
19966
+ return forEachProjectReference(
19967
+ /*projectReferences*/
19968
+ void 0,
19969
+ resolvedProjectReferences,
19970
+ (resolvedRef, parent) => resolvedRef && cb(resolvedRef, parent)
19971
+ );
19972
+ }
19973
+ function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
19974
+ let seenResolvedRefs;
19975
+ return worker(
19976
+ projectReferences,
19977
+ resolvedProjectReferences,
19978
+ /*parent*/
19979
+ void 0
19980
+ );
19981
+ function worker(projectReferences2, resolvedProjectReferences2, parent) {
19982
+ if (cbRef) {
19983
+ const result = cbRef(projectReferences2, parent);
19984
+ if (result) return result;
19985
+ }
19986
+ let skipChildren;
19987
+ return forEach(
19988
+ resolvedProjectReferences2,
19989
+ (resolvedRef, index) => {
19990
+ if (resolvedRef && (seenResolvedRefs == null ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) {
19991
+ (skipChildren ?? (skipChildren = /* @__PURE__ */ new Set())).add(resolvedRef);
19992
+ return void 0;
19993
+ }
19994
+ const result = cbResolvedRef(resolvedRef, parent, index);
19995
+ if (result || !resolvedRef) return result;
19996
+ (seenResolvedRefs || (seenResolvedRefs = /* @__PURE__ */ new Set())).add(resolvedRef.sourceFile.path);
19997
+ }
19998
+ ) || forEach(
19999
+ resolvedProjectReferences2,
20000
+ (resolvedRef) => resolvedRef && !(skipChildren == null ? void 0 : skipChildren.has(resolvedRef)) ? worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef) : void 0
20001
+ );
20002
+ }
20003
+ }
20004
+ function getOptionsSyntaxByArrayElementValue(optionsObject, name, value) {
20005
+ return optionsObject && getPropertyArrayElementValue(optionsObject, name, value);
20006
+ }
20007
+ function getPropertyArrayElementValue(objectLiteral, propKey, elementValue) {
20008
+ return forEachPropertyAssignment(objectLiteral, propKey, (property) => isArrayLiteralExpression(property.initializer) ? find(property.initializer.elements, (element) => isStringLiteral(element) && element.text === elementValue) : void 0);
20009
+ }
20010
+ function getOptionsSyntaxByValue(optionsObject, name, value) {
20011
+ return forEachOptionsSyntaxByName(optionsObject, name, (property) => isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : void 0);
20012
+ }
20013
+ function forEachOptionsSyntaxByName(optionsObject, name, callback) {
20014
+ return forEachPropertyAssignment(optionsObject, name, callback);
20015
+ }
19850
20016
 
19851
20017
  // src/compiler/factory/baseNodeFactory.ts
19852
20018
  function createBaseNodeFactory() {
@@ -22453,6 +22619,8 @@ function createNodeFactory(flags, baseFactory2) {
22453
22619
  node.colonToken = colonToken ?? createToken(59 /* ColonToken */);
22454
22620
  node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
22455
22621
  node.transformFlags |= propagateChildFlags(node.condition) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.whenTrue) | propagateChildFlags(node.colonToken) | propagateChildFlags(node.whenFalse);
22622
+ node.flowNodeWhenFalse = void 0;
22623
+ node.flowNodeWhenTrue = void 0;
22456
22624
  return node;
22457
22625
  }
22458
22626
  function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
@@ -24256,7 +24424,7 @@ function createNodeFactory(flags, baseFactory2) {
24256
24424
  function isIgnorableParen(node) {
24257
24425
  return isParenthesizedExpression(node) && nodeIsSynthesized(node) && nodeIsSynthesized(getSourceMapRange(node)) && nodeIsSynthesized(getCommentRange(node)) && !some(getSyntheticLeadingComments(node)) && !some(getSyntheticTrailingComments(node));
24258
24426
  }
24259
- function restoreOuterExpressions(outerExpression, innerExpression, kinds = 31 /* All */) {
24427
+ function restoreOuterExpressions(outerExpression, innerExpression, kinds = 63 /* All */) {
24260
24428
  if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
24261
24429
  return updateOuterExpression(
24262
24430
  outerExpression,
@@ -24302,7 +24470,7 @@ function createNodeFactory(flags, baseFactory2) {
24302
24470
  }
24303
24471
  }
24304
24472
  function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers = false) {
24305
- const callee = skipOuterExpressions(expression, 31 /* All */);
24473
+ const callee = skipOuterExpressions(expression, 63 /* All */);
24306
24474
  let thisArg;
24307
24475
  let target;
24308
24476
  if (isSuperProperty(callee)) {
@@ -27171,7 +27339,7 @@ function getJSDocTypeAssertionType(node) {
27171
27339
  Debug.assertIsDefined(type);
27172
27340
  return type;
27173
27341
  }
27174
- function isOuterExpression(node, kinds = 31 /* All */) {
27342
+ function isOuterExpression(node, kinds = 63 /* All */) {
27175
27343
  switch (node.kind) {
27176
27344
  case 217 /* ParenthesizedExpression */:
27177
27345
  if (kinds & -2147483648 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
@@ -27180,8 +27348,9 @@ function isOuterExpression(node, kinds = 31 /* All */) {
27180
27348
  return (kinds & 1 /* Parentheses */) !== 0;
27181
27349
  case 216 /* TypeAssertionExpression */:
27182
27350
  case 234 /* AsExpression */:
27183
- case 238 /* SatisfiesExpression */:
27184
27351
  return (kinds & 2 /* TypeAssertions */) !== 0;
27352
+ case 238 /* SatisfiesExpression */:
27353
+ return (kinds & (2 /* TypeAssertions */ | 32 /* Satisfies */)) !== 0;
27185
27354
  case 233 /* ExpressionWithTypeArguments */:
27186
27355
  return (kinds & 16 /* ExpressionsWithTypeArguments */) !== 0;
27187
27356
  case 235 /* NonNullExpression */:
@@ -27191,13 +27360,13 @@ function isOuterExpression(node, kinds = 31 /* All */) {
27191
27360
  }
27192
27361
  return false;
27193
27362
  }
27194
- function skipOuterExpressions(node, kinds = 31 /* All */) {
27363
+ function skipOuterExpressions(node, kinds = 63 /* All */) {
27195
27364
  while (isOuterExpression(node, kinds)) {
27196
27365
  node = node.expression;
27197
27366
  }
27198
27367
  return node;
27199
27368
  }
27200
- function walkUpOuterExpressions(node, kinds = 31 /* All */) {
27369
+ function walkUpOuterExpressions(node, kinds = 63 /* All */) {
27201
27370
  let parent = node.parent;
27202
27371
  while (isOuterExpression(parent, kinds)) {
27203
27372
  parent = parent.parent;
@@ -35054,6 +35223,7 @@ var Parser;
35054
35223
  const node = factory2.createExpressionWithTypeArguments(expression, typeArguments);
35055
35224
  const res = finishNode(node, pos);
35056
35225
  if (usedBrace) {
35226
+ skipWhitespace();
35057
35227
  parseExpected(20 /* CloseBraceToken */);
35058
35228
  }
35059
35229
  return res;
@@ -36099,6 +36269,8 @@ var libEntries = [
36099
36269
  ["esnext.regexp", "lib.es2024.regexp.d.ts"],
36100
36270
  ["esnext.string", "lib.es2024.string.d.ts"],
36101
36271
  ["esnext.iterator", "lib.esnext.iterator.d.ts"],
36272
+ ["esnext.promise", "lib.esnext.promise.d.ts"],
36273
+ ["esnext.float16", "lib.esnext.float16.d.ts"],
36102
36274
  ["decorators", "lib.decorators.d.ts"],
36103
36275
  ["decorators.legacy", "lib.decorators.legacy.d.ts"]
36104
36276
  ];
@@ -36425,6 +36597,7 @@ var moduleOptionDeclaration = {
36425
36597
  es2022: 7 /* ES2022 */,
36426
36598
  esnext: 99 /* ESNext */,
36427
36599
  node16: 100 /* Node16 */,
36600
+ node18: 101 /* Node18 */,
36428
36601
  nodenext: 199 /* NodeNext */,
36429
36602
  preserve: 200 /* Preserve */
36430
36603
  })),
@@ -36677,6 +36850,23 @@ var commandOptionsWithoutBuild = [
36677
36850
  affectsBuildInfo: true,
36678
36851
  affectsSemanticDiagnostics: true
36679
36852
  },
36853
+ {
36854
+ name: "erasableSyntaxOnly",
36855
+ type: "boolean",
36856
+ category: Diagnostics.Interop_Constraints,
36857
+ description: Diagnostics.Do_not_allow_runtime_constructs_that_are_not_part_of_ECMAScript,
36858
+ defaultValueDescription: false,
36859
+ affectsBuildInfo: true,
36860
+ affectsSemanticDiagnostics: true
36861
+ },
36862
+ {
36863
+ name: "libReplacement",
36864
+ type: "boolean",
36865
+ affectsProgramStructure: true,
36866
+ category: Diagnostics.Language_and_Environment,
36867
+ description: Diagnostics.Enable_lib_replacement,
36868
+ defaultValueDescription: true
36869
+ },
36680
36870
  // Strict Type Checks
36681
36871
  {
36682
36872
  name: "strict",
@@ -40729,9 +40919,7 @@ function tryFileLookup(fileName, onlyRecordFailures, state) {
40729
40919
  }
40730
40920
  function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
40731
40921
  const packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : void 0;
40732
- const packageJsonContent = packageInfo && packageInfo.contents.packageJsonContent;
40733
- const versionPaths = packageInfo && getVersionPathsOfPackageJsonInfo(packageInfo, state);
40734
- return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths), state);
40922
+ return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo), state);
40735
40923
  }
40736
40924
  function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
40737
40925
  return {
@@ -40838,13 +41026,14 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
40838
41026
  (_f = state.failedLookupLocations) == null ? void 0 : _f.push(packageJsonPath);
40839
41027
  }
40840
41028
  }
40841
- function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
41029
+ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJson) {
41030
+ const versionPaths = packageJson && getVersionPathsOfPackageJsonInfo(packageJson, state);
40842
41031
  let packageFile;
40843
- if (jsonContent) {
41032
+ if (packageJson && arePathsEqual(packageJson == null ? void 0 : packageJson.packageDirectory, candidate, state.host)) {
40844
41033
  if (state.isConfigLookup) {
40845
- packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
41034
+ packageFile = readPackageJsonTSConfigField(packageJson.contents.packageJsonContent, packageJson.packageDirectory, state);
40846
41035
  } else {
40847
- packageFile = extensions & 4 /* Declaration */ && readPackageJsonTypesFields(jsonContent, candidate, state) || extensions & (3 /* ImplementationFiles */ | 4 /* Declaration */) && readPackageJsonMainField(jsonContent, candidate, state) || void 0;
41036
+ packageFile = extensions & 4 /* Declaration */ && readPackageJsonTypesFields(packageJson.contents.packageJsonContent, packageJson.packageDirectory, state) || extensions & (3 /* ImplementationFiles */ | 4 /* Declaration */) && readPackageJsonMainField(packageJson.contents.packageJsonContent, packageJson.packageDirectory, state) || void 0;
40848
41037
  }
40849
41038
  }
40850
41039
  const loader = (extensions2, candidate2, onlyRecordFailures2, state2) => {
@@ -40863,7 +41052,7 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
40863
41052
  const features = state2.features;
40864
41053
  const candidateIsFromPackageJsonField = state2.candidateIsFromPackageJsonField;
40865
41054
  state2.candidateIsFromPackageJsonField = true;
40866
- if ((jsonContent == null ? void 0 : jsonContent.type) !== "module") {
41055
+ if ((packageJson == null ? void 0 : packageJson.contents.packageJsonContent.type) !== "module") {
40867
41056
  state2.features &= ~32 /* EsmMode */;
40868
41057
  }
40869
41058
  const result = nodeLoadModuleByRelativeName(
@@ -41134,6 +41323,7 @@ function hasOneAsterisk(patternKey) {
41134
41323
  function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
41135
41324
  return loadModuleFromTargetExportOrImport;
41136
41325
  function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
41326
+ var _a, _b;
41137
41327
  if (typeof target === "string") {
41138
41328
  if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
41139
41329
  if (state.traceEnabled) {
@@ -41162,6 +41352,8 @@ function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirec
41162
41352
  redirectedReference,
41163
41353
  state.conditions
41164
41354
  );
41355
+ (_a = state.failedLookupLocations) == null ? void 0 : _a.push(...result.failedLookupLocations ?? emptyArray);
41356
+ (_b = state.affectingLocations) == null ? void 0 : _b.push(...result.affectingLocations ?? emptyArray);
41165
41357
  return toSearchResult(
41166
41358
  result.resolvedModule ? {
41167
41359
  path: result.resolvedModule.resolvedFileName,
@@ -41271,20 +41463,20 @@ function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirec
41271
41463
  void 0
41272
41464
  );
41273
41465
  function toAbsolutePath(path) {
41274
- var _a, _b;
41466
+ var _a2, _b2;
41275
41467
  if (path === void 0) return path;
41276
- return getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a));
41468
+ return getNormalizedAbsolutePath(path, (_b2 = (_a2 = state.host).getCurrentDirectory) == null ? void 0 : _b2.call(_a2));
41277
41469
  }
41278
41470
  function combineDirectoryPath(root, dir) {
41279
41471
  return ensureTrailingDirectorySeparator(combinePaths(root, dir));
41280
41472
  }
41281
41473
  function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports2) {
41282
- var _a, _b, _c, _d;
41474
+ var _a2, _b2, _c, _d;
41283
41475
  if (!state.isConfigLookup && (state.compilerOptions.declarationDir || state.compilerOptions.outDir) && !finalPath.includes("/node_modules/") && (state.compilerOptions.configFile ? containsPath(scope.packageDirectory, toAbsolutePath(state.compilerOptions.configFile.fileName), !useCaseSensitiveFileNames(state)) : true)) {
41284
41476
  const getCanonicalFileName = hostGetCanonicalFileName({ useCaseSensitiveFileNames: () => useCaseSensitiveFileNames(state) });
41285
41477
  const commonSourceDirGuesses = [];
41286
41478
  if (state.compilerOptions.rootDir || state.compilerOptions.composite && state.compilerOptions.configFilePath) {
41287
- const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [], ((_b = (_a = state.host).getCurrentDirectory) == null ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
41479
+ const commonDir = toAbsolutePath(getCommonSourceDirectory(state.compilerOptions, () => [], ((_b2 = (_a2 = state.host).getCurrentDirectory) == null ? void 0 : _b2.call(_a2)) || "", getCanonicalFileName));
41288
41480
  commonSourceDirGuesses.push(commonDir);
41289
41481
  } else if (state.requestContainingDirectory) {
41290
41482
  const requestingFile = toAbsolutePath(combinePaths(state.requestContainingDirectory, "index.ts"));
@@ -41340,8 +41532,8 @@ function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirec
41340
41532
  }
41341
41533
  return void 0;
41342
41534
  function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
41343
- var _a2, _b2;
41344
- const currentDir = state.compilerOptions.configFile ? ((_b2 = (_a2 = state.host).getCurrentDirectory) == null ? void 0 : _b2.call(_a2)) || "" : commonSourceDirGuess;
41535
+ var _a3, _b3;
41536
+ const currentDir = state.compilerOptions.configFile ? ((_b3 = (_a3 = state.host).getCurrentDirectory) == null ? void 0 : _b3.call(_a3)) || "" : commonSourceDirGuess;
41345
41537
  const candidateDirectories = [];
41346
41538
  if (state.compilerOptions.declarationDir) {
41347
41539
  candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
@@ -41388,7 +41580,7 @@ function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directo
41388
41580
  );
41389
41581
  }
41390
41582
  function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
41391
- const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ ? 99 /* ESNext */ : 1 /* CommonJS */;
41583
+ const mode = state.features === 0 ? void 0 : state.features & 32 /* EsmMode */ || state.conditions.includes("import") ? 99 /* ESNext */ : 1 /* CommonJS */;
41392
41584
  const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
41393
41585
  const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
41394
41586
  if (priorityExtensions) {
@@ -41466,8 +41658,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, node
41466
41658
  candidate,
41467
41659
  !nodeModulesDirectoryExists,
41468
41660
  state,
41469
- packageInfo.contents.packageJsonContent,
41470
- getVersionPathsOfPackageJsonInfo(packageInfo, state)
41661
+ packageInfo
41471
41662
  );
41472
41663
  return withPackageId(packageInfo, fromDirectory, state);
41473
41664
  }
@@ -41477,8 +41668,7 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, node
41477
41668
  candidate2,
41478
41669
  onlyRecordFailures,
41479
41670
  state2,
41480
- packageInfo && packageInfo.contents.packageJsonContent,
41481
- packageInfo && getVersionPathsOfPackageJsonInfo(packageInfo, state2)
41671
+ packageInfo
41482
41672
  );
41483
41673
  if (!pathAndExtension && packageInfo && (packageInfo.contents.packageJsonContent.exports === void 0 || packageInfo.contents.packageJsonContent.exports === null) && state2.features & 32 /* EsmMode */) {
41484
41674
  pathAndExtension = loadModuleFromFile(extensions2, combinePaths(candidate2, "index.js"), onlyRecordFailures, state2);
@@ -41908,6 +42098,7 @@ function createBinder() {
41908
42098
  var preSwitchCaseFlow;
41909
42099
  var activeLabelList;
41910
42100
  var hasExplicitReturn;
42101
+ var inReturnPosition;
41911
42102
  var hasFlowEffects;
41912
42103
  var emitFlags;
41913
42104
  var inStrictMode;
@@ -41980,6 +42171,7 @@ function createBinder() {
41980
42171
  currentExceptionTarget = void 0;
41981
42172
  activeLabelList = void 0;
41982
42173
  hasExplicitReturn = false;
42174
+ inReturnPosition = false;
41983
42175
  hasFlowEffects = false;
41984
42176
  inAssignmentPattern = false;
41985
42177
  emitFlags = 0 /* None */;
@@ -42216,6 +42408,8 @@ function createBinder() {
42216
42408
  const saveContainer = container;
42217
42409
  const saveThisParentContainer = thisParentContainer;
42218
42410
  const savedBlockScopeContainer = blockScopeContainer;
42411
+ const savedInReturnPosition = inReturnPosition;
42412
+ if (node.kind === 219 /* ArrowFunction */ && node.body.kind !== 241 /* Block */) inReturnPosition = true;
42219
42413
  if (containerFlags & 1 /* IsContainer */) {
42220
42414
  if (node.kind !== 219 /* ArrowFunction */) {
42221
42415
  thisParentContainer = container;
@@ -42293,6 +42487,7 @@ function createBinder() {
42293
42487
  } else {
42294
42488
  bindChildren(node);
42295
42489
  }
42490
+ inReturnPosition = savedInReturnPosition;
42296
42491
  container = saveContainer;
42297
42492
  thisParentContainer = saveThisParentContainer;
42298
42493
  blockScopeContainer = savedBlockScopeContainer;
@@ -42314,6 +42509,9 @@ function createBinder() {
42314
42509
  const saveInAssignmentPattern = inAssignmentPattern;
42315
42510
  inAssignmentPattern = false;
42316
42511
  if (checkUnreachable(node)) {
42512
+ if (canHaveFlowNode(node) && node.flowNode) {
42513
+ node.flowNode = void 0;
42514
+ }
42317
42515
  bindEachChild(node);
42318
42516
  bindJSDoc(node);
42319
42517
  inAssignmentPattern = saveInAssignmentPattern;
@@ -42509,7 +42707,9 @@ function createBinder() {
42509
42707
  case 36 /* ExclamationEqualsToken */:
42510
42708
  case 37 /* EqualsEqualsEqualsToken */:
42511
42709
  case 38 /* ExclamationEqualsEqualsToken */:
42512
- return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) || (isBooleanLiteral(expr.right) && isNarrowingExpression(expr.left) || isBooleanLiteral(expr.left) && isNarrowingExpression(expr.right));
42710
+ const left = skipParentheses(expr.left);
42711
+ const right = skipParentheses(expr.right);
42712
+ return isNarrowableOperand(left) || isNarrowableOperand(right) || isNarrowingTypeofOperands(right, left) || isNarrowingTypeofOperands(left, right) || (isBooleanLiteral(right) && isNarrowingExpression(left) || isBooleanLiteral(left) && isNarrowingExpression(right));
42513
42713
  case 104 /* InstanceOfKeyword */:
42514
42714
  return isNarrowableOperand(expr.left);
42515
42715
  case 103 /* InKeyword */:
@@ -42701,13 +42901,16 @@ function createBinder() {
42701
42901
  function bindForStatement(node) {
42702
42902
  const preLoopLabel = setContinueTarget(node, createLoopLabel());
42703
42903
  const preBodyLabel = createBranchLabel();
42904
+ const preIncrementorLabel = createBranchLabel();
42704
42905
  const postLoopLabel = createBranchLabel();
42705
42906
  bind(node.initializer);
42706
42907
  addAntecedent(preLoopLabel, currentFlow);
42707
42908
  currentFlow = preLoopLabel;
42708
42909
  bindCondition(node.condition, preBodyLabel, postLoopLabel);
42709
42910
  currentFlow = finishFlowLabel(preBodyLabel);
42710
- bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
42911
+ bindIterativeStatement(node.statement, postLoopLabel, preIncrementorLabel);
42912
+ addAntecedent(preIncrementorLabel, currentFlow);
42913
+ currentFlow = finishFlowLabel(preIncrementorLabel);
42711
42914
  bind(node.incrementor);
42712
42915
  addAntecedent(preLoopLabel, currentFlow);
42713
42916
  currentFlow = finishFlowLabel(postLoopLabel);
@@ -42744,7 +42947,10 @@ function createBinder() {
42744
42947
  currentFlow = finishFlowLabel(postIfLabel);
42745
42948
  }
42746
42949
  function bindReturnOrThrow(node) {
42950
+ const savedInReturnPosition = inReturnPosition;
42951
+ inReturnPosition = true;
42747
42952
  bind(node.expression);
42953
+ inReturnPosition = savedInReturnPosition;
42748
42954
  if (node.kind === 253 /* ReturnStatement */) {
42749
42955
  hasExplicitReturn = true;
42750
42956
  if (currentReturnTarget) {
@@ -43105,10 +43311,16 @@ function createBinder() {
43105
43311
  hasFlowEffects = false;
43106
43312
  bindCondition(node.condition, trueLabel, falseLabel);
43107
43313
  currentFlow = finishFlowLabel(trueLabel);
43314
+ if (inReturnPosition) {
43315
+ node.flowNodeWhenTrue = currentFlow;
43316
+ }
43108
43317
  bind(node.questionToken);
43109
43318
  bind(node.whenTrue);
43110
43319
  addAntecedent(postExpressionLabel, currentFlow);
43111
43320
  currentFlow = finishFlowLabel(falseLabel);
43321
+ if (inReturnPosition) {
43322
+ node.flowNodeWhenFalse = currentFlow;
43323
+ }
43112
43324
  bind(node.colonToken);
43113
43325
  bind(node.whenFalse);
43114
43326
  addAntecedent(postExpressionLabel, currentFlow);
@@ -46165,8 +46377,8 @@ function createTypeChecker(host) {
46165
46377
  writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
46166
46378
  return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
46167
46379
  },
46168
- writeType: (type, enclosingDeclaration, flags, writer) => {
46169
- return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
46380
+ writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
46381
+ return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
46170
46382
  },
46171
46383
  writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
46172
46384
  return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
@@ -46282,6 +46494,7 @@ function createTypeChecker(host) {
46282
46494
  getNumberLiteralType,
46283
46495
  getBigIntType: () => bigintType,
46284
46496
  getBigIntLiteralType,
46497
+ getUnknownType: () => unknownType,
46285
46498
  createPromiseType,
46286
46499
  createArrayType,
46287
46500
  getElementTypeOfArrayType,
@@ -46398,8 +46611,13 @@ function createTypeChecker(host) {
46398
46611
  getMemberOverrideModifierStatus,
46399
46612
  isTypeParameterPossiblyReferenced,
46400
46613
  typeHasCallOrConstructSignatures,
46401
- getSymbolFlags
46614
+ getSymbolFlags,
46615
+ getTypeArgumentsForResolvedSignature
46402
46616
  };
46617
+ function getTypeArgumentsForResolvedSignature(signature) {
46618
+ if (signature.mapper === void 0) return void 0;
46619
+ return instantiateTypes((signature.target || signature).typeParameters, signature.mapper);
46620
+ }
46403
46621
  function getCandidateSignaturesForStringLiteralCompletions(call, editingArgument) {
46404
46622
  const candidatesSet = /* @__PURE__ */ new Set();
46405
46623
  const candidates = [];
@@ -46776,6 +46994,12 @@ function createTypeChecker(host) {
46776
46994
  /*isReadonly*/
46777
46995
  true
46778
46996
  );
46997
+ var anyBaseTypeIndexInfo = createIndexInfo(
46998
+ stringType,
46999
+ anyType,
47000
+ /*isReadonly*/
47001
+ false
47002
+ );
46779
47003
  var iterationTypesCache = /* @__PURE__ */ new Map();
46780
47004
  var noIterationTypes = {
46781
47005
  get yieldType() {
@@ -46952,6 +47176,7 @@ function createTypeChecker(host) {
46952
47176
  [".jsx", ".jsx"],
46953
47177
  [".json", ".json"]
46954
47178
  ];
47179
+ var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
46955
47180
  initializeTypeChecker();
46956
47181
  return checker;
46957
47182
  function isDefinitelyReferenceToGlobalSymbolObject(node) {
@@ -47815,9 +48040,9 @@ function createTypeChecker(host) {
47815
48040
  const containerKind = grandparent.parent.kind;
47816
48041
  if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) {
47817
48042
  error(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name));
47818
- } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) {
48043
+ } else if (isClassLike(grandparent.parent) && heritageKind === 96 /* ExtendsKeyword */) {
47819
48044
  error(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name));
47820
- } else if (containerKind === 263 /* ClassDeclaration */ && heritageKind === 119 /* ImplementsKeyword */) {
48045
+ } else if (isClassLike(grandparent.parent) && heritageKind === 119 /* ImplementsKeyword */) {
47821
48046
  error(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name));
47822
48047
  }
47823
48048
  } else {
@@ -48993,7 +49218,7 @@ function createTypeChecker(host) {
48993
49218
  moduleReference
48994
49219
  );
48995
49220
  }
48996
- if (errorNode && (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */)) {
49221
+ if (errorNode && (moduleKind === 100 /* Node16 */ || moduleKind === 101 /* Node18 */)) {
48997
49222
  const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
48998
49223
  const overrideHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l) || isJSDocImportTag(l));
48999
49224
  if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !hasResolutionModeOverride(overrideHost)) {
@@ -50087,14 +50312,18 @@ function createTypeChecker(host) {
50087
50312
  return writer2;
50088
50313
  }
50089
50314
  }
50090
- function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
50091
- const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */;
50315
+ function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
50316
+ const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */ || verbosityLevel !== void 0;
50092
50317
  const typeNode = nodeBuilder.typeToTypeNode(
50093
50318
  type,
50094
50319
  enclosingDeclaration,
50095
- toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0 /* None */),
50320
+ toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
50096
50321
  /*internalFlags*/
50097
- void 0
50322
+ void 0,
50323
+ /*tracker*/
50324
+ void 0,
50325
+ verbosityLevel,
50326
+ out
50098
50327
  );
50099
50328
  if (typeNode === void 0) return Debug.fail("should always get typenode");
50100
50329
  const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
@@ -50234,12 +50463,7 @@ function createTypeChecker(host) {
50234
50463
  enterNewScope(context, node) {
50235
50464
  if (isFunctionLike(node) || isJSDocSignature(node)) {
50236
50465
  const signature = getSignatureFromDeclaration(node);
50237
- const expandedParams = getExpandedParameters(
50238
- signature,
50239
- /*skipUnionExpanding*/
50240
- true
50241
- )[0];
50242
- return enterNewScope(context, node, expandedParams, signature.typeParameters);
50466
+ return enterNewScope(context, node, signature.parameters, signature.typeParameters);
50243
50467
  } else {
50244
50468
  const typeParameters = isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
50245
50469
  return enterNewScope(
@@ -50319,38 +50543,134 @@ function createTypeChecker(host) {
50319
50543
  return true;
50320
50544
  }
50321
50545
  if (requiresAddingUndefined && annotationType) {
50322
- annotationType = getOptionalType(annotationType, !isParameter(node));
50546
+ annotationType = addOptionality(annotationType, !isParameter(node));
50323
50547
  }
50324
50548
  return !!annotationType && typeNodeIsEquivalentToType(node, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type);
50325
50549
  }
50326
50550
  };
50327
50551
  return {
50328
50552
  syntacticBuilderResolver,
50329
- typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
50330
- typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
50331
- serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)),
50332
- serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)),
50333
- serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)),
50334
- indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
50335
- indexInfo,
50336
- context,
50337
- /*typeNode*/
50338
- void 0
50339
- )),
50340
- signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => signatureToSignatureDeclarationHelper(signature, kind, context)),
50341
- symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToName(
50342
- symbol,
50343
- context,
50344
- meaning,
50345
- /*expectsIdentifier*/
50346
- false
50347
- )),
50348
- symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToExpression(symbol, context, meaning)),
50349
- symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
50350
- symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
50351
- typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
50352
- symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
50353
- symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => symbolToNode(symbol, context, meaning))
50553
+ typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
50554
+ typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50555
+ enclosingDeclaration,
50556
+ flags,
50557
+ internalFlags,
50558
+ tracker,
50559
+ /*verbosityLevel*/
50560
+ void 0,
50561
+ (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
50562
+ ),
50563
+ serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50564
+ enclosingDeclaration,
50565
+ flags,
50566
+ internalFlags,
50567
+ tracker,
50568
+ /*verbosityLevel*/
50569
+ void 0,
50570
+ (context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
50571
+ ),
50572
+ serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50573
+ enclosingDeclaration,
50574
+ flags,
50575
+ internalFlags,
50576
+ tracker,
50577
+ /*verbosityLevel*/
50578
+ void 0,
50579
+ (context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
50580
+ ),
50581
+ serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50582
+ enclosingDeclaration,
50583
+ flags,
50584
+ internalFlags,
50585
+ tracker,
50586
+ /*verbosityLevel*/
50587
+ void 0,
50588
+ (context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
50589
+ ),
50590
+ indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50591
+ enclosingDeclaration,
50592
+ flags,
50593
+ internalFlags,
50594
+ tracker,
50595
+ /*verbosityLevel*/
50596
+ void 0,
50597
+ (context) => indexInfoToIndexSignatureDeclarationHelper(
50598
+ indexInfo,
50599
+ context,
50600
+ /*typeNode*/
50601
+ void 0
50602
+ )
50603
+ ),
50604
+ signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50605
+ enclosingDeclaration,
50606
+ flags,
50607
+ internalFlags,
50608
+ tracker,
50609
+ /*verbosityLevel*/
50610
+ void 0,
50611
+ (context) => signatureToSignatureDeclarationHelper(signature, kind, context)
50612
+ ),
50613
+ symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50614
+ enclosingDeclaration,
50615
+ flags,
50616
+ internalFlags,
50617
+ tracker,
50618
+ /*verbosityLevel*/
50619
+ void 0,
50620
+ (context) => symbolToName(
50621
+ symbol,
50622
+ context,
50623
+ meaning,
50624
+ /*expectsIdentifier*/
50625
+ false
50626
+ )
50627
+ ),
50628
+ symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50629
+ enclosingDeclaration,
50630
+ flags,
50631
+ internalFlags,
50632
+ tracker,
50633
+ /*verbosityLevel*/
50634
+ void 0,
50635
+ (context) => symbolToExpression(symbol, context, meaning)
50636
+ ),
50637
+ symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50638
+ enclosingDeclaration,
50639
+ flags,
50640
+ internalFlags,
50641
+ tracker,
50642
+ /*verbosityLevel*/
50643
+ void 0,
50644
+ (context) => typeParametersToTypeParameterDeclarations(symbol, context)
50645
+ ),
50646
+ symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50647
+ enclosingDeclaration,
50648
+ flags,
50649
+ internalFlags,
50650
+ tracker,
50651
+ /*verbosityLevel*/
50652
+ void 0,
50653
+ (context) => symbolToParameterDeclaration(symbol, context)
50654
+ ),
50655
+ typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context)),
50656
+ symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50657
+ enclosingDeclaration,
50658
+ flags,
50659
+ internalFlags,
50660
+ tracker,
50661
+ /*verbosityLevel*/
50662
+ void 0,
50663
+ (context) => symbolTableToDeclarationStatements(symbolTable, context)
50664
+ ),
50665
+ symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
50666
+ enclosingDeclaration,
50667
+ flags,
50668
+ internalFlags,
50669
+ tracker,
50670
+ /*verbosityLevel*/
50671
+ void 0,
50672
+ (context) => symbolToNode(symbol, context, meaning)
50673
+ )
50354
50674
  };
50355
50675
  function getTypeFromTypeNode2(context, node, noMappedTypes) {
50356
50676
  const type = getTypeFromTypeNodeWithoutContext(node);
@@ -50392,7 +50712,7 @@ function createTypeChecker(host) {
50392
50712
  }
50393
50713
  return symbolToExpression(symbol, context, meaning);
50394
50714
  }
50395
- function withContext(enclosingDeclaration, flags, internalFlags, tracker, cb) {
50715
+ function withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
50396
50716
  const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
50397
50717
  const context = {
50398
50718
  enclosingDeclaration,
@@ -50400,6 +50720,7 @@ function createTypeChecker(host) {
50400
50720
  flags: flags || 0 /* None */,
50401
50721
  internalFlags: internalFlags || 0 /* None */,
50402
50722
  tracker: void 0,
50723
+ unfoldDepth: verbosityLevel ?? -1,
50403
50724
  encounteredError: false,
50404
50725
  suppressReportInferenceFallback: false,
50405
50726
  reportedDiagnostic: false,
@@ -50421,13 +50742,18 @@ function createTypeChecker(host) {
50421
50742
  typeParameterNamesByText: void 0,
50422
50743
  typeParameterNamesByTextNextNameCount: void 0,
50423
50744
  enclosingSymbolTypes: /* @__PURE__ */ new Map(),
50424
- mapper: void 0
50745
+ mapper: void 0,
50746
+ depth: 0,
50747
+ couldUnfoldMore: false
50425
50748
  };
50426
50749
  context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
50427
50750
  const resultingNode = cb(context);
50428
50751
  if (context.truncating && context.flags & 1 /* NoTruncation */) {
50429
50752
  context.tracker.reportTruncationError();
50430
50753
  }
50754
+ if (out) {
50755
+ out.couldUnfoldMore = context.couldUnfoldMore;
50756
+ }
50431
50757
  return context.encounteredError ? void 0 : resultingNode;
50432
50758
  }
50433
50759
  function addSymbolTypeToContext(context, symbol, type) {
@@ -50446,16 +50772,36 @@ function createTypeChecker(host) {
50446
50772
  function saveRestoreFlags(context) {
50447
50773
  const flags = context.flags;
50448
50774
  const internalFlags = context.internalFlags;
50775
+ const depth = context.depth;
50449
50776
  return restore;
50450
50777
  function restore() {
50451
50778
  context.flags = flags;
50452
50779
  context.internalFlags = internalFlags;
50780
+ context.depth = depth;
50453
50781
  }
50454
50782
  }
50455
50783
  function checkTruncationLength(context) {
50456
50784
  if (context.truncating) return context.truncating;
50457
50785
  return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
50458
50786
  }
50787
+ function couldUnfoldType(type, context) {
50788
+ var _a;
50789
+ if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
50790
+ return false;
50791
+ }
50792
+ return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
50793
+ }
50794
+ function canUnfoldType(type, context) {
50795
+ var _a;
50796
+ if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
50797
+ return false;
50798
+ }
50799
+ const result = context.depth < context.unfoldDepth;
50800
+ if (!result) {
50801
+ context.couldUnfoldMore = true;
50802
+ }
50803
+ return result;
50804
+ }
50459
50805
  function typeToTypeNodeHelper(type, context) {
50460
50806
  const restoreFlags = saveRestoreFlags(context);
50461
50807
  const typeNode = typeToTypeNodeWorker(type, context);
@@ -50603,16 +50949,27 @@ function createTypeChecker(host) {
50603
50949
  return factory.createThisTypeNode();
50604
50950
  }
50605
50951
  if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
50606
- const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
50607
- if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
50608
- if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
50609
- return factory.createArrayTypeNode(typeArgumentNodes[0]);
50952
+ if (!canUnfoldType(type, context)) {
50953
+ const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
50954
+ if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
50955
+ if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
50956
+ return factory.createArrayTypeNode(typeArgumentNodes[0]);
50957
+ }
50958
+ return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
50610
50959
  }
50611
- return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
50960
+ context.depth += 1;
50612
50961
  }
50613
50962
  const objectFlags = getObjectFlags(type);
50614
50963
  if (objectFlags & 4 /* Reference */) {
50615
50964
  Debug.assert(!!(type.flags & 524288 /* Object */));
50965
+ if (canUnfoldType(type, context)) {
50966
+ context.depth += 1;
50967
+ return createAnonymousTypeNode(
50968
+ type,
50969
+ /*forceClassExpansion*/
50970
+ true
50971
+ );
50972
+ }
50616
50973
  return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
50617
50974
  }
50618
50975
  if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
@@ -50642,6 +50999,14 @@ function createTypeChecker(host) {
50642
50999
  void 0
50643
51000
  );
50644
51001
  }
51002
+ if (objectFlags & 3 /* ClassOrInterface */ && canUnfoldType(type, context)) {
51003
+ context.depth += 1;
51004
+ return createAnonymousTypeNode(
51005
+ type,
51006
+ /*forceClassExpansion*/
51007
+ true
51008
+ );
51009
+ }
50645
51010
  if (type.symbol) {
50646
51011
  return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
50647
51012
  }
@@ -50845,7 +51210,7 @@ function createTypeChecker(host) {
50845
51210
  }
50846
51211
  return result;
50847
51212
  }
50848
- function createAnonymousTypeNode(type2) {
51213
+ function createAnonymousTypeNode(type2, forceClassExpansion = false) {
50849
51214
  var _a2, _b2;
50850
51215
  const typeId = type2.id;
50851
51216
  const symbol = type2.symbol;
@@ -50868,7 +51233,7 @@ function createTypeChecker(host) {
50868
51233
  const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
50869
51234
  if (isJSConstructor(symbol.valueDeclaration)) {
50870
51235
  return symbolToTypeNode(symbol, context, isInstanceType);
50871
- } else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
51236
+ } else if (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
50872
51237
  symbol,
50873
51238
  context.enclosingDeclaration,
50874
51239
  isInstanceType,
@@ -50892,7 +51257,7 @@ function createTypeChecker(host) {
50892
51257
  function shouldWriteTypeOfFunctionSymbol() {
50893
51258
  var _a3;
50894
51259
  const isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method
50895
- some(symbol.declarations, (declaration) => isStatic(declaration));
51260
+ some(symbol.declarations, (declaration) => isStatic(declaration) && !isLateBindableIndexSignature(getNameOfDeclaration(declaration)));
50896
51261
  const isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol
50897
51262
  forEach(symbol.declarations, (declaration) => declaration.parent.kind === 307 /* SourceFile */ || declaration.parent.kind === 268 /* ModuleBlock */));
50898
51263
  if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
@@ -50912,7 +51277,7 @@ function createTypeChecker(host) {
50912
51277
  if (id && !context.symbolDepth) {
50913
51278
  context.symbolDepth = /* @__PURE__ */ new Map();
50914
51279
  }
50915
- const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
51280
+ const links = context.unfoldDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
50916
51281
  const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
50917
51282
  if (links) {
50918
51283
  links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
@@ -51195,6 +51560,38 @@ function createTypeChecker(host) {
51195
51560
  ids.unshift(state);
51196
51561
  return ids;
51197
51562
  }
51563
+ function indexInfoToObjectComputedNamesOrSignatureDeclaration(indexInfo, context2, typeNode) {
51564
+ if (indexInfo.components) {
51565
+ const allComponentComputedNamesSerializable = every(indexInfo.components, (e) => {
51566
+ var _a2;
51567
+ return !!(e.name && isComputedPropertyName(e.name) && isEntityNameExpression(e.name.expression) && context2.enclosingDeclaration && ((_a2 = isEntityNameVisible(
51568
+ e.name.expression,
51569
+ context2.enclosingDeclaration,
51570
+ /*shouldComputeAliasToMakeVisible*/
51571
+ false
51572
+ )) == null ? void 0 : _a2.accessibility) === 0 /* Accessible */);
51573
+ });
51574
+ if (allComponentComputedNamesSerializable) {
51575
+ const newComponents = filter(indexInfo.components, (e) => {
51576
+ return !hasLateBindableName(e);
51577
+ });
51578
+ return map(newComponents, (e) => {
51579
+ trackComputedName(e.name.expression, context2.enclosingDeclaration, context2);
51580
+ return setTextRange2(
51581
+ context2,
51582
+ factory.createPropertySignature(
51583
+ indexInfo.isReadonly ? [factory.createModifier(148 /* ReadonlyKeyword */)] : void 0,
51584
+ e.name,
51585
+ (isPropertySignature(e) || isPropertyDeclaration(e) || isMethodSignature(e) || isMethodDeclaration(e) || isGetAccessor(e) || isSetAccessor(e)) && e.questionToken ? factory.createToken(58 /* QuestionToken */) : void 0,
51586
+ typeNode || typeToTypeNodeHelper(getTypeOfSymbol(e.symbol), context2)
51587
+ ),
51588
+ e
51589
+ );
51590
+ });
51591
+ }
51592
+ }
51593
+ return [indexInfoToIndexSignatureDeclarationHelper(indexInfo, context2, typeNode)];
51594
+ }
51198
51595
  function createTypeNodesFromResolvedType(resolvedType) {
51199
51596
  if (checkTruncationLength(context)) {
51200
51597
  if (context.flags & 1 /* NoTruncation */) {
@@ -51219,7 +51616,7 @@ function createTypeChecker(host) {
51219
51616
  typeElements.push(signatureToSignatureDeclarationHelper(signature, 180 /* ConstructSignature */, context));
51220
51617
  }
51221
51618
  for (const info of resolvedType.indexInfos) {
51222
- typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : void 0));
51619
+ typeElements.push(...indexInfoToObjectComputedNamesOrSignatureDeclaration(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : void 0));
51223
51620
  }
51224
51621
  const properties = resolvedType.properties;
51225
51622
  if (!properties) {
@@ -51827,7 +52224,7 @@ function createTypeChecker(host) {
51827
52224
  return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
51828
52225
  }
51829
52226
  function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
51830
- return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
52227
+ return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
51831
52228
  }
51832
52229
  function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
51833
52230
  const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
@@ -51908,7 +52305,7 @@ function createTypeChecker(host) {
51908
52305
  if (!context.tracker.canTrackSymbol) return;
51909
52306
  const firstIdentifier = getFirstIdentifier(accessExpression);
51910
52307
  const name = resolveName(
51911
- firstIdentifier,
52308
+ enclosingDeclaration,
51912
52309
  firstIdentifier.escapedText,
51913
52310
  111551 /* Value */ | 1048576 /* ExportValue */,
51914
52311
  /*nameNotFoundMessage*/
@@ -51918,6 +52315,19 @@ function createTypeChecker(host) {
51918
52315
  );
51919
52316
  if (name) {
51920
52317
  context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */);
52318
+ } else {
52319
+ const fallback = resolveName(
52320
+ firstIdentifier,
52321
+ firstIdentifier.escapedText,
52322
+ 111551 /* Value */ | 1048576 /* ExportValue */,
52323
+ /*nameNotFoundMessage*/
52324
+ void 0,
52325
+ /*isUse*/
52326
+ true
52327
+ );
52328
+ if (fallback) {
52329
+ context.tracker.trackSymbol(fallback, enclosingDeclaration, 111551 /* Value */);
52330
+ }
51921
52331
  }
51922
52332
  }
51923
52333
  function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
@@ -52461,7 +52871,7 @@ function createTypeChecker(host) {
52461
52871
  let result;
52462
52872
  const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
52463
52873
  const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
52464
- if (decl) {
52874
+ if (!couldUnfoldType(type, context) && decl) {
52465
52875
  if (isAccessor(decl)) {
52466
52876
  result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
52467
52877
  } else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
@@ -56577,12 +56987,7 @@ function createTypeChecker(host) {
56577
56987
  addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
56578
56988
  callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */));
56579
56989
  constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */));
56580
- const inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(
56581
- stringType,
56582
- anyType,
56583
- /*isReadonly*/
56584
- false
56585
- )];
56990
+ const inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [anyBaseTypeIndexInfo];
56586
56991
  indexInfos = concatenate(indexInfos, filter(inheritedIndexInfos, (info) => !findIndexInfo(indexInfos, info.keyType)));
56587
56992
  }
56588
56993
  }
@@ -57108,12 +57513,7 @@ function createTypeChecker(host) {
57108
57513
  members = createSymbolTable(getNamedOrIndexSignatureMembers(members));
57109
57514
  addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
57110
57515
  } else if (baseConstructorType === anyType) {
57111
- baseConstructorIndexInfo = createIndexInfo(
57112
- stringType,
57113
- anyType,
57114
- /*isReadonly*/
57115
- false
57116
- );
57516
+ baseConstructorIndexInfo = anyBaseTypeIndexInfo;
57117
57517
  }
57118
57518
  }
57119
57519
  const indexSymbol = getIndexSymbolFromSymbolTable(members);
@@ -58742,8 +59142,8 @@ function createTypeChecker(host) {
58742
59142
  function getIndexSymbolFromSymbolTable(symbolTable) {
58743
59143
  return symbolTable.get("__index" /* Index */);
58744
59144
  }
58745
- function createIndexInfo(keyType, type, isReadonly, declaration) {
58746
- return { keyType, type, isReadonly, declaration };
59145
+ function createIndexInfo(keyType, type, isReadonly, declaration, components) {
59146
+ return { keyType, type, isReadonly, declaration, components };
58747
59147
  }
58748
59148
  function getIndexInfosOfSymbol(symbol) {
58749
59149
  const indexSymbol = getIndexSymbol(symbol);
@@ -59183,11 +59583,14 @@ function createTypeChecker(host) {
59183
59583
  function isNoInferType(type) {
59184
59584
  return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
59185
59585
  }
59186
- function getSubstitutionType(baseType, constraint) {
59187
- return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
59586
+ function isNarrowingSubstitutionType(type) {
59587
+ return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /* IsNarrowingType */);
59188
59588
  }
59189
- function getOrCreateSubstitutionType(baseType, constraint) {
59190
- const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
59589
+ function getSubstitutionType(baseType, constraint, isNarrowed) {
59590
+ return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
59591
+ }
59592
+ function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
59593
+ const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
59191
59594
  const cached = substitutionTypes.get(id);
59192
59595
  if (cached) {
59193
59596
  return cached;
@@ -59195,6 +59598,9 @@ function createTypeChecker(host) {
59195
59598
  const result = createType(33554432 /* Substitution */);
59196
59599
  result.baseType = baseType;
59197
59600
  result.constraint = constraint;
59601
+ if (isNarrowed) {
59602
+ result.objectFlags |= 16777216 /* IsNarrowingType */;
59603
+ }
59198
59604
  substitutionTypes.set(id, result);
59199
59605
  return result;
59200
59606
  }
@@ -59256,6 +59662,9 @@ function createTypeChecker(host) {
59256
59662
  case "Number":
59257
59663
  checkNoTypeArguments(node);
59258
59664
  return numberType;
59665
+ case "BigInt":
59666
+ checkNoTypeArguments(node);
59667
+ return bigintType;
59259
59668
  case "Boolean":
59260
59669
  checkNoTypeArguments(node);
59261
59670
  return booleanType;
@@ -61397,7 +61806,7 @@ function createTypeChecker(host) {
61397
61806
  function isDeferredType(type, checkTuples) {
61398
61807
  return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
61399
61808
  }
61400
- function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
61809
+ function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing) {
61401
61810
  let result;
61402
61811
  let extraTypes;
61403
61812
  let tailCount = 0;
@@ -61414,10 +61823,11 @@ function createTypeChecker(host) {
61414
61823
  if (checkType === wildcardType || extendsType === wildcardType) {
61415
61824
  return wildcardType;
61416
61825
  }
61826
+ const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
61417
61827
  const checkTypeNode = skipTypeParentheses(root.node.checkType);
61418
61828
  const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
61419
61829
  const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
61420
- const checkTypeDeferred = isDeferredType(checkType, checkTuples);
61830
+ const checkTypeDeferred = isDeferredType(effectiveCheckType, checkTuples);
61421
61831
  let combinedMapper;
61422
61832
  if (root.inferTypeParameters) {
61423
61833
  const context = createInferenceContext(
@@ -61436,8 +61846,8 @@ function createTypeChecker(host) {
61436
61846
  }
61437
61847
  const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
61438
61848
  if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
61439
- if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
61440
- if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
61849
+ if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (effectiveCheckType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(effectiveCheckType), getPermissiveInstantiation(inferredExtendsType)))) {
61850
+ if (effectiveCheckType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(effectiveCheckType)))) {
61441
61851
  (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
61442
61852
  }
61443
61853
  const falseType2 = getTypeFromTypeNode(root.node.falseType);
@@ -61454,7 +61864,7 @@ function createTypeChecker(host) {
61454
61864
  result = instantiateType(falseType2, mapper);
61455
61865
  break;
61456
61866
  }
61457
- if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
61867
+ if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(effectiveCheckType), getRestrictiveInstantiation(inferredExtendsType))) {
61458
61868
  const trueType2 = getTypeFromTypeNode(root.node.trueType);
61459
61869
  const trueMapper = combinedMapper || mapper;
61460
61870
  if (canTailRecurse(trueType2, trueMapper)) {
@@ -61809,7 +62219,7 @@ function createTypeChecker(host) {
61809
62219
  return result;
61810
62220
  }
61811
62221
  function getIndexInfoWithReadonly(info, readonly) {
61812
- return info.isReadonly !== readonly ? createIndexInfo(info.keyType, info.type, readonly, info.declaration) : info;
62222
+ return info.isReadonly !== readonly ? createIndexInfo(info.keyType, info.type, readonly, info.declaration, info.components) : info;
61813
62223
  }
61814
62224
  function createLiteralType(flags, value, symbol, regularType) {
61815
62225
  const type = createTypeWithSymbol(flags, symbol);
@@ -62420,8 +62830,39 @@ function createTypeChecker(host) {
62420
62830
  if (!result) {
62421
62831
  const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
62422
62832
  const checkType = root.checkType;
62423
- const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
62424
- result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
62833
+ let distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
62834
+ let narrowingBaseType;
62835
+ const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
62836
+ if (forNarrowing) {
62837
+ narrowingBaseType = distributionType.baseType;
62838
+ distributionType = getReducedType(distributionType.constraint);
62839
+ }
62840
+ if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
62841
+ if (narrowingBaseType) {
62842
+ result = mapTypeToIntersection(
62843
+ distributionType,
62844
+ (t) => getConditionalType(
62845
+ root,
62846
+ prependTypeMapping(checkType, getSubstitutionType(
62847
+ narrowingBaseType,
62848
+ t,
62849
+ /*isNarrowed*/
62850
+ true
62851
+ ), newMapper),
62852
+ forConstraint,
62853
+ /*aliasSymbol*/
62854
+ void 0,
62855
+ /*aliasTypeArguments*/
62856
+ void 0,
62857
+ forNarrowing
62858
+ )
62859
+ );
62860
+ } else {
62861
+ result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
62862
+ }
62863
+ } else {
62864
+ result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
62865
+ }
62425
62866
  root.instantiations.set(id, result);
62426
62867
  }
62427
62868
  return result;
@@ -62568,7 +63009,7 @@ function createTypeChecker(host) {
62568
63009
  return type.restrictiveInstantiation;
62569
63010
  }
62570
63011
  function instantiateIndexInfo(info, mapper) {
62571
- return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration);
63012
+ return createIndexInfo(info.keyType, instantiateType(info.type, mapper), info.isReadonly, info.declaration, info.components);
62572
63013
  }
62573
63014
  function isContextSensitive(node) {
62574
63015
  Debug.assert(node.kind !== 174 /* MethodDeclaration */ || isObjectLiteralMethod(node));
@@ -63564,10 +64005,12 @@ function createTypeChecker(host) {
63564
64005
  function shouldNormalizeIntersection(type) {
63565
64006
  let hasInstantiable = false;
63566
64007
  let hasNullableOrEmpty = false;
64008
+ let hasSubstitution = false;
63567
64009
  for (const t of type.types) {
63568
64010
  hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
63569
64011
  hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
63570
- if (hasInstantiable && hasNullableOrEmpty) return true;
64012
+ hasSubstitution || (hasSubstitution = isNarrowingSubstitutionType(t));
64013
+ if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
63571
64014
  }
63572
64015
  return false;
63573
64016
  }
@@ -66699,7 +67142,7 @@ function createTypeChecker(host) {
66699
67142
  }
66700
67143
  }
66701
67144
  }
66702
- const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, sameMap(getIndexInfosOfType(type), (info) => createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly)));
67145
+ const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, sameMap(getIndexInfosOfType(type), (info) => createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly, info.declaration, info.components)));
66703
67146
  result.objectFlags |= getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */);
66704
67147
  return result;
66705
67148
  }
@@ -68141,6 +68584,7 @@ function createTypeChecker(host) {
68141
68584
  return target.kind === 108 /* SuperKeyword */;
68142
68585
  case 235 /* NonNullExpression */:
68143
68586
  case 217 /* ParenthesizedExpression */:
68587
+ case 238 /* SatisfiesExpression */:
68144
68588
  return isMatchingReference(source.expression, target);
68145
68589
  case 211 /* PropertyAccessExpression */:
68146
68590
  case 212 /* ElementAccessExpression */:
@@ -68726,6 +69170,18 @@ function createTypeChecker(host) {
68726
69170
  }
68727
69171
  return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
68728
69172
  }
69173
+ function mapTypeToIntersection(type, mapper) {
69174
+ if (type.flags & 131072 /* Never */) {
69175
+ return type;
69176
+ }
69177
+ if (!(type.flags & 1048576 /* Union */)) {
69178
+ return mapper(type);
69179
+ }
69180
+ const origin = type.origin;
69181
+ const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
69182
+ const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
69183
+ return getIntersectionType(mappedTypes);
69184
+ }
68729
69185
  function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
68730
69186
  return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
68731
69187
  }
@@ -69991,6 +70447,7 @@ function createTypeChecker(host) {
69991
70447
  if (checkDerived) {
69992
70448
  return filterType(type, (t) => !isTypeDerivedFrom(t, candidate));
69993
70449
  }
70450
+ type = type.flags & 2 /* Unknown */ ? unknownUnionType : type;
69994
70451
  const trueType2 = getNarrowedType(
69995
70452
  type,
69996
70453
  candidate,
@@ -69999,7 +70456,7 @@ function createTypeChecker(host) {
69999
70456
  /*checkDerived*/
70000
70457
  false
70001
70458
  );
70002
- return filterType(type, (t) => !isTypeSubsetOf(t, trueType2));
70459
+ return recombineUnknownType(filterType(type, (t) => !isTypeSubsetOf(t, trueType2)));
70003
70460
  }
70004
70461
  if (type.flags & 3 /* AnyOrUnknown */) {
70005
70462
  return candidate;
@@ -70097,6 +70554,7 @@ function createTypeChecker(host) {
70097
70554
  return narrowTypeByCallExpression(type, expr, assumeTrue);
70098
70555
  case 217 /* ParenthesizedExpression */:
70099
70556
  case 235 /* NonNullExpression */:
70557
+ case 238 /* SatisfiesExpression */:
70100
70558
  return narrowType(type, expr.expression, assumeTrue);
70101
70559
  case 226 /* BinaryExpression */:
70102
70560
  return narrowTypeByBinaryExpression(type, expr, assumeTrue);
@@ -70308,11 +70766,11 @@ function createTypeChecker(host) {
70308
70766
  ));
70309
70767
  return contextualType && !isGenericType(contextualType);
70310
70768
  }
70311
- function getNarrowableTypeForReference(type, reference, checkMode) {
70769
+ function getNarrowableTypeForReference(type, reference, checkMode, forReturnTypeNarrowing) {
70312
70770
  if (isNoInferType(type)) {
70313
70771
  type = type.baseType;
70314
70772
  }
70315
- const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70773
+ const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (forReturnTypeNarrowing || isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
70316
70774
  return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
70317
70775
  }
70318
70776
  function isExportOrExportExpression(location) {
@@ -70460,12 +70918,13 @@ function createTypeChecker(host) {
70460
70918
  const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found : void 0;
70461
70919
  const jsxFactoryNamespace = getJsxNamespace(node);
70462
70920
  const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node;
70921
+ const shouldFactoryRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */;
70463
70922
  let jsxFactorySym;
70464
70923
  if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
70465
70924
  jsxFactorySym = resolveName(
70466
70925
  jsxFactoryLocation,
70467
70926
  jsxFactoryNamespace,
70468
- compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
70927
+ shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */,
70469
70928
  jsxFactoryRefErr,
70470
70929
  /*isUse*/
70471
70930
  true
@@ -70479,12 +70938,13 @@ function createTypeChecker(host) {
70479
70938
  }
70480
70939
  if (isJsxOpeningFragment(node)) {
70481
70940
  const file = getSourceFileOfNode(node);
70482
- const localJsxNamespace = getLocalJsxNamespace(file);
70483
- if (localJsxNamespace) {
70941
+ const entity = getJsxFactoryEntity(file);
70942
+ if (entity) {
70943
+ const localJsxNamespace = getFirstIdentifier(entity).escapedText;
70484
70944
  resolveName(
70485
70945
  jsxFactoryLocation,
70486
70946
  localJsxNamespace,
70487
- compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
70947
+ shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */,
70488
70948
  jsxFactoryRefErr,
70489
70949
  /*isUse*/
70490
70950
  true
@@ -71437,9 +71897,16 @@ function createTypeChecker(host) {
71437
71897
  function getContextualTypeForReturnExpression(node, contextFlags) {
71438
71898
  const func = getContainingFunction(node);
71439
71899
  if (func) {
71900
+ const functionFlags = getFunctionFlags(func);
71901
+ const links = getNodeLinks(node);
71902
+ if (links.contextualReturnType) {
71903
+ if (functionFlags & 2 /* Async */) {
71904
+ return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
71905
+ }
71906
+ return links.contextualReturnType;
71907
+ }
71440
71908
  let contextualReturnType = getContextualReturnType(func, contextFlags);
71441
71909
  if (contextualReturnType) {
71442
- const functionFlags = getFunctionFlags(func);
71443
71910
  if (functionFlags & 1 /* Generator */) {
71444
71911
  const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
71445
71912
  if (contextualReturnType.flags & 1048576 /* Union */) {
@@ -72137,6 +72604,13 @@ function createTypeChecker(host) {
72137
72604
  if (index >= 0) {
72138
72605
  return contextualTypes[index];
72139
72606
  }
72607
+ const links = getNodeLinks(node);
72608
+ if (links.contextualReturnType) {
72609
+ if (node.flags & 65536 /* AwaitContext */) {
72610
+ return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
72611
+ }
72612
+ return links.contextualReturnType;
72613
+ }
72140
72614
  const { parent } = node;
72141
72615
  switch (parent.kind) {
72142
72616
  case 260 /* VariableDeclaration */:
@@ -72718,16 +73192,33 @@ function createTypeChecker(host) {
72718
73192
  const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
72719
73193
  return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
72720
73194
  }
73195
+ function isSymbolWithComputedName(symbol) {
73196
+ var _a;
73197
+ const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
73198
+ return firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name);
73199
+ }
72721
73200
  function getObjectLiteralIndexInfo(isReadonly, offset, properties, keyType) {
73201
+ var _a;
72722
73202
  const propTypes = [];
73203
+ let components;
72723
73204
  for (let i = offset; i < properties.length; i++) {
72724
73205
  const prop = properties[i];
72725
73206
  if (keyType === stringType && !isSymbolWithSymbolName(prop) || keyType === numberType && isSymbolWithNumericName(prop) || keyType === esSymbolType && isSymbolWithSymbolName(prop)) {
72726
73207
  propTypes.push(getTypeOfSymbol(properties[i]));
73208
+ if (isSymbolWithComputedName(properties[i])) {
73209
+ components = append(components, (_a = properties[i].declarations) == null ? void 0 : _a[0]);
73210
+ }
72727
73211
  }
72728
73212
  }
72729
73213
  const unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType;
72730
- return createIndexInfo(keyType, unionType, isReadonly);
73214
+ return createIndexInfo(
73215
+ keyType,
73216
+ unionType,
73217
+ isReadonly,
73218
+ /*declaration*/
73219
+ void 0,
73220
+ components
73221
+ );
72731
73222
  }
72732
73223
  function getImmediateAliasedSymbol(symbol) {
72733
73224
  Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
@@ -73262,6 +73753,9 @@ function createTypeChecker(host) {
73262
73753
  return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
73263
73754
  }
73264
73755
  function getJsxElementChildrenPropertyName(jsxNamespace) {
73756
+ if (compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */) {
73757
+ return "children";
73758
+ }
73265
73759
  return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
73266
73760
  }
73267
73761
  function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
@@ -74045,6 +74539,13 @@ function createTypeChecker(host) {
74045
74539
  return getIntersectionType(x);
74046
74540
  }
74047
74541
  function reportNonexistentProperty(propNode, containingType, isUncheckedJS) {
74542
+ const links = getNodeLinks(propNode);
74543
+ const cache = links.nonExistentPropCheckCache || (links.nonExistentPropCheckCache = /* @__PURE__ */ new Set());
74544
+ const key = `${getTypeId(containingType)}|${isUncheckedJS}`;
74545
+ if (cache.has(key)) {
74546
+ return;
74547
+ }
74548
+ cache.add(key);
74048
74549
  let errorInfo;
74049
74550
  let relatedInfo;
74050
74551
  if (!isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 402784252 /* Primitive */)) {
@@ -74813,8 +75314,8 @@ function createTypeChecker(host) {
74813
75314
  }
74814
75315
  }
74815
75316
  function getEffectiveCheckNode(argument) {
74816
- argument = skipParentheses(argument);
74817
- return isSatisfiesExpression(argument) ? skipParentheses(argument.expression) : argument;
75317
+ const flags = isInJSFile(argument) ? 1 /* Parentheses */ | 32 /* Satisfies */ | -2147483648 /* ExcludeJSDocTypeAssertion */ : 1 /* Parentheses */ | 32 /* Satisfies */;
75318
+ return skipOuterExpressions(argument, flags);
74818
75319
  }
74819
75320
  function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
74820
75321
  const errorOutputContainer = { errors: void 0, skipLogging: true };
@@ -75239,11 +75740,16 @@ function createTypeChecker(host) {
75239
75740
  if (!result) {
75240
75741
  result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
75241
75742
  }
75743
+ const links = getNodeLinks(node);
75744
+ if (links.resolvedSignature !== resolvingSignature && !candidatesOutArray) {
75745
+ Debug.assert(links.resolvedSignature);
75746
+ return links.resolvedSignature;
75747
+ }
75242
75748
  if (result) {
75243
75749
  return result;
75244
75750
  }
75245
75751
  result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
75246
- getNodeLinks(node).resolvedSignature = result;
75752
+ links.resolvedSignature = result;
75247
75753
  if (reportErrors2) {
75248
75754
  if (!headMessage && isInstanceof) {
75249
75755
  headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
@@ -76003,12 +76509,14 @@ function createTypeChecker(host) {
76003
76509
  const sourceFileLinks = getNodeLinks(getSourceFileOfNode(node));
76004
76510
  if (sourceFileLinks.jsxFragmentType !== void 0) return sourceFileLinks.jsxFragmentType;
76005
76511
  const jsxFragmentFactoryName = getJsxNamespace(node);
76006
- if (jsxFragmentFactoryName === "null") return sourceFileLinks.jsxFragmentType = anyType;
76512
+ const shouldResolveFactoryReference = (compilerOptions.jsx === 2 /* React */ || compilerOptions.jsxFragmentFactory !== void 0) && jsxFragmentFactoryName !== "null";
76513
+ if (!shouldResolveFactoryReference) return sourceFileLinks.jsxFragmentType = anyType;
76514
+ const shouldModuleRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */;
76007
76515
  const jsxFactoryRefErr = diagnostics ? Diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found : void 0;
76008
76516
  const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName(
76009
76517
  node,
76010
76518
  jsxFragmentFactoryName,
76011
- compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
76519
+ shouldModuleRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */,
76012
76520
  /*nameNotFoundMessage*/
76013
76521
  jsxFactoryRefErr,
76014
76522
  /*isUse*/
@@ -76127,12 +76635,9 @@ function createTypeChecker(host) {
76127
76635
  resolutionStart = resolutionTargets.length;
76128
76636
  }
76129
76637
  links.resolvedSignature = resolvingSignature;
76130
- let result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
76638
+ const result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
76131
76639
  resolutionStart = saveResolutionStart;
76132
76640
  if (result !== resolvingSignature) {
76133
- if (links.resolvedSignature !== resolvingSignature) {
76134
- result = links.resolvedSignature;
76135
- }
76136
76641
  links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
76137
76642
  }
76138
76643
  return result;
@@ -76711,12 +77216,12 @@ function createTypeChecker(host) {
76711
77216
  }
76712
77217
  }
76713
77218
  function checkImportMetaProperty(node) {
76714
- if (moduleKind === 100 /* Node16 */ || moduleKind === 199 /* NodeNext */) {
77219
+ if (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
76715
77220
  if (getSourceFileOfNode(node).impliedNodeFormat !== 99 /* ESNext */) {
76716
77221
  error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
76717
77222
  }
76718
77223
  } else if (moduleKind < 6 /* ES2020 */ && moduleKind !== 4 /* System */) {
76719
- error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext);
77224
+ error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_node18_or_nodenext);
76720
77225
  }
76721
77226
  const file = getSourceFileOfNode(node);
76722
77227
  Debug.assert(!!(file.flags & 8388608 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
@@ -77545,7 +78050,7 @@ function createTypeChecker(host) {
77545
78050
  }
77546
78051
  return !someType(operandConstraint, (t) => getTypeFacts(t, notEqualFacts) === notEqualFacts);
77547
78052
  }
77548
- const type = checkExpressionCached(node.expression);
78053
+ const type = getBaseConstraintOrType(checkExpressionCached(node.expression));
77549
78054
  if (!isLiteralType(type)) {
77550
78055
  return false;
77551
78056
  }
@@ -77808,19 +78313,7 @@ function createTypeChecker(host) {
77808
78313
  const exprType = checkExpression(node.body);
77809
78314
  const returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
77810
78315
  if (returnOrPromisedType) {
77811
- const effectiveCheckNode = getEffectiveCheckNode(node.body);
77812
- if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) {
77813
- const awaitedType = checkAwaitedType(
77814
- exprType,
77815
- /*withAlias*/
77816
- false,
77817
- effectiveCheckNode,
77818
- Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
77819
- );
77820
- checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
77821
- } else {
77822
- checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
77823
- }
78316
+ checkReturnExpression(node, returnOrPromisedType, node.body, node.body, exprType);
77824
78317
  }
77825
78318
  }
77826
78319
  }
@@ -77874,7 +78367,7 @@ function createTypeChecker(host) {
77874
78367
  }
77875
78368
  if (isReadonlySymbol(symbol)) {
77876
78369
  if (symbol.flags & 4 /* Property */ && isAccessExpression(expr) && expr.expression.kind === 110 /* ThisKeyword */) {
77877
- const ctor = getContainingFunction(expr);
78370
+ const ctor = getControlFlowContainer(expr);
77878
78371
  if (!(ctor && (ctor.kind === 176 /* Constructor */ || isJSConstructor(ctor)))) {
77879
78372
  return true;
77880
78373
  }
@@ -77903,7 +78396,7 @@ function createTypeChecker(host) {
77903
78396
  return false;
77904
78397
  }
77905
78398
  function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
77906
- const node = skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */);
78399
+ const node = skipOuterExpressions(expr, 38 /* Assertions */ | 1 /* Parentheses */);
77907
78400
  if (node.kind !== 80 /* Identifier */ && !isAccessExpression(node)) {
77908
78401
  error(expr, invalidReferenceMessage);
77909
78402
  return false;
@@ -77970,6 +78463,7 @@ function createTypeChecker(host) {
77970
78463
  }
77971
78464
  switch (moduleKind) {
77972
78465
  case 100 /* Node16 */:
78466
+ case 101 /* Node18 */:
77973
78467
  case 199 /* NodeNext */:
77974
78468
  if (sourceFile.impliedNodeFormat === 1 /* CommonJS */) {
77975
78469
  span ?? (span = getSpanOfTokenAtPosition(sourceFile, node.pos));
@@ -77990,7 +78484,7 @@ function createTypeChecker(host) {
77990
78484
  // fallthrough
77991
78485
  default:
77992
78486
  span ?? (span = getSpanOfTokenAtPosition(sourceFile, node.pos));
77993
- const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher : Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher;
78487
+ const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher : Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher;
77994
78488
  diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message));
77995
78489
  hasError = true;
77996
78490
  break;
@@ -78554,7 +79048,7 @@ function createTypeChecker(host) {
78554
79048
  if (isBinaryExpression(right) && (right.operatorToken.kind === 57 /* BarBarToken */ || right.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
78555
79049
  grammarErrorOnNode(right, Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, tokenToString(right.operatorToken.kind), tokenToString(operatorToken.kind));
78556
79050
  }
78557
- const leftTarget = skipOuterExpressions(left, 31 /* All */);
79051
+ const leftTarget = skipOuterExpressions(left, 63 /* All */);
78558
79052
  const nullishSemantics = getSyntacticNullishnessSemantics(leftTarget);
78559
79053
  if (nullishSemantics !== 3 /* Sometimes */) {
78560
79054
  if (node.parent.kind === 226 /* BinaryExpression */) {
@@ -78574,7 +79068,9 @@ function createTypeChecker(host) {
78574
79068
  switch (node.kind) {
78575
79069
  case 223 /* AwaitExpression */:
78576
79070
  case 213 /* CallExpression */:
79071
+ case 215 /* TaggedTemplateExpression */:
78577
79072
  case 212 /* ElementAccessExpression */:
79073
+ case 236 /* MetaProperty */:
78578
79074
  case 214 /* NewExpression */:
78579
79075
  case 211 /* PropertyAccessExpression */:
78580
79076
  case 229 /* YieldExpression */:
@@ -78590,6 +79086,8 @@ function createTypeChecker(host) {
78590
79086
  case 56 /* AmpersandAmpersandToken */:
78591
79087
  case 77 /* AmpersandAmpersandEqualsToken */:
78592
79088
  return 3 /* Sometimes */;
79089
+ case 28 /* CommaToken */:
79090
+ return getSyntacticNullishnessSemantics(node.right);
78593
79091
  }
78594
79092
  return 2 /* Never */;
78595
79093
  case 227 /* ConditionalExpression */:
@@ -79769,6 +80267,9 @@ function createTypeChecker(host) {
79769
80267
  checkVariableLikeDeclaration(node);
79770
80268
  const func = getContainingFunction(node);
79771
80269
  if (hasSyntacticModifier(node, 31 /* ParameterPropertyModifier */)) {
80270
+ if (compilerOptions.erasableSyntaxOnly) {
80271
+ error(node, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
80272
+ }
79772
80273
  if (!(func.kind === 176 /* Constructor */ && nodeIsPresent(func.body))) {
79773
80274
  error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
79774
80275
  }
@@ -83042,7 +83543,6 @@ function createTypeChecker(host) {
83042
83543
  }
83043
83544
  const signature = getSignatureFromDeclaration(container);
83044
83545
  const returnType = getReturnTypeOfSignature(signature);
83045
- const functionFlags = getFunctionFlags(container);
83046
83546
  if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
83047
83547
  const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
83048
83548
  if (container.kind === 178 /* SetAccessor */) {
@@ -83050,26 +83550,249 @@ function createTypeChecker(host) {
83050
83550
  error(node, Diagnostics.Setters_cannot_return_a_value);
83051
83551
  }
83052
83552
  } else if (container.kind === 176 /* Constructor */) {
83053
- if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
83553
+ const exprType2 = node.expression ? checkExpressionCached(node.expression) : undefinedType;
83554
+ if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType2, returnType, node, node.expression)) {
83054
83555
  error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
83055
83556
  }
83056
83557
  } else if (getReturnTypeFromAnnotation(container)) {
83057
- const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
83058
- const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
83059
- exprType,
83060
- /*withAlias*/
83061
- false,
83062
- node,
83063
- Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
83064
- ) : exprType;
83065
- if (unwrappedReturnType) {
83066
- checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
83067
- }
83558
+ const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(container)) ?? returnType;
83559
+ checkReturnExpression(container, unwrappedReturnType, node, node.expression, exprType);
83068
83560
  }
83069
83561
  } else if (container.kind !== 176 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
83070
83562
  error(node, Diagnostics.Not_all_code_paths_return_a_value);
83071
83563
  }
83072
83564
  }
83565
+ function checkReturnExpression(container, unwrappedReturnType, node, expr, exprType, inConditionalExpression = false) {
83566
+ const excludeJSDocTypeAssertions = isInJSFile(node);
83567
+ const functionFlags = getFunctionFlags(container);
83568
+ if (expr) {
83569
+ const unwrappedExpr = skipParentheses(expr, excludeJSDocTypeAssertions);
83570
+ if (isConditionalExpression(unwrappedExpr)) {
83571
+ checkReturnExpression(
83572
+ container,
83573
+ unwrappedReturnType,
83574
+ node,
83575
+ unwrappedExpr.whenTrue,
83576
+ checkExpression(unwrappedExpr.whenTrue),
83577
+ /*inConditionalExpression*/
83578
+ true
83579
+ );
83580
+ checkReturnExpression(
83581
+ container,
83582
+ unwrappedReturnType,
83583
+ node,
83584
+ unwrappedExpr.whenFalse,
83585
+ checkExpression(unwrappedExpr.whenFalse),
83586
+ /*inConditionalExpression*/
83587
+ true
83588
+ );
83589
+ return;
83590
+ }
83591
+ }
83592
+ const inReturnStatement = node.kind === 253 /* ReturnStatement */;
83593
+ const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
83594
+ exprType,
83595
+ /*withAlias*/
83596
+ false,
83597
+ node,
83598
+ Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
83599
+ ) : exprType;
83600
+ const effectiveExpr = expr && getEffectiveCheckNode(expr);
83601
+ const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
83602
+ if (!(unwrappedReturnType.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */)) || !couldContainTypeVariables(unwrappedReturnType)) {
83603
+ checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
83604
+ return;
83605
+ }
83606
+ if (checkTypeAssignableTo(
83607
+ unwrappedExprType,
83608
+ unwrappedReturnType,
83609
+ /*errorNode*/
83610
+ void 0
83611
+ )) {
83612
+ return;
83613
+ }
83614
+ let narrowPosition = node;
83615
+ let narrowFlowNode = inReturnStatement && node.flowNode;
83616
+ if (expr && isConditionalExpression(expr.parent)) {
83617
+ narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
83618
+ narrowPosition = expr;
83619
+ }
83620
+ if (!narrowFlowNode) {
83621
+ checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
83622
+ return;
83623
+ }
83624
+ const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
83625
+ container,
83626
+ /*includeThisTypes*/
83627
+ false
83628
+ ), getEffectiveTypeParameterDeclarations(container));
83629
+ const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
83630
+ if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
83631
+ checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
83632
+ return;
83633
+ }
83634
+ const narrowedTypeParameters = [];
83635
+ const narrowedTypes = [];
83636
+ for (const [typeParam, symbol, reference] of narrowableTypeParameters) {
83637
+ const narrowReference = factory.cloneNode(reference);
83638
+ narrowReference.id = void 0;
83639
+ getNodeLinks(narrowReference).resolvedSymbol = symbol;
83640
+ setParent(narrowReference, narrowPosition.parent);
83641
+ narrowReference.flowNode = narrowFlowNode;
83642
+ const initialType = getNarrowableTypeForReference(
83643
+ typeParam,
83644
+ narrowReference,
83645
+ /*checkMode*/
83646
+ void 0,
83647
+ /*forReturnTypeNarrowing*/
83648
+ true
83649
+ );
83650
+ if (initialType === typeParam) {
83651
+ continue;
83652
+ }
83653
+ const flowType = getFlowTypeOfReference(narrowReference, initialType);
83654
+ const exprType2 = getTypeFromFlowType(flowType);
83655
+ if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
83656
+ continue;
83657
+ }
83658
+ const narrowedType = getSubstitutionType(
83659
+ typeParam,
83660
+ exprType2,
83661
+ /*isNarrowed*/
83662
+ true
83663
+ );
83664
+ narrowedTypeParameters.push(typeParam);
83665
+ narrowedTypes.push(narrowedType);
83666
+ }
83667
+ const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
83668
+ const narrowedReturnType = instantiateType(
83669
+ unwrappedReturnType,
83670
+ narrowMapper
83671
+ );
83672
+ if (expr) {
83673
+ const links = getNodeLinks(expr);
83674
+ if (!links.contextualReturnType) {
83675
+ links.contextualReturnType = narrowedReturnType;
83676
+ }
83677
+ }
83678
+ const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
83679
+ const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
83680
+ narrowedExprType,
83681
+ /*withAlias*/
83682
+ false,
83683
+ node,
83684
+ Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
83685
+ ) : narrowedExprType;
83686
+ checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
83687
+ }
83688
+ function getNarrowableTypeParameters(candidates) {
83689
+ const narrowableParams = [];
83690
+ for (const typeParam of candidates) {
83691
+ const constraint = getConstraintOfTypeParameter(typeParam);
83692
+ if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
83693
+ if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
83694
+ const declaration = typeParam.symbol.declarations[0];
83695
+ const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
83696
+ if (!isFunctionLike(container)) continue;
83697
+ let reference;
83698
+ let hasInvalidReference = false;
83699
+ for (const paramDecl of container.parameters) {
83700
+ const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
83701
+ if (!typeNode) continue;
83702
+ if (isTypeParameterReferenced(typeParam, typeNode)) {
83703
+ let candidateReference;
83704
+ if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
83705
+ if (reference) {
83706
+ hasInvalidReference = true;
83707
+ break;
83708
+ }
83709
+ reference = candidateReference;
83710
+ } else {
83711
+ hasInvalidReference = true;
83712
+ break;
83713
+ }
83714
+ }
83715
+ }
83716
+ if (!hasInvalidReference && reference) {
83717
+ const symbol = getResolvedSymbol(reference);
83718
+ if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
83719
+ }
83720
+ }
83721
+ }
83722
+ return narrowableParams;
83723
+ function getValidParameterReference(paramDecl, constraint) {
83724
+ if (!isIdentifier(paramDecl.name)) return;
83725
+ const isOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
83726
+ if (isOptional && !containsUndefinedType(constraint)) return;
83727
+ return paramDecl.name;
83728
+ }
83729
+ function isReferenceToTypeParameter(typeParam, node) {
83730
+ return getTypeFromTypeReference(node) === typeParam;
83731
+ }
83732
+ function isTypeParameterReferenced(typeParam, node) {
83733
+ return isReferenced(node);
83734
+ function isReferenced(node2) {
83735
+ if (isTypeReferenceNode(node2)) {
83736
+ return isReferenceToTypeParameter(typeParam, node2);
83737
+ }
83738
+ if (isTypeQueryNode(node2)) {
83739
+ return isTypeParameterPossiblyReferenced(typeParam, node2);
83740
+ }
83741
+ return !!forEachChild(node2, isReferenced);
83742
+ }
83743
+ }
83744
+ }
83745
+ function isNarrowableReturnType(returnType) {
83746
+ return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
83747
+ }
83748
+ function isNarrowableConditionalType(type, mapper) {
83749
+ const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
83750
+ const mapped = getMappedType(t, mapper);
83751
+ if (isNarrowingSubstitutionType(mapped)) {
83752
+ return mapped.baseType;
83753
+ }
83754
+ return mapped;
83755
+ });
83756
+ const id = `${type.id}:${getTypeListId(typeArguments)}`;
83757
+ let result = narrowableReturnTypeCache.get(id);
83758
+ if (result === void 0) {
83759
+ const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
83760
+ const instantiatedType = instantiateType(type, nonNarrowingMapper);
83761
+ result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
83762
+ narrowableReturnTypeCache.set(id, result);
83763
+ }
83764
+ return result;
83765
+ }
83766
+ function isNarrowableConditionalTypeWorker(type) {
83767
+ if (!type.root.isDistributive) {
83768
+ return false;
83769
+ }
83770
+ if (type.root.inferTypeParameters) {
83771
+ return false;
83772
+ }
83773
+ if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
83774
+ return false;
83775
+ }
83776
+ const constraintType = getConstraintOfTypeParameter(type.checkType);
83777
+ if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
83778
+ return false;
83779
+ }
83780
+ if (!everyType(type.extendsType, (extendsType) => some(
83781
+ constraintType.types,
83782
+ (constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
83783
+ ))) {
83784
+ return false;
83785
+ }
83786
+ const trueType2 = getTrueTypeFromConditionalType(type);
83787
+ const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
83788
+ if (!isValidTrueType) return false;
83789
+ const falseType2 = getFalseTypeFromConditionalType(type);
83790
+ const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
83791
+ return isValidFalseType;
83792
+ }
83793
+ function isConditionalType(type) {
83794
+ return !!(type.flags & 16777216 /* Conditional */);
83795
+ }
83073
83796
  function checkWithStatement(node) {
83074
83797
  if (!checkGrammarStatementInAmbientContext(node)) {
83075
83798
  if (node.flags & 65536 /* AwaitContext */) {
@@ -83201,7 +83924,7 @@ function createTypeChecker(host) {
83201
83924
  const typeDeclaration = symbol.valueDeclaration;
83202
83925
  if (typeDeclaration && isClassLike(typeDeclaration)) {
83203
83926
  for (const member of typeDeclaration.members) {
83204
- if (!isStatic(member) && !hasBindableName(member)) {
83927
+ if ((!isStaticIndex && !isStatic(member) || isStaticIndex && isStatic(member)) && !hasBindableName(member)) {
83205
83928
  const symbol2 = getSymbolOfDeclaration(member);
83206
83929
  checkIndexConstraintForProperty(type, symbol2, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol2));
83207
83930
  }
@@ -83652,6 +84375,13 @@ function createTypeChecker(host) {
83652
84375
  function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, member, errorNode) {
83653
84376
  const isJs = isInJSFile(node);
83654
84377
  const nodeInAmbientContext = !!(node.flags & 33554432 /* Ambient */);
84378
+ if (memberHasOverrideModifier && (member == null ? void 0 : member.valueDeclaration) && isClassElement(member.valueDeclaration) && member.valueDeclaration.name && isNonBindableDynamicName(member.valueDeclaration.name)) {
84379
+ error(
84380
+ errorNode,
84381
+ isJs ? Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_name_is_dynamic : Diagnostics.This_member_cannot_have_an_override_modifier_because_its_name_is_dynamic
84382
+ );
84383
+ return 2 /* HasInvalidOverride */;
84384
+ }
83655
84385
  if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
83656
84386
  const thisType = memberIsStatic ? staticType : typeWithThis;
83657
84387
  const baseType = memberIsStatic ? baseStaticType : baseWithThis;
@@ -84244,6 +84974,9 @@ function createTypeChecker(host) {
84244
84974
  checkCollisionsForDeclarationName(node, node.name);
84245
84975
  checkExportsOnMergedDeclarations(node);
84246
84976
  node.members.forEach(checkEnumMember);
84977
+ if (compilerOptions.erasableSyntaxOnly && !(node.flags & 33554432 /* Ambient */)) {
84978
+ error(node, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
84979
+ }
84247
84980
  computeEnumMemberValues(node);
84248
84981
  const enumSymbol = getSymbolOfDeclaration(node);
84249
84982
  const firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind);
@@ -84345,6 +85078,9 @@ function createTypeChecker(host) {
84345
85078
  checkExportsOnMergedDeclarations(node);
84346
85079
  const symbol = getSymbolOfDeclaration(node);
84347
85080
  if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext && isInstantiatedModule(node, shouldPreserveConstEnums(compilerOptions))) {
85081
+ if (compilerOptions.erasableSyntaxOnly) {
85082
+ error(node.name, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
85083
+ }
84348
85084
  if (getIsolatedModules(compilerOptions) && !getSourceFileOfNode(node).externalModuleIndicator) {
84349
85085
  error(node.name, Diagnostics.Namespaces_are_not_allowed_in_global_script_files_when_0_is_enabled_If_this_file_is_not_intended_to_be_a_global_script_set_moduleDetection_to_force_or_add_an_empty_export_statement, isolatedModulesLikeFlagName);
84350
85086
  }
@@ -84658,10 +85394,20 @@ function createTypeChecker(host) {
84658
85394
  if (validForTypeAttributes && override) {
84659
85395
  return;
84660
85396
  }
84661
- const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier);
84662
- if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
84663
- const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
84664
- return grammarErrorOnNode(node, message);
85397
+ if (!moduleSupportsImportAttributes(moduleKind)) {
85398
+ return grammarErrorOnNode(
85399
+ node,
85400
+ isImportAttributes2 ? Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_preserve : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_node18_nodenext_or_preserve
85401
+ );
85402
+ }
85403
+ if (moduleKind === 199 /* NodeNext */ && !isImportAttributes2) {
85404
+ return grammarErrorOnFirstToken(node, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_asserts);
85405
+ }
85406
+ if (declaration.moduleSpecifier && getEmitSyntaxForModuleSpecifierExpression(declaration.moduleSpecifier) === 1 /* CommonJS */) {
85407
+ return grammarErrorOnNode(
85408
+ node,
85409
+ isImportAttributes2 ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls
85410
+ );
84665
85411
  }
84666
85412
  const isTypeOnly = isJSDocImportTag(declaration) || (isImportDeclaration(declaration) ? (_a = declaration.importClause) == null ? void 0 : _a.isTypeOnly : declaration.isTypeOnly);
84667
85413
  if (isTypeOnly) {
@@ -84702,7 +85448,7 @@ function createTypeChecker(host) {
84702
85448
  }
84703
85449
  }
84704
85450
  }
84705
- if (isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) {
85451
+ if (!importClause.isTypeOnly && 101 /* Node18 */ <= moduleKind && moduleKind <= 199 /* NodeNext */ && isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) {
84706
85452
  error(node.moduleSpecifier, Diagnostics.Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0, ModuleKind[moduleKind]);
84707
85453
  }
84708
85454
  } else if (noUncheckedSideEffectImports && !importClause) {
@@ -84722,7 +85468,11 @@ function createTypeChecker(host) {
84722
85468
  return;
84723
85469
  }
84724
85470
  checkGrammarModifiers(node);
84725
- if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
85471
+ const isImportEquals = isInternalModuleImportEqualsDeclaration(node);
85472
+ if (compilerOptions.erasableSyntaxOnly && isImportEquals && !(node.flags & 33554432 /* Ambient */)) {
85473
+ error(node, Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled);
85474
+ }
85475
+ if (isImportEquals || checkExternalImportOrExportDeclaration(node)) {
84726
85476
  checkImportBinding(node);
84727
85477
  markLinkedReferences(node, 6 /* ExportImportEquals */);
84728
85478
  if (node.moduleReference.kind !== 283 /* ExternalModuleReference */) {
@@ -86986,6 +87736,36 @@ function createTypeChecker(host) {
86986
87736
  result || (result = []);
86987
87737
  for (const info of infoList) {
86988
87738
  if (info.declaration) continue;
87739
+ if (info === anyBaseTypeIndexInfo) continue;
87740
+ if (info.components) {
87741
+ const allComponentComputedNamesSerializable = every(info.components, (e) => {
87742
+ var _a;
87743
+ return !!(e.name && isComputedPropertyName(e.name) && isEntityNameExpression(e.name.expression) && enclosing && ((_a = isEntityNameVisible(
87744
+ e.name.expression,
87745
+ enclosing,
87746
+ /*shouldComputeAliasToMakeVisible*/
87747
+ false
87748
+ )) == null ? void 0 : _a.accessibility) === 0 /* Accessible */);
87749
+ });
87750
+ if (allComponentComputedNamesSerializable) {
87751
+ const newComponents = filter(info.components, (e) => {
87752
+ return !hasLateBindableName(e);
87753
+ });
87754
+ result.push(...map(newComponents, (e) => {
87755
+ trackComputedName(e.name.expression);
87756
+ const mods = infoList === staticInfos ? [factory.createModifier(126 /* StaticKeyword */)] : void 0;
87757
+ return factory.createPropertyDeclaration(
87758
+ append(mods, info.isReadonly ? factory.createModifier(148 /* ReadonlyKeyword */) : void 0),
87759
+ e.name,
87760
+ (isPropertySignature(e) || isPropertyDeclaration(e) || isMethodSignature(e) || isMethodDeclaration(e) || isGetAccessor(e) || isSetAccessor(e)) && e.questionToken ? factory.createToken(58 /* QuestionToken */) : void 0,
87761
+ nodeBuilder.typeToTypeNode(getTypeOfSymbol(e.symbol), enclosing, flags, internalFlags, tracker),
87762
+ /*initializer*/
87763
+ void 0
87764
+ );
87765
+ }));
87766
+ continue;
87767
+ }
87768
+ }
86989
87769
  const node = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, enclosing, flags, internalFlags, tracker);
86990
87770
  if (node && infoList === staticInfos) {
86991
87771
  (node.modifiers || (node.modifiers = factory.createNodeArray())).unshift(factory.createModifier(126 /* StaticKeyword */));
@@ -86996,6 +87776,22 @@ function createTypeChecker(host) {
86996
87776
  }
86997
87777
  }
86998
87778
  return result;
87779
+ function trackComputedName(accessExpression) {
87780
+ if (!tracker.trackSymbol) return;
87781
+ const firstIdentifier = getFirstIdentifier(accessExpression);
87782
+ const name = resolveName(
87783
+ firstIdentifier,
87784
+ firstIdentifier.escapedText,
87785
+ 111551 /* Value */ | 1048576 /* ExportValue */,
87786
+ /*nameNotFoundMessage*/
87787
+ void 0,
87788
+ /*isUse*/
87789
+ true
87790
+ );
87791
+ if (name) {
87792
+ tracker.trackSymbol(name, enclosing, 111551 /* Value */);
87793
+ }
87794
+ }
86999
87795
  }
87000
87796
  };
87001
87797
  function isImportRequiredByAugmentation(node) {
@@ -88077,6 +88873,7 @@ function createTypeChecker(host) {
88077
88873
  }
88078
88874
  switch (moduleKind) {
88079
88875
  case 100 /* Node16 */:
88876
+ case 101 /* Node18 */:
88080
88877
  case 199 /* NodeNext */:
88081
88878
  if (sourceFile.impliedNodeFormat === 1 /* CommonJS */) {
88082
88879
  diagnostics.add(
@@ -88095,7 +88892,7 @@ function createTypeChecker(host) {
88095
88892
  // fallthrough
88096
88893
  default:
88097
88894
  diagnostics.add(
88098
- createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher)
88895
+ createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_node18_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher)
88099
88896
  );
88100
88897
  break;
88101
88898
  }
@@ -88239,7 +89036,7 @@ function createTypeChecker(host) {
88239
89036
  }
88240
89037
  }
88241
89038
  function checkGrammarForInvalidDynamicName(node, message) {
88242
- if (isNonBindableDynamicName(node)) {
89039
+ if (isNonBindableDynamicName(node) && !isEntityNameExpression(isElementAccessExpression(node) ? skipParentheses(node.argumentExpression) : node.expression)) {
88243
89040
  return grammarErrorOnNode(node, message);
88244
89041
  }
88245
89042
  }
@@ -88698,17 +89495,17 @@ function createTypeChecker(host) {
88698
89495
  return grammarErrorOnNode(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
88699
89496
  }
88700
89497
  if (moduleKind === 5 /* ES2015 */) {
88701
- return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_or_nodenext);
89498
+ return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_node18_or_nodenext);
88702
89499
  }
88703
89500
  if (node.typeArguments) {
88704
89501
  return grammarErrorOnNode(node, Diagnostics.This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot_have_type_arguments);
88705
89502
  }
88706
89503
  const nodeArguments = node.arguments;
88707
- if (moduleKind !== 99 /* ESNext */ && moduleKind !== 199 /* NodeNext */ && moduleKind !== 100 /* Node16 */ && moduleKind !== 200 /* Preserve */) {
89504
+ if (!(100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
88708
89505
  checkGrammarForDisallowedTrailingComma(nodeArguments);
88709
89506
  if (nodeArguments.length > 1) {
88710
89507
  const importAttributesArgument = nodeArguments[1];
88711
- return grammarErrorOnNode(importAttributesArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_nodenext_or_preserve);
89508
+ return grammarErrorOnNode(importAttributesArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_node16_node18_nodenext_or_preserve);
88712
89509
  }
88713
89510
  }
88714
89511
  if (nodeArguments.length === 0 || nodeArguments.length > 2) {
@@ -93043,7 +93840,7 @@ function transformTypeScript(context) {
93043
93840
  return updated;
93044
93841
  }
93045
93842
  function visitParenthesizedExpression(node) {
93046
- const innerExpression = skipOuterExpressions(node.expression, ~(6 /* Assertions */ | 16 /* ExpressionsWithTypeArguments */));
93843
+ const innerExpression = skipOuterExpressions(node.expression, ~(38 /* Assertions */ | 16 /* ExpressionsWithTypeArguments */));
93047
93844
  if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
93048
93845
  const expression = visitNode(node.expression, visitor, isExpression);
93049
93846
  Debug.assert(expression);
@@ -112202,11 +112999,7 @@ function createGetIsolatedDeclarationErrors(resolver) {
112202
112999
  if (isSetAccessor(node.parent)) {
112203
113000
  return createAccessorTypeError(node.parent);
112204
113001
  }
112205
- const addUndefined = resolver.requiresAddingImplicitUndefined(
112206
- node,
112207
- /*enclosingDeclaration*/
112208
- void 0
112209
- );
113002
+ const addUndefined = resolver.requiresAddingImplicitUndefined(node, node.parent);
112210
113003
  if (!addUndefined && node.initializer) {
112211
113004
  return createExpressionError(node.initializer);
112212
113005
  }
@@ -113890,6 +114683,7 @@ function getModuleTransformer(moduleKind) {
113890
114683
  case 6 /* ES2020 */:
113891
114684
  case 5 /* ES2015 */:
113892
114685
  case 100 /* Node16 */:
114686
+ case 101 /* Node18 */:
113893
114687
  case 199 /* NodeNext */:
113894
114688
  case 1 /* CommonJS */:
113895
114689
  return transformImpliedNodeFormatDependentModule;
@@ -120396,45 +121190,6 @@ function loadWithModeAwareCache(entries, containingFile, redirectedReference, op
120396
121190
  }
120397
121191
  return resolutions;
120398
121192
  }
120399
- function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
120400
- return forEachProjectReference(
120401
- /*projectReferences*/
120402
- void 0,
120403
- resolvedProjectReferences,
120404
- (resolvedRef, parent) => resolvedRef && cb(resolvedRef, parent)
120405
- );
120406
- }
120407
- function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
120408
- let seenResolvedRefs;
120409
- return worker(
120410
- projectReferences,
120411
- resolvedProjectReferences,
120412
- /*parent*/
120413
- void 0
120414
- );
120415
- function worker(projectReferences2, resolvedProjectReferences2, parent) {
120416
- if (cbRef) {
120417
- const result = cbRef(projectReferences2, parent);
120418
- if (result) return result;
120419
- }
120420
- let skipChildren;
120421
- return forEach(
120422
- resolvedProjectReferences2,
120423
- (resolvedRef, index) => {
120424
- if (resolvedRef && (seenResolvedRefs == null ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) {
120425
- (skipChildren ?? (skipChildren = /* @__PURE__ */ new Set())).add(resolvedRef);
120426
- return void 0;
120427
- }
120428
- const result = cbResolvedRef(resolvedRef, parent, index);
120429
- if (result || !resolvedRef) return result;
120430
- (seenResolvedRefs || (seenResolvedRefs = /* @__PURE__ */ new Set())).add(resolvedRef.sourceFile.path);
120431
- }
120432
- ) || forEach(
120433
- resolvedProjectReferences2,
120434
- (resolvedRef) => resolvedRef && !(skipChildren == null ? void 0 : skipChildren.has(resolvedRef)) ? worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef) : void 0
120435
- );
120436
- }
120437
- }
120438
121193
  var inferredTypesContainingFile = "__inferred type names__.ts";
120439
121194
  function getInferredLibraryNameResolveFrom(options, currentDirectory, libFileName) {
120440
121195
  const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
@@ -120450,13 +121205,6 @@ function getLibraryNameFromLibFileName(libFileName) {
120450
121205
  }
120451
121206
  return "@typescript/lib-" + path;
120452
121207
  }
120453
- function getLibNameFromLibReference(libReference) {
120454
- return toFileNameLowerCase(libReference.fileName);
120455
- }
120456
- function getLibFileNameFromLibReference(libReference) {
120457
- const libName = getLibNameFromLibReference(libReference);
120458
- return libMap.get(libName);
120459
- }
120460
121208
  function isReferencedFile(reason) {
120461
121209
  switch (reason == null ? void 0 : reason.kind) {
120462
121210
  case 3 /* Import */:
@@ -120670,11 +121418,13 @@ function createCreateProgramOptions(rootNames, options, host, oldProgram, config
120670
121418
  typeScriptVersion: typeScriptVersion2
120671
121419
  };
120672
121420
  }
120673
- function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
121421
+ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
120674
121422
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
120675
- const createProgramOptions = isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
120676
- const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion: typeScriptVersion2 } = createProgramOptions;
120677
- let { oldProgram } = createProgramOptions;
121423
+ let _createProgramOptions = isArray(_rootNamesOrOptions) ? createCreateProgramOptions(_rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : _rootNamesOrOptions;
121424
+ const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion: typeScriptVersion2, host: createProgramOptionsHost } = _createProgramOptions;
121425
+ let { oldProgram } = _createProgramOptions;
121426
+ _createProgramOptions = void 0;
121427
+ _rootNamesOrOptions = void 0;
120678
121428
  for (const option of commandLineOptionOfCustomType) {
120679
121429
  if (hasProperty(options, option.name)) {
120680
121430
  if (typeof options[option.name] === "string") {
@@ -120687,16 +121437,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120687
121437
  let processingOtherFiles;
120688
121438
  let files;
120689
121439
  let symlinks;
120690
- let commonSourceDirectory;
120691
121440
  let typeChecker;
120692
121441
  let classifiableNames;
120693
- let fileReasons = createMultiMap();
120694
121442
  let filesWithReferencesProcessed;
120695
- let fileReasonsToChain;
120696
- let reasonToRelatedInfo;
120697
121443
  let cachedBindAndCheckDiagnosticsForFile;
120698
121444
  let cachedDeclarationDiagnosticsForFile;
120699
- let fileProcessingDiagnostics;
121445
+ const programDiagnostics = createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax);
120700
121446
  let automaticTypeDirectiveNames;
120701
121447
  let automaticTypeDirectiveResolutions;
120702
121448
  let resolvedLibReferences;
@@ -120718,13 +121464,12 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
120718
121464
  true
120719
121465
  );
120720
121466
  mark("beforeProgram");
120721
- const host = createProgramOptions.host || createCompilerHost(options);
121467
+ const host = createProgramOptionsHost || createCompilerHost(options);
120722
121468
  const configParsingHost = parseConfigHostFromCompilerHostLike(host);
120723
121469
  let skipDefaultLib = options.noLib;
120724
121470
  const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options));
120725
121471
  const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName());
120726
- const programDiagnostics = createDiagnosticCollection();
120727
- let lazyProgramDiagnosticExplainingFile = [];
121472
+ let skipVerifyCompilerOptions = false;
120728
121473
  const currentDirectory = host.getCurrentDirectory();
120729
121474
  const supportedExtensions = getSupportedExtensions(options);
120730
121475
  const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
@@ -121002,7 +121747,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121002
121747
  getTypeCount: () => getTypeChecker().getTypeCount(),
121003
121748
  getInstantiationCount: () => getTypeChecker().getInstantiationCount(),
121004
121749
  getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(),
121005
- getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
121750
+ getFileProcessingDiagnostics: () => programDiagnostics.getFileProcessingDiagnostics(),
121006
121751
  getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames,
121007
121752
  getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
121008
121753
  isSourceFileFromExternalLibrary,
@@ -121018,6 +121763,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121018
121763
  resolvedModules,
121019
121764
  resolvedTypeReferenceDirectiveNames,
121020
121765
  resolvedLibReferences,
121766
+ getProgramDiagnosticsContainer: () => programDiagnostics,
121021
121767
  getResolvedModule,
121022
121768
  getResolvedModuleFromModuleSpecifier,
121023
121769
  getResolvedTypeReferenceDirective,
@@ -121050,70 +121796,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121050
121796
  realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
121051
121797
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
121052
121798
  getCanonicalFileName,
121053
- getFileIncludeReasons: () => fileReasons,
121799
+ getFileIncludeReasons: () => programDiagnostics.getFileReasons(),
121054
121800
  structureIsReused,
121055
121801
  writeFile: writeFile2,
121056
121802
  getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation)
121057
121803
  };
121058
121804
  onProgramCreateComplete();
121059
- verifyCompilerOptions();
121805
+ if (!skipVerifyCompilerOptions) {
121806
+ verifyCompilerOptions();
121807
+ }
121060
121808
  mark("afterProgram");
121061
121809
  measure("Program", "beforeProgram", "afterProgram");
121062
121810
  (_p = tracing) == null ? void 0 : _p.pop();
121063
121811
  return program;
121064
- function updateAndGetProgramDiagnostics() {
121065
- if (lazyProgramDiagnosticExplainingFile) {
121066
- fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
121067
- switch (diagnostic.kind) {
121068
- case 1 /* FilePreprocessingFileExplainingDiagnostic */:
121069
- return programDiagnostics.add(
121070
- createDiagnosticExplainingFile(
121071
- diagnostic.file && getSourceFileByPath(diagnostic.file),
121072
- diagnostic.fileProcessingReason,
121073
- diagnostic.diagnostic,
121074
- diagnostic.args || emptyArray
121075
- )
121076
- );
121077
- case 0 /* FilePreprocessingLibReferenceDiagnostic */:
121078
- return programDiagnostics.add(filePreprocessingLibreferenceDiagnostic(diagnostic));
121079
- case 2 /* ResolutionDiagnostics */:
121080
- return diagnostic.diagnostics.forEach((d) => programDiagnostics.add(d));
121081
- default:
121082
- Debug.assertNever(diagnostic);
121083
- }
121084
- });
121085
- lazyProgramDiagnosticExplainingFile.forEach(
121086
- ({ file, diagnostic, args }) => programDiagnostics.add(
121087
- createDiagnosticExplainingFile(
121088
- file,
121089
- /*fileProcessingReason*/
121090
- void 0,
121091
- diagnostic,
121092
- args
121093
- )
121094
- )
121095
- );
121096
- lazyProgramDiagnosticExplainingFile = void 0;
121097
- fileReasonsToChain = void 0;
121098
- reasonToRelatedInfo = void 0;
121099
- }
121100
- return programDiagnostics;
121101
- }
121102
- function filePreprocessingLibreferenceDiagnostic({ reason }) {
121103
- const { file, pos, end } = getReferencedFileLocation(program, reason);
121104
- const libReference = file.libReferenceDirectives[reason.index];
121105
- const libName = getLibNameFromLibReference(libReference);
121106
- const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
121107
- const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
121108
- return createFileDiagnostic(
121109
- file,
121110
- Debug.checkDefined(pos),
121111
- Debug.checkDefined(end) - pos,
121112
- suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0,
121113
- libName,
121114
- suggestion
121115
- );
121116
- }
121117
121812
  function getResolvedModule(file, moduleName, mode) {
121118
121813
  var _a2;
121119
121814
  return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
@@ -121162,7 +121857,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121162
121857
  function addResolutionDiagnostics(resolution) {
121163
121858
  var _a2;
121164
121859
  if (!((_a2 = resolution.resolutionDiagnostics) == null ? void 0 : _a2.length)) return;
121165
- (fileProcessingDiagnostics ?? (fileProcessingDiagnostics = [])).push({
121860
+ programDiagnostics.addFileProcessingDiagnostic({
121166
121861
  kind: 2 /* ResolutionDiagnostics */,
121167
121862
  diagnostics: resolution.resolutionDiagnostics
121168
121863
  });
@@ -121256,16 +121951,19 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121256
121951
  return toPath(fileName, currentDirectory, getCanonicalFileName);
121257
121952
  }
121258
121953
  function getCommonSourceDirectory2() {
121259
- if (commonSourceDirectory === void 0) {
121260
- const emittedFiles = filter(files, (file) => sourceFileMayBeEmitted(file, program));
121261
- commonSourceDirectory = getCommonSourceDirectory(
121262
- options,
121263
- () => mapDefined(emittedFiles, (file) => file.isDeclarationFile ? void 0 : file.fileName),
121264
- currentDirectory,
121265
- getCanonicalFileName,
121266
- (commonSourceDirectory2) => checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory2)
121267
- );
121954
+ let commonSourceDirectory = programDiagnostics.getCommonSourceDirectory();
121955
+ if (commonSourceDirectory !== void 0) {
121956
+ return commonSourceDirectory;
121268
121957
  }
121958
+ const emittedFiles = filter(files, (file) => sourceFileMayBeEmitted(file, program));
121959
+ commonSourceDirectory = getCommonSourceDirectory(
121960
+ options,
121961
+ () => mapDefined(emittedFiles, (file) => file.isDeclarationFile ? void 0 : file.fileName),
121962
+ currentDirectory,
121963
+ getCanonicalFileName,
121964
+ (commonSourceDirectory2) => checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory2)
121965
+ );
121966
+ programDiagnostics.setCommonSourceDirectory(commonSourceDirectory);
121269
121967
  return commonSourceDirectory;
121270
121968
  }
121271
121969
  function getClassifiableNames() {
@@ -121576,9 +122274,10 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121576
122274
  }
121577
122275
  filesByName.set(path, filesByName.get(oldFile.path));
121578
122276
  });
122277
+ const isConfigIdentical = oldOptions.configFile && oldOptions.configFile === options.configFile || !oldOptions.configFile && !options.configFile && !optionsHaveChanges(oldOptions, options, optionDeclarations);
122278
+ programDiagnostics.reuseStateFromOldProgram(oldProgram.getProgramDiagnosticsContainer(), isConfigIdentical);
122279
+ skipVerifyCompilerOptions = isConfigIdentical;
121579
122280
  files = newSourceFiles;
121580
- fileReasons = oldProgram.getFileIncludeReasons();
121581
- fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
121582
122281
  automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames();
121583
122282
  automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions();
121584
122283
  sourceFileToPackageName = oldProgram.sourceFileToPackageName;
@@ -121794,7 +122493,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
121794
122493
  if (skipTypeChecking(sourceFile, options, program)) {
121795
122494
  return emptyArray;
121796
122495
  }
121797
- const programDiagnosticsInFile = updateAndGetProgramDiagnostics().getDiagnostics(sourceFile.fileName);
122496
+ const programDiagnosticsInFile = programDiagnostics.getCombinedDiagnostics(program).getDiagnostics(sourceFile.fileName);
121798
122497
  if (!((_a2 = sourceFile.commentDirectives) == null ? void 0 : _a2.length)) {
121799
122498
  return programDiagnosticsInFile;
121800
122499
  }
@@ -122152,15 +122851,15 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122152
122851
  }
122153
122852
  function getOptionsDiagnostics() {
122154
122853
  return sortAndDeduplicateDiagnostics(concatenate(
122155
- updateAndGetProgramDiagnostics().getGlobalDiagnostics(),
122854
+ programDiagnostics.getCombinedDiagnostics(program).getGlobalDiagnostics(),
122156
122855
  getOptionsDiagnosticsOfConfigFile()
122157
122856
  ));
122158
122857
  }
122159
122858
  function getOptionsDiagnosticsOfConfigFile() {
122160
122859
  if (!options.configFile) return emptyArray;
122161
- let diagnostics = updateAndGetProgramDiagnostics().getDiagnostics(options.configFile.fileName);
122860
+ let diagnostics = programDiagnostics.getCombinedDiagnostics(program).getDiagnostics(options.configFile.fileName);
122162
122861
  forEachResolvedProjectReference2((resolvedRef) => {
122163
- diagnostics = concatenate(diagnostics, updateAndGetProgramDiagnostics().getDiagnostics(resolvedRef.sourceFile.fileName));
122862
+ diagnostics = concatenate(diagnostics, programDiagnostics.getCombinedDiagnostics(program).getDiagnostics(resolvedRef.sourceFile.fileName));
122164
122863
  });
122165
122864
  return diagnostics;
122166
122865
  }
@@ -122367,7 +123066,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122367
123066
  );
122368
123067
  }
122369
123068
  function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, reason) {
122370
- const hasExistingReasonToReportErrorOn = !isReferencedFile(reason) && some(fileReasons.get(existingFile.path), isReferencedFile);
123069
+ const hasExistingReasonToReportErrorOn = !isReferencedFile(reason) && some(programDiagnostics.getFileReasons().get(existingFile.path), isReferencedFile);
122371
123070
  if (hasExistingReasonToReportErrorOn) {
122372
123071
  addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, [existingFile.fileName, fileName]);
122373
123072
  } else {
@@ -122554,7 +123253,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122554
123253
  }
122555
123254
  function addFileIncludeReason(file, reason, checkExisting) {
122556
123255
  if (file && (!checkExisting || !isReferencedFile(reason) || !(filesWithReferencesProcessed == null ? void 0 : filesWithReferencesProcessed.has(reason.file)))) {
122557
- fileReasons.add(file.path, reason);
123256
+ programDiagnostics.getFileReasons().add(file.path, reason);
122558
123257
  return true;
122559
123258
  }
122560
123259
  return false;
@@ -122706,6 +123405,16 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122706
123405
  var _a2, _b2, _c2, _d2, _e2;
122707
123406
  const existing = resolvedLibProcessing == null ? void 0 : resolvedLibProcessing.get(libFileName);
122708
123407
  if (existing) return existing;
123408
+ if (options.libReplacement === false) {
123409
+ const result2 = {
123410
+ resolution: {
123411
+ resolvedModule: void 0
123412
+ },
123413
+ actual: combinePaths(defaultLibraryPath, libFileName)
123414
+ };
123415
+ (resolvedLibProcessing ?? (resolvedLibProcessing = /* @__PURE__ */ new Map())).set(libFileName, result2);
123416
+ return result2;
123417
+ }
122709
123418
  if (structureIsReused !== 0 /* Not */ && oldProgram && !hasInvalidatedLibResolutions(libFileName)) {
122710
123419
  const oldResolution = (_a2 = oldProgram.resolvedLibReferences) == null ? void 0 : _a2.get(libFileName);
122711
123420
  if (oldResolution) {
@@ -122753,7 +123462,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122753
123462
  { kind: 7 /* LibReferenceDirective */, file: file.path, index }
122754
123463
  );
122755
123464
  } else {
122756
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
123465
+ programDiagnostics.addFileProcessingDiagnostic({
122757
123466
  kind: 0 /* FilePreprocessingLibReferenceDiagnostic */,
122758
123467
  reason: { kind: 7 /* LibReferenceDirective */, file: file.path, index }
122759
123468
  });
@@ -122816,10 +123525,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122816
123525
  if (!sourceFile.isDeclarationFile) {
122817
123526
  const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
122818
123527
  if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
122819
- addLazyProgramDiagnosticExplainingFile(
123528
+ programDiagnostics.addLazyConfigDiagnostic(
122820
123529
  sourceFile,
122821
123530
  Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files,
122822
- [sourceFile.fileName, rootDirectory]
123531
+ sourceFile.fileName,
123532
+ rootDirectory
122823
123533
  );
122824
123534
  allFilesBelongToPath = false;
122825
123535
  }
@@ -122934,7 +123644,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122934
123644
  }
122935
123645
  const outputFile = options.outFile;
122936
123646
  if (!options.tsBuildInfoFile && options.incremental && !outputFile && !options.configFilePath) {
122937
- programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
123647
+ programDiagnostics.addConfigDiagnostic(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
122938
123648
  }
122939
123649
  verifyDeprecatedCompilerOptions();
122940
123650
  verifyProjectReferences();
@@ -122942,10 +123652,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
122942
123652
  const rootPaths = new Set(rootNames.map(toPath3));
122943
123653
  for (const file of files) {
122944
123654
  if (sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
122945
- addLazyProgramDiagnosticExplainingFile(
123655
+ programDiagnostics.addLazyConfigDiagnostic(
122946
123656
  file,
122947
123657
  Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern,
122948
- [file.fileName, options.configFilePath || ""]
123658
+ file.fileName,
123659
+ options.configFilePath || ""
122949
123660
  );
122950
123661
  }
122951
123662
  }
@@ -123036,14 +123747,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123036
123747
  }
123037
123748
  } else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === 0 /* None */) {
123038
123749
  const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
123039
- programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
123750
+ programDiagnostics.addConfigDiagnostic(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
123040
123751
  }
123041
123752
  if (outputFile && !options.emitDeclarationOnly) {
123042
123753
  if (options.module && !(options.module === 2 /* AMD */ || options.module === 4 /* System */)) {
123043
123754
  createDiagnosticForOptionName(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, "outFile", "module");
123044
123755
  } else if (options.module === void 0 && firstNonAmbientExternalModuleSourceFile) {
123045
123756
  const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
123046
- programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, "outFile"));
123757
+ programDiagnostics.addConfigDiagnostic(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, "outFile"));
123047
123758
  }
123048
123759
  }
123049
123760
  if (getResolveJsonModule(options)) {
@@ -123132,7 +123843,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123132
123843
  }
123133
123844
  if (ModuleKind[moduleKind] && (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) && !(3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) {
123134
123845
  const moduleKindName = ModuleKind[moduleKind];
123135
- createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1, moduleKindName, moduleKindName);
123846
+ const moduleResolutionName = ModuleResolutionKind[moduleKindName] ? moduleKindName : "Node16";
123847
+ createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_moduleResolution_must_be_set_to_0_or_left_unspecified_when_option_module_is_set_to_1, moduleResolutionName, moduleKindName);
123136
123848
  } else if (ModuleResolutionKind[moduleResolution] && (3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) && !(100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */)) {
123137
123849
  const moduleResolutionName = ModuleResolutionKind[moduleResolution];
123138
123850
  createOptionValueDiagnostic("module", Diagnostics.Option_module_must_be_set_to_0_when_option_moduleResolution_is_set_to_1, moduleResolutionName, moduleResolutionName);
@@ -123294,90 +124006,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123294
124006
  }
123295
124007
  });
123296
124008
  }
123297
- function createDiagnosticExplainingFile(file, fileProcessingReason, diagnostic, args) {
123298
- let seenReasons;
123299
- const reasons = file && fileReasons.get(file.path);
123300
- let fileIncludeReasons;
123301
- let relatedInfo;
123302
- let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : void 0;
123303
- let fileIncludeReasonDetails;
123304
- let redirectInfo;
123305
- let cachedChain = file && (fileReasonsToChain == null ? void 0 : fileReasonsToChain.get(file.path));
123306
- let chain;
123307
- if (cachedChain) {
123308
- if (cachedChain.fileIncludeReasonDetails) {
123309
- seenReasons = new Set(reasons);
123310
- reasons == null ? void 0 : reasons.forEach(populateRelatedInfo);
123311
- } else {
123312
- reasons == null ? void 0 : reasons.forEach(processReason);
123313
- }
123314
- redirectInfo = cachedChain.redirectInfo;
123315
- } else {
123316
- reasons == null ? void 0 : reasons.forEach(processReason);
123317
- redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, getCompilerOptionsForFile(file));
123318
- }
123319
- if (fileProcessingReason) processReason(fileProcessingReason);
123320
- const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
123321
- if (locationReason && (seenReasons == null ? void 0 : seenReasons.size) === 1) seenReasons = void 0;
123322
- if (seenReasons && cachedChain) {
123323
- if (cachedChain.details && !processedExtraReason) {
123324
- chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args || emptyArray);
123325
- } else if (cachedChain.fileIncludeReasonDetails) {
123326
- if (!processedExtraReason) {
123327
- if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
123328
- fileIncludeReasonDetails = cachedChain.fileIncludeReasonDetails;
123329
- } else {
123330
- fileIncludeReasons = cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length);
123331
- }
123332
- } else {
123333
- if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
123334
- fileIncludeReasons = [...cachedChain.fileIncludeReasonDetails.next, fileIncludeReasons[0]];
123335
- } else {
123336
- fileIncludeReasons = append(cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length), fileIncludeReasons[0]);
123337
- }
123338
- }
123339
- }
123340
- }
123341
- if (!chain) {
123342
- if (!fileIncludeReasonDetails) fileIncludeReasonDetails = seenReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
123343
- chain = chainDiagnosticMessages(
123344
- redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails,
123345
- diagnostic,
123346
- ...args || emptyArray
123347
- );
123348
- }
123349
- if (file) {
123350
- if (cachedChain) {
123351
- if (!cachedChain.fileIncludeReasonDetails || !processedExtraReason && fileIncludeReasonDetails) {
123352
- cachedChain.fileIncludeReasonDetails = fileIncludeReasonDetails;
123353
- }
123354
- } else {
123355
- (fileReasonsToChain ?? (fileReasonsToChain = /* @__PURE__ */ new Map())).set(file.path, cachedChain = { fileIncludeReasonDetails, redirectInfo });
123356
- }
123357
- if (!cachedChain.details && !processedExtraReason) cachedChain.details = chain.next;
123358
- }
123359
- const location = locationReason && getReferencedFileLocation(program, locationReason);
123360
- return location && isReferenceFileLocation(location) ? createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
123361
- function processReason(reason) {
123362
- if (seenReasons == null ? void 0 : seenReasons.has(reason)) return;
123363
- (seenReasons ?? (seenReasons = /* @__PURE__ */ new Set())).add(reason);
123364
- (fileIncludeReasons ?? (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
123365
- populateRelatedInfo(reason);
123366
- }
123367
- function populateRelatedInfo(reason) {
123368
- if (!locationReason && isReferencedFile(reason)) {
123369
- locationReason = reason;
123370
- } else if (locationReason !== reason) {
123371
- relatedInfo = append(relatedInfo, getFileIncludeReasonToRelatedInformation(reason));
123372
- }
123373
- }
123374
- function cachedFileIncludeDetailsHasProcessedExtraReason() {
123375
- var _a2;
123376
- return ((_a2 = cachedChain.fileIncludeReasonDetails.next) == null ? void 0 : _a2.length) !== (reasons == null ? void 0 : reasons.length);
123377
- }
123378
- }
123379
124009
  function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
123380
- (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
124010
+ programDiagnostics.addFileProcessingDiagnostic({
123381
124011
  kind: 1 /* FilePreprocessingFileExplainingDiagnostic */,
123382
124012
  file: file && file.path,
123383
124013
  fileProcessingReason,
@@ -123385,99 +124015,6 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123385
124015
  args
123386
124016
  });
123387
124017
  }
123388
- function addLazyProgramDiagnosticExplainingFile(file, diagnostic, args) {
123389
- lazyProgramDiagnosticExplainingFile.push({ file, diagnostic, args });
123390
- }
123391
- function getFileIncludeReasonToRelatedInformation(reason) {
123392
- let relatedInfo = reasonToRelatedInfo == null ? void 0 : reasonToRelatedInfo.get(reason);
123393
- if (relatedInfo === void 0) (reasonToRelatedInfo ?? (reasonToRelatedInfo = /* @__PURE__ */ new Map())).set(reason, relatedInfo = fileIncludeReasonToRelatedInformation(reason) ?? false);
123394
- return relatedInfo || void 0;
123395
- }
123396
- function fileIncludeReasonToRelatedInformation(reason) {
123397
- if (isReferencedFile(reason)) {
123398
- const referenceLocation = getReferencedFileLocation(program, reason);
123399
- let message2;
123400
- switch (reason.kind) {
123401
- case 3 /* Import */:
123402
- message2 = Diagnostics.File_is_included_via_import_here;
123403
- break;
123404
- case 4 /* ReferenceFile */:
123405
- message2 = Diagnostics.File_is_included_via_reference_here;
123406
- break;
123407
- case 5 /* TypeReferenceDirective */:
123408
- message2 = Diagnostics.File_is_included_via_type_library_reference_here;
123409
- break;
123410
- case 7 /* LibReferenceDirective */:
123411
- message2 = Diagnostics.File_is_included_via_library_reference_here;
123412
- break;
123413
- default:
123414
- Debug.assertNever(reason);
123415
- }
123416
- return isReferenceFileLocation(referenceLocation) ? createFileDiagnostic(
123417
- referenceLocation.file,
123418
- referenceLocation.pos,
123419
- referenceLocation.end - referenceLocation.pos,
123420
- message2
123421
- ) : void 0;
123422
- }
123423
- if (!options.configFile) return void 0;
123424
- let configFileNode;
123425
- let message;
123426
- switch (reason.kind) {
123427
- case 0 /* RootFile */:
123428
- if (!options.configFile.configFileSpecs) return void 0;
123429
- const fileName = getNormalizedAbsolutePath(rootNames[reason.index], currentDirectory);
123430
- const matchedByFiles = getMatchedFileSpec(program, fileName);
123431
- if (matchedByFiles) {
123432
- configFileNode = getTsConfigPropArrayElementValue(options.configFile, "files", matchedByFiles);
123433
- message = Diagnostics.File_is_matched_by_files_list_specified_here;
123434
- break;
123435
- }
123436
- const matchedByInclude = getMatchedIncludeSpec(program, fileName);
123437
- if (!matchedByInclude || !isString(matchedByInclude)) return void 0;
123438
- configFileNode = getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude);
123439
- message = Diagnostics.File_is_matched_by_include_pattern_specified_here;
123440
- break;
123441
- case 1 /* SourceFromProjectReference */:
123442
- case 2 /* OutputFromProjectReference */:
123443
- const referencedResolvedRef = Debug.checkDefined(resolvedProjectReferences == null ? void 0 : resolvedProjectReferences[reason.index]);
123444
- const referenceInfo = forEachProjectReference(
123445
- projectReferences,
123446
- resolvedProjectReferences,
123447
- (resolvedRef, parent, index2) => resolvedRef === referencedResolvedRef ? { sourceFile: (parent == null ? void 0 : parent.sourceFile) || options.configFile, index: index2 } : void 0
123448
- );
123449
- if (!referenceInfo) return void 0;
123450
- const { sourceFile, index } = referenceInfo;
123451
- const referencesSyntax = forEachTsConfigPropArray(sourceFile, "references", (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0);
123452
- return referencesSyntax && referencesSyntax.elements.length > index ? createDiagnosticForNodeInSourceFile(
123453
- sourceFile,
123454
- referencesSyntax.elements[index],
123455
- reason.kind === 2 /* OutputFromProjectReference */ ? Diagnostics.File_is_output_from_referenced_project_specified_here : Diagnostics.File_is_source_from_referenced_project_specified_here
123456
- ) : void 0;
123457
- case 8 /* AutomaticTypeDirectiveFile */:
123458
- if (!options.types) return void 0;
123459
- configFileNode = getOptionsSyntaxByArrayElementValue("types", reason.typeReference);
123460
- message = Diagnostics.File_is_entry_point_of_type_library_specified_here;
123461
- break;
123462
- case 6 /* LibFile */:
123463
- if (reason.index !== void 0) {
123464
- configFileNode = getOptionsSyntaxByArrayElementValue("lib", options.lib[reason.index]);
123465
- message = Diagnostics.File_is_library_specified_here;
123466
- break;
123467
- }
123468
- const target = getNameOfScriptTarget(getEmitScriptTarget(options));
123469
- configFileNode = target ? getOptionsSyntaxByValue("target", target) : void 0;
123470
- message = Diagnostics.File_is_default_library_for_target_specified_here;
123471
- break;
123472
- default:
123473
- Debug.assertNever(reason);
123474
- }
123475
- return configFileNode && createDiagnosticForNodeInSourceFile(
123476
- options.configFile,
123477
- configFileNode,
123478
- message
123479
- );
123480
- }
123481
124018
  function verifyProjectReferences() {
123482
124019
  const buildInfoPath = !options.suppressOutputPathCheck ? getTsBuildInfoEmitOutputFilePath(options) : void 0;
123483
124020
  forEachProjectReference(
@@ -123513,7 +124050,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123513
124050
  forEachPropertyAssignment(pathProp.initializer, key, (keyProps) => {
123514
124051
  const initializer = keyProps.initializer;
123515
124052
  if (isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
123516
- programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, ...args));
124053
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, ...args));
123517
124054
  needCompilerDiagnostic = false;
123518
124055
  }
123519
124056
  });
@@ -123542,18 +124079,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123542
124079
  createCompilerOptionsDiagnostic(message, ...args);
123543
124080
  }
123544
124081
  }
123545
- function forEachOptionsSyntaxByName(name, callback) {
123546
- return forEachPropertyAssignment(getCompilerOptionsObjectLiteralSyntax(), name, callback);
123547
- }
123548
124082
  function forEachOptionPathsSyntax(callback) {
123549
- return forEachOptionsSyntaxByName("paths", callback);
123550
- }
123551
- function getOptionsSyntaxByValue(name, value) {
123552
- return forEachOptionsSyntaxByName(name, (property) => isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : void 0);
123553
- }
123554
- function getOptionsSyntaxByArrayElementValue(name, value) {
123555
- const compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
123556
- return compilerOptionsObjectLiteralSyntax && getPropertyArrayElementValue(compilerOptionsObjectLiteralSyntax, name, value);
124083
+ return forEachOptionsSyntaxByName(getCompilerOptionsObjectLiteralSyntax(), "paths", callback);
123557
124084
  }
123558
124085
  function createDiagnosticForOptionName(message, option1, option2, option3) {
123559
124086
  createDiagnosticForOption(
@@ -123581,9 +124108,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123581
124108
  function createDiagnosticForReference(sourceFile, index, message, ...args) {
123582
124109
  const referencesSyntax = forEachTsConfigPropArray(sourceFile || options.configFile, "references", (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0);
123583
124110
  if (referencesSyntax && referencesSyntax.elements.length > index) {
123584
- programDiagnostics.add(createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, ...args));
124111
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, ...args));
123585
124112
  } else {
123586
- programDiagnostics.add(createCompilerDiagnostic(message, ...args));
124113
+ programDiagnostics.addConfigDiagnostic(createCompilerDiagnostic(message, ...args));
123587
124114
  }
123588
124115
  }
123589
124116
  function createDiagnosticForOption(onKey, option1, option2, message, ...args) {
@@ -123597,14 +124124,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123597
124124
  const compilerOptionsProperty = getCompilerOptionsPropertySyntax();
123598
124125
  if (compilerOptionsProperty) {
123599
124126
  if ("messageText" in message) {
123600
- programDiagnostics.add(createDiagnosticForNodeFromMessageChain(options.configFile, compilerOptionsProperty.name, message));
124127
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeFromMessageChain(options.configFile, compilerOptionsProperty.name, message));
123601
124128
  } else {
123602
- programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, compilerOptionsProperty.name, message, ...args));
124129
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeInSourceFile(options.configFile, compilerOptionsProperty.name, message, ...args));
123603
124130
  }
123604
124131
  } else if ("messageText" in message) {
123605
- programDiagnostics.add(createCompilerDiagnosticFromMessageChain(message));
124132
+ programDiagnostics.addConfigDiagnostic(createCompilerDiagnosticFromMessageChain(message));
123606
124133
  } else {
123607
- programDiagnostics.add(createCompilerDiagnostic(message, ...args));
124134
+ programDiagnostics.addConfigDiagnostic(createCompilerDiagnostic(message, ...args));
123608
124135
  }
123609
124136
  }
123610
124137
  function getCompilerOptionsObjectLiteralSyntax() {
@@ -123628,9 +124155,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123628
124155
  let needsCompilerDiagnostic = false;
123629
124156
  forEachPropertyAssignment(objectLiteral, key1, (prop) => {
123630
124157
  if ("messageText" in message) {
123631
- programDiagnostics.add(createDiagnosticForNodeFromMessageChain(options.configFile, onKey ? prop.name : prop.initializer, message));
124158
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeFromMessageChain(options.configFile, onKey ? prop.name : prop.initializer, message));
123632
124159
  } else {
123633
- programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, ...args));
124160
+ programDiagnostics.addConfigDiagnostic(createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, ...args));
123634
124161
  }
123635
124162
  needsCompilerDiagnostic = true;
123636
124163
  }, key2);
@@ -123638,7 +124165,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
123638
124165
  }
123639
124166
  function blockEmittingOfFile(emitFileName, diag2) {
123640
124167
  hasEmitBlockingDiagnostics.set(toPath3(emitFileName), true);
123641
- programDiagnostics.add(diag2);
124168
+ programDiagnostics.addConfigDiagnostic(diag2);
123642
124169
  }
123643
124170
  function isEmittedFile(file) {
123644
124171
  if (options.noEmit) {
@@ -123961,6 +124488,293 @@ function getModuleNameStringLiteralAt({ imports, moduleAugmentations }, index) {
123961
124488
  Debug.fail("should never ask for module name at index higher than possible module name");
123962
124489
  }
123963
124490
 
124491
+ // src/compiler/programDiagnostics.ts
124492
+ function createProgramDiagnostics(getCompilerOptionsObjectLiteralSyntax) {
124493
+ let computedDiagnostics;
124494
+ let fileReasons = createMultiMap();
124495
+ let fileProcessingDiagnostics;
124496
+ let commonSourceDirectory;
124497
+ let configDiagnostics;
124498
+ let lazyConfigDiagnostics;
124499
+ let fileReasonsToChain;
124500
+ let reasonToRelatedInfo;
124501
+ return {
124502
+ addConfigDiagnostic(diag2) {
124503
+ Debug.assert(computedDiagnostics === void 0, "Cannot modify program diagnostic state after requesting combined diagnostics");
124504
+ (configDiagnostics ?? (configDiagnostics = createDiagnosticCollection())).add(diag2);
124505
+ },
124506
+ addLazyConfigDiagnostic(file, message, ...args) {
124507
+ Debug.assert(computedDiagnostics === void 0, "Cannot modify program diagnostic state after requesting combined diagnostics");
124508
+ (lazyConfigDiagnostics ?? (lazyConfigDiagnostics = [])).push({ file, diagnostic: message, args });
124509
+ },
124510
+ addFileProcessingDiagnostic(diag2) {
124511
+ Debug.assert(computedDiagnostics === void 0, "Cannot modify program diagnostic state after requesting combined diagnostics");
124512
+ (fileProcessingDiagnostics ?? (fileProcessingDiagnostics = [])).push(diag2);
124513
+ },
124514
+ setCommonSourceDirectory(directory) {
124515
+ commonSourceDirectory = directory;
124516
+ },
124517
+ reuseStateFromOldProgram(oldProgramDiagnostics, isConfigIdentical) {
124518
+ fileReasons = oldProgramDiagnostics.getFileReasons();
124519
+ fileProcessingDiagnostics = oldProgramDiagnostics.getFileProcessingDiagnostics();
124520
+ if (isConfigIdentical) {
124521
+ commonSourceDirectory = oldProgramDiagnostics.getCommonSourceDirectory();
124522
+ configDiagnostics = oldProgramDiagnostics.getConfigDiagnostics();
124523
+ lazyConfigDiagnostics = oldProgramDiagnostics.getLazyConfigDiagnostics();
124524
+ }
124525
+ },
124526
+ getFileProcessingDiagnostics() {
124527
+ return fileProcessingDiagnostics;
124528
+ },
124529
+ getFileReasons() {
124530
+ return fileReasons;
124531
+ },
124532
+ getCommonSourceDirectory() {
124533
+ return commonSourceDirectory;
124534
+ },
124535
+ getConfigDiagnostics() {
124536
+ return configDiagnostics;
124537
+ },
124538
+ getLazyConfigDiagnostics() {
124539
+ return lazyConfigDiagnostics;
124540
+ },
124541
+ getCombinedDiagnostics(program) {
124542
+ if (computedDiagnostics) {
124543
+ return computedDiagnostics;
124544
+ }
124545
+ computedDiagnostics = createDiagnosticCollection();
124546
+ configDiagnostics == null ? void 0 : configDiagnostics.getDiagnostics().forEach((d) => computedDiagnostics.add(d));
124547
+ fileProcessingDiagnostics == null ? void 0 : fileProcessingDiagnostics.forEach((diagnostic) => {
124548
+ switch (diagnostic.kind) {
124549
+ case 1 /* FilePreprocessingFileExplainingDiagnostic */:
124550
+ return computedDiagnostics.add(
124551
+ createDiagnosticExplainingFile(
124552
+ program,
124553
+ diagnostic.file && program.getSourceFileByPath(diagnostic.file),
124554
+ diagnostic.fileProcessingReason,
124555
+ diagnostic.diagnostic,
124556
+ diagnostic.args || emptyArray
124557
+ )
124558
+ );
124559
+ case 0 /* FilePreprocessingLibReferenceDiagnostic */:
124560
+ return computedDiagnostics.add(filePreprocessingLibreferenceDiagnostic(program, diagnostic));
124561
+ case 2 /* ResolutionDiagnostics */:
124562
+ return diagnostic.diagnostics.forEach((d) => computedDiagnostics.add(d));
124563
+ default:
124564
+ Debug.assertNever(diagnostic);
124565
+ }
124566
+ });
124567
+ lazyConfigDiagnostics == null ? void 0 : lazyConfigDiagnostics.forEach(
124568
+ ({ file, diagnostic, args }) => computedDiagnostics.add(
124569
+ createDiagnosticExplainingFile(
124570
+ program,
124571
+ file,
124572
+ /*fileProcessingReason*/
124573
+ void 0,
124574
+ diagnostic,
124575
+ args
124576
+ )
124577
+ )
124578
+ );
124579
+ fileReasonsToChain = void 0;
124580
+ reasonToRelatedInfo = void 0;
124581
+ return computedDiagnostics;
124582
+ }
124583
+ };
124584
+ function filePreprocessingLibreferenceDiagnostic(program, { reason }) {
124585
+ const { file, pos, end } = getReferencedFileLocation(program, reason);
124586
+ const libReference = file.libReferenceDirectives[reason.index];
124587
+ const libName = getLibNameFromLibReference(libReference);
124588
+ const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
124589
+ const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
124590
+ return createFileDiagnostic(
124591
+ file,
124592
+ Debug.checkDefined(pos),
124593
+ Debug.checkDefined(end) - pos,
124594
+ suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0,
124595
+ libName,
124596
+ suggestion
124597
+ );
124598
+ }
124599
+ function createDiagnosticExplainingFile(program, file, fileProcessingReason, diagnostic, args) {
124600
+ let seenReasons;
124601
+ let fileIncludeReasons;
124602
+ let relatedInfo;
124603
+ let fileIncludeReasonDetails;
124604
+ let redirectInfo;
124605
+ let chain;
124606
+ const reasons = file && fileReasons.get(file.path);
124607
+ let locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : void 0;
124608
+ let cachedChain = file && (fileReasonsToChain == null ? void 0 : fileReasonsToChain.get(file.path));
124609
+ if (cachedChain) {
124610
+ if (cachedChain.fileIncludeReasonDetails) {
124611
+ seenReasons = new Set(reasons);
124612
+ reasons == null ? void 0 : reasons.forEach(populateRelatedInfo);
124613
+ } else {
124614
+ reasons == null ? void 0 : reasons.forEach(processReason);
124615
+ }
124616
+ redirectInfo = cachedChain.redirectInfo;
124617
+ } else {
124618
+ reasons == null ? void 0 : reasons.forEach(processReason);
124619
+ redirectInfo = file && explainIfFileIsRedirectAndImpliedFormat(file, program.getCompilerOptionsForFile(file));
124620
+ }
124621
+ if (fileProcessingReason) processReason(fileProcessingReason);
124622
+ const processedExtraReason = (seenReasons == null ? void 0 : seenReasons.size) !== (reasons == null ? void 0 : reasons.length);
124623
+ if (locationReason && (seenReasons == null ? void 0 : seenReasons.size) === 1) seenReasons = void 0;
124624
+ if (seenReasons && cachedChain) {
124625
+ if (cachedChain.details && !processedExtraReason) {
124626
+ chain = chainDiagnosticMessages(cachedChain.details, diagnostic, ...args ?? emptyArray);
124627
+ } else if (cachedChain.fileIncludeReasonDetails) {
124628
+ if (!processedExtraReason) {
124629
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
124630
+ fileIncludeReasonDetails = cachedChain.fileIncludeReasonDetails;
124631
+ } else {
124632
+ fileIncludeReasons = cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length);
124633
+ }
124634
+ } else {
124635
+ if (!cachedFileIncludeDetailsHasProcessedExtraReason()) {
124636
+ fileIncludeReasons = [...cachedChain.fileIncludeReasonDetails.next, fileIncludeReasons[0]];
124637
+ } else {
124638
+ fileIncludeReasons = append(cachedChain.fileIncludeReasonDetails.next.slice(0, reasons.length), fileIncludeReasons[0]);
124639
+ }
124640
+ }
124641
+ }
124642
+ }
124643
+ if (!chain) {
124644
+ if (!fileIncludeReasonDetails) fileIncludeReasonDetails = seenReasons && chainDiagnosticMessages(fileIncludeReasons, Diagnostics.The_file_is_in_the_program_because_Colon);
124645
+ chain = chainDiagnosticMessages(
124646
+ redirectInfo ? fileIncludeReasonDetails ? [fileIncludeReasonDetails, ...redirectInfo] : redirectInfo : fileIncludeReasonDetails,
124647
+ diagnostic,
124648
+ ...args || emptyArray
124649
+ );
124650
+ }
124651
+ if (file) {
124652
+ if (cachedChain) {
124653
+ if (!cachedChain.fileIncludeReasonDetails || !processedExtraReason && fileIncludeReasonDetails) {
124654
+ cachedChain.fileIncludeReasonDetails = fileIncludeReasonDetails;
124655
+ }
124656
+ } else {
124657
+ (fileReasonsToChain ?? (fileReasonsToChain = /* @__PURE__ */ new Map())).set(file.path, cachedChain = { fileIncludeReasonDetails, redirectInfo });
124658
+ }
124659
+ if (!cachedChain.details && !processedExtraReason) cachedChain.details = chain.next;
124660
+ }
124661
+ const location = locationReason && getReferencedFileLocation(program, locationReason);
124662
+ return location && isReferenceFileLocation(location) ? createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
124663
+ function processReason(reason) {
124664
+ if (seenReasons == null ? void 0 : seenReasons.has(reason)) return;
124665
+ (seenReasons ?? (seenReasons = /* @__PURE__ */ new Set())).add(reason);
124666
+ (fileIncludeReasons ?? (fileIncludeReasons = [])).push(fileIncludeReasonToDiagnostics(program, reason));
124667
+ populateRelatedInfo(reason);
124668
+ }
124669
+ function populateRelatedInfo(reason) {
124670
+ if (!locationReason && isReferencedFile(reason)) {
124671
+ locationReason = reason;
124672
+ } else if (locationReason !== reason) {
124673
+ relatedInfo = append(relatedInfo, getFileIncludeReasonToRelatedInformation(program, reason));
124674
+ }
124675
+ }
124676
+ function cachedFileIncludeDetailsHasProcessedExtraReason() {
124677
+ var _a;
124678
+ return ((_a = cachedChain.fileIncludeReasonDetails.next) == null ? void 0 : _a.length) !== (reasons == null ? void 0 : reasons.length);
124679
+ }
124680
+ }
124681
+ function getFileIncludeReasonToRelatedInformation(program, reason) {
124682
+ let relatedInfo = reasonToRelatedInfo == null ? void 0 : reasonToRelatedInfo.get(reason);
124683
+ if (relatedInfo === void 0) (reasonToRelatedInfo ?? (reasonToRelatedInfo = /* @__PURE__ */ new Map())).set(reason, relatedInfo = fileIncludeReasonToRelatedInformation(program, reason) ?? false);
124684
+ return relatedInfo || void 0;
124685
+ }
124686
+ function fileIncludeReasonToRelatedInformation(program, reason) {
124687
+ if (isReferencedFile(reason)) {
124688
+ const referenceLocation = getReferencedFileLocation(program, reason);
124689
+ let message2;
124690
+ switch (reason.kind) {
124691
+ case 3 /* Import */:
124692
+ message2 = Diagnostics.File_is_included_via_import_here;
124693
+ break;
124694
+ case 4 /* ReferenceFile */:
124695
+ message2 = Diagnostics.File_is_included_via_reference_here;
124696
+ break;
124697
+ case 5 /* TypeReferenceDirective */:
124698
+ message2 = Diagnostics.File_is_included_via_type_library_reference_here;
124699
+ break;
124700
+ case 7 /* LibReferenceDirective */:
124701
+ message2 = Diagnostics.File_is_included_via_library_reference_here;
124702
+ break;
124703
+ default:
124704
+ Debug.assertNever(reason);
124705
+ }
124706
+ return isReferenceFileLocation(referenceLocation) ? createFileDiagnostic(
124707
+ referenceLocation.file,
124708
+ referenceLocation.pos,
124709
+ referenceLocation.end - referenceLocation.pos,
124710
+ message2
124711
+ ) : void 0;
124712
+ }
124713
+ const currentDirectory = program.getCurrentDirectory();
124714
+ const rootNames = program.getRootFileNames();
124715
+ const options = program.getCompilerOptions();
124716
+ if (!options.configFile) return void 0;
124717
+ let configFileNode;
124718
+ let message;
124719
+ switch (reason.kind) {
124720
+ case 0 /* RootFile */:
124721
+ if (!options.configFile.configFileSpecs) return void 0;
124722
+ const fileName = getNormalizedAbsolutePath(rootNames[reason.index], currentDirectory);
124723
+ const matchedByFiles = getMatchedFileSpec(program, fileName);
124724
+ if (matchedByFiles) {
124725
+ configFileNode = getTsConfigPropArrayElementValue(options.configFile, "files", matchedByFiles);
124726
+ message = Diagnostics.File_is_matched_by_files_list_specified_here;
124727
+ break;
124728
+ }
124729
+ const matchedByInclude = getMatchedIncludeSpec(program, fileName);
124730
+ if (!matchedByInclude || !isString(matchedByInclude)) return void 0;
124731
+ configFileNode = getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude);
124732
+ message = Diagnostics.File_is_matched_by_include_pattern_specified_here;
124733
+ break;
124734
+ case 1 /* SourceFromProjectReference */:
124735
+ case 2 /* OutputFromProjectReference */:
124736
+ const resolvedProjectReferences = program.getResolvedProjectReferences();
124737
+ const projectReferences = program.getProjectReferences();
124738
+ const referencedResolvedRef = Debug.checkDefined(resolvedProjectReferences == null ? void 0 : resolvedProjectReferences[reason.index]);
124739
+ const referenceInfo = forEachProjectReference(
124740
+ projectReferences,
124741
+ resolvedProjectReferences,
124742
+ (resolvedRef, parent, index2) => resolvedRef === referencedResolvedRef ? { sourceFile: (parent == null ? void 0 : parent.sourceFile) || options.configFile, index: index2 } : void 0
124743
+ );
124744
+ if (!referenceInfo) return void 0;
124745
+ const { sourceFile, index } = referenceInfo;
124746
+ const referencesSyntax = forEachTsConfigPropArray(sourceFile, "references", (property) => isArrayLiteralExpression(property.initializer) ? property.initializer : void 0);
124747
+ return referencesSyntax && referencesSyntax.elements.length > index ? createDiagnosticForNodeInSourceFile(
124748
+ sourceFile,
124749
+ referencesSyntax.elements[index],
124750
+ reason.kind === 2 /* OutputFromProjectReference */ ? Diagnostics.File_is_output_from_referenced_project_specified_here : Diagnostics.File_is_source_from_referenced_project_specified_here
124751
+ ) : void 0;
124752
+ case 8 /* AutomaticTypeDirectiveFile */:
124753
+ if (!options.types) return void 0;
124754
+ configFileNode = getOptionsSyntaxByArrayElementValue(getCompilerOptionsObjectLiteralSyntax(), "types", reason.typeReference);
124755
+ message = Diagnostics.File_is_entry_point_of_type_library_specified_here;
124756
+ break;
124757
+ case 6 /* LibFile */:
124758
+ if (reason.index !== void 0) {
124759
+ configFileNode = getOptionsSyntaxByArrayElementValue(getCompilerOptionsObjectLiteralSyntax(), "lib", options.lib[reason.index]);
124760
+ message = Diagnostics.File_is_library_specified_here;
124761
+ break;
124762
+ }
124763
+ const target = getNameOfScriptTarget(getEmitScriptTarget(options));
124764
+ configFileNode = target ? getOptionsSyntaxByValue(getCompilerOptionsObjectLiteralSyntax(), "target", target) : void 0;
124765
+ message = Diagnostics.File_is_default_library_for_target_specified_here;
124766
+ break;
124767
+ default:
124768
+ Debug.assertNever(reason);
124769
+ }
124770
+ return configFileNode && createDiagnosticForNodeInSourceFile(
124771
+ options.configFile,
124772
+ configFileNode,
124773
+ message
124774
+ );
124775
+ }
124776
+ }
124777
+
123964
124778
  // src/compiler/builderState.ts
123965
124779
  var BuilderState;
123966
124780
  ((BuilderState2) => {
@@ -131703,9 +132517,9 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
131703
132517
  }
131704
132518
  if (!result && node.kind === 303 /* PropertyAssignment */) {
131705
132519
  const initializer = node.initializer;
131706
- const type = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0;
131707
- if (type && !isConstTypeReference(type)) {
131708
- result = serializeExistingTypeNode(type, context);
132520
+ const assertionNode = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0;
132521
+ if (assertionNode && !isConstTypeReference(assertionNode) && resolver.canReuseTypeNodeAnnotation(context, node, assertionNode, symbol)) {
132522
+ result = serializeExistingTypeNode(assertionNode, context);
131709
132523
  }
131710
132524
  }
131711
132525
  return result ?? inferTypeOfDeclaration(
@@ -131998,18 +132812,21 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
131998
132812
  return failed;
131999
132813
  }
132000
132814
  function typeFromFunctionLikeExpression(fnNode, context) {
132001
- const oldNoInferenceFallback = context.noInferenceFallback;
132002
- context.noInferenceFallback = true;
132003
- createReturnFromSignature(
132815
+ const returnType = createReturnFromSignature(
132004
132816
  fnNode,
132005
132817
  /*symbol*/
132006
132818
  void 0,
132007
132819
  context
132008
132820
  );
132009
- reuseTypeParameters(fnNode.typeParameters, context);
132010
- fnNode.parameters.map((p) => ensureParameter(p, context));
132011
- context.noInferenceFallback = oldNoInferenceFallback;
132012
- return notImplemented2;
132821
+ const typeParameters = reuseTypeParameters(fnNode.typeParameters, context);
132822
+ const parameters = fnNode.parameters.map((p) => ensureParameter(p, context));
132823
+ return syntacticResult(
132824
+ factory.createFunctionTypeNode(
132825
+ typeParameters,
132826
+ parameters,
132827
+ returnType
132828
+ )
132829
+ );
132013
132830
  }
132014
132831
  function canGetTypeFromArrayLiteral(arrayLiteral, context, isConstContext) {
132015
132832
  if (!isConstContext) {