@typescript-deploys/pr-build 5.5.0-pr-58203-3 → 5.5.0-pr-58264-13
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 +1909 -126
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +1965 -130
- package/package.json +2 -3
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240422`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6172,6 +6172,43 @@ var Diagnostics = {
|
|
|
6172
6172
|
Identifier_string_literal_or_number_literal_expected: diag(1496, 1 /* Error */, "Identifier_string_literal_or_number_literal_expected_1496", "Identifier, string literal, or number literal expected."),
|
|
6173
6173
|
Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator: diag(1497, 1 /* Error */, "Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator_1497", "Expression must be enclosed in parentheses to be used as a decorator."),
|
|
6174
6174
|
Invalid_syntax_in_decorator: diag(1498, 1 /* Error */, "Invalid_syntax_in_decorator_1498", "Invalid syntax in decorator."),
|
|
6175
|
+
Unknown_regular_expression_flag: diag(1499, 1 /* Error */, "Unknown_regular_expression_flag_1499", "Unknown regular expression flag."),
|
|
6176
|
+
Duplicate_regular_expression_flag: diag(1500, 1 /* Error */, "Duplicate_regular_expression_flag_1500", "Duplicate regular expression flag."),
|
|
6177
|
+
This_regular_expression_flag_is_only_available_when_targeting_0_or_later: diag(1501, 1 /* Error */, "This_regular_expression_flag_is_only_available_when_targeting_0_or_later_1501", "This regular expression flag is only available when targeting '{0}' or later."),
|
|
6178
|
+
The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously: diag(1502, 1 /* Error */, "The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously_1502", "The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously."),
|
|
6179
|
+
Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later: diag(1503, 1 /* Error */, "Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later_1503", "Named capturing groups are only available when targeting 'ES2018' or later."),
|
|
6180
|
+
Subpattern_flags_must_be_present_when_there_is_a_minus_sign: diag(1504, 1 /* Error */, "Subpattern_flags_must_be_present_when_there_is_a_minus_sign_1504", "Subpattern flags must be present when there is a minus sign."),
|
|
6181
|
+
Incomplete_quantifier_Digit_expected: diag(1505, 1 /* Error */, "Incomplete_quantifier_Digit_expected_1505", "Incomplete quantifier. Digit expected."),
|
|
6182
|
+
Numbers_out_of_order_in_quantifier: diag(1506, 1 /* Error */, "Numbers_out_of_order_in_quantifier_1506", "Numbers out of order in quantifier."),
|
|
6183
|
+
There_is_nothing_available_for_repetition: diag(1507, 1 /* Error */, "There_is_nothing_available_for_repetition_1507", "There is nothing available for repetition."),
|
|
6184
|
+
Unexpected_0_Did_you_mean_to_escape_it_with_backslash: diag(1508, 1 /* Error */, "Unexpected_0_Did_you_mean_to_escape_it_with_backslash_1508", "Unexpected '{0}'. Did you mean to escape it with backslash?"),
|
|
6185
|
+
This_regular_expression_flag_cannot_be_toggled_within_a_subpattern: diag(1509, 1 /* Error */, "This_regular_expression_flag_cannot_be_toggled_within_a_subpattern_1509", "This regular expression flag cannot be toggled within a subpattern."),
|
|
6186
|
+
k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets: diag(1510, 1 /* Error */, "k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets_1510", "'\\k' must be followed by a capturing group name enclosed in angle brackets."),
|
|
6187
|
+
q_is_only_available_inside_character_class: diag(1511, 1 /* Error */, "q_is_only_available_inside_character_class_1511", "'\\q' is only available inside character class."),
|
|
6188
|
+
c_must_be_followed_by_an_ASCII_letter: diag(1512, 1 /* Error */, "c_must_be_followed_by_an_ASCII_letter_1512", "'\\c' must be followed by an ASCII letter."),
|
|
6189
|
+
Undetermined_character_escape: diag(1513, 1 /* Error */, "Undetermined_character_escape_1513", "Undetermined character escape."),
|
|
6190
|
+
Expected_a_capturing_group_name: diag(1514, 1 /* Error */, "Expected_a_capturing_group_name_1514", "Expected a capturing group name."),
|
|
6191
|
+
Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other: diag(1515, 1 /* Error */, "Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other_1515", "Named capturing groups with the same name must be mutually exclusive to each other."),
|
|
6192
|
+
A_character_class_range_must_not_be_bounded_by_another_character_class: diag(1516, 1 /* Error */, "A_character_class_range_must_not_be_bounded_by_another_character_class_1516", "A character class range must not be bounded by another character class."),
|
|
6193
|
+
Range_out_of_order_in_character_class: diag(1517, 1 /* Error */, "Range_out_of_order_in_character_class_1517", "Range out of order in character class."),
|
|
6194
|
+
Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class: diag(1518, 1 /* Error */, "Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_characte_1518", "Anything that would possibly match more than a single character is invalid inside a negated character class."),
|
|
6195
|
+
Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead: diag(1519, 1 /* Error */, "Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead_1519", "Operators must not be mixed within a character class. Wrap it in a nested class instead."),
|
|
6196
|
+
Expected_a_class_set_oprand: diag(1520, 1 /* Error */, "Expected_a_class_set_oprand_1520", "Expected a class set oprand."),
|
|
6197
|
+
q_must_be_followed_by_string_alternatives_enclosed_in_braces: diag(1521, 1 /* Error */, "q_must_be_followed_by_string_alternatives_enclosed_in_braces_1521", "'\\q' must be followed by string alternatives enclosed in braces."),
|
|
6198
|
+
A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash: diag(1522, 1 /* Error */, "A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backs_1522", "A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash?"),
|
|
6199
|
+
Expected_a_Unicode_property_name: diag(1523, 1 /* Error */, "Expected_a_Unicode_property_name_1523", "Expected a Unicode property name."),
|
|
6200
|
+
Unknown_Unicode_property_name: diag(1524, 1 /* Error */, "Unknown_Unicode_property_name_1524", "Unknown Unicode property name."),
|
|
6201
|
+
Expected_a_Unicode_property_value: diag(1525, 1 /* Error */, "Expected_a_Unicode_property_value_1525", "Expected a Unicode property value."),
|
|
6202
|
+
Unknown_Unicode_property_value: diag(1526, 1 /* Error */, "Unknown_Unicode_property_value_1526", "Unknown Unicode property value."),
|
|
6203
|
+
Expected_a_Unicode_property_name_or_value: diag(1527, 1 /* Error */, "Expected_a_Unicode_property_name_or_value_1527", "Expected a Unicode property name or value."),
|
|
6204
|
+
Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set: diag(1528, 1 /* Error */, "Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_t_1528", "Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set."),
|
|
6205
|
+
Unknown_Unicode_property_name_or_value: diag(1529, 1 /* Error */, "Unknown_Unicode_property_name_or_value_1529", "Unknown Unicode property name or value."),
|
|
6206
|
+
Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1530, 1 /* Error */, "Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v__1530", "Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
|
|
6207
|
+
_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces: diag(1531, 1 /* Error */, "_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces_1531", "'\\{0}' must be followed by a Unicode property value expression enclosed in braces."),
|
|
6208
|
+
There_is_no_capturing_group_named_0_in_this_regular_expression: diag(1532, 1 /* Error */, "There_is_no_capturing_group_named_0_in_this_regular_expression_1532", "There is no capturing group named '{0}' in this regular expression."),
|
|
6209
|
+
A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression: diag(1533, 1 /* Error */, "A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_1533", "A decimal escape must refer to an existent capturing group. There are only {0} capturing groups in this regular expression."),
|
|
6210
|
+
Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression: diag(1534, 1 /* Error */, "Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression_1534", "Decimal escapes are invalid when there are no capturing groups in a regular expression."),
|
|
6211
|
+
This_character_cannot_be_escaped_in_a_regular_expression: diag(1535, 1 /* Error */, "This_character_cannot_be_escaped_in_a_regular_expression_1535", "This character cannot be escaped in a regular expression."),
|
|
6175
6212
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
6176
6213
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
6177
6214
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -7417,6 +7454,7 @@ var Diagnostics = {
|
|
|
7417
7454
|
Specify_how_the_TypeScript_watch_mode_works: diag(6715, 3 /* Message */, "Specify_how_the_TypeScript_watch_mode_works_6715", "Specify how the TypeScript watch mode works."),
|
|
7418
7455
|
Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, 3 /* Message */, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
|
|
7419
7456
|
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."),
|
|
7457
|
+
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."),
|
|
7420
7458
|
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'."),
|
|
7421
7459
|
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."),
|
|
7422
7460
|
one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
|
|
@@ -7558,6 +7596,36 @@ var Diagnostics = {
|
|
|
7558
7596
|
A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag: diag(8039, 1 /* Error */, "A_JSDoc_template_tag_may_not_follow_a_typedef_callback_or_overload_tag_8039", "A JSDoc '@template' tag may not follow a '@typedef', '@callback', or '@overload' tag"),
|
|
7559
7597
|
Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, 1 /* Error */, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
|
|
7560
7598
|
Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, 1 /* Error */, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
|
|
7599
|
+
Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations: diag(9007, 1 /* Error */, "Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9007", "Function must have an explicit return type annotation with --isolatedDeclarations."),
|
|
7600
|
+
Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations: diag(9008, 1 /* Error */, "Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9008", "Method must have an explicit return type annotation with --isolatedDeclarations."),
|
|
7601
|
+
At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations: diag(9009, 1 /* Error */, "At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations_9009", "At least one accessor must have an explicit return type annotation with --isolatedDeclarations."),
|
|
7602
|
+
Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations: diag(9010, 1 /* Error */, "Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9010", "Variable must have an explicit type annotation with --isolatedDeclarations."),
|
|
7603
|
+
Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations: diag(9011, 1 /* Error */, "Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9011", "Parameter must have an explicit type annotation with --isolatedDeclarations."),
|
|
7604
|
+
Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations: diag(9012, 1 /* Error */, "Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations_9012", "Property must have an explicit type annotation with --isolatedDeclarations."),
|
|
7605
|
+
Expression_type_can_t_be_inferred_with_isolatedDeclarations: diag(9013, 1 /* Error */, "Expression_type_can_t_be_inferred_with_isolatedDeclarations_9013", "Expression type can't be inferred with --isolatedDeclarations."),
|
|
7606
|
+
Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations: diag(9014, 1 /* Error */, "Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedD_9014", "Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations."),
|
|
7607
|
+
Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations: diag(9015, 1 /* Error */, "Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations_9015", "Objects that contain spread assignments can't be inferred with --isolatedDeclarations."),
|
|
7608
|
+
Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations: diag(9016, 1 /* Error */, "Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations_9016", "Objects that contain shorthand properties can't be inferred with --isolatedDeclarations."),
|
|
7609
|
+
Only_const_arrays_can_be_inferred_with_isolatedDeclarations: diag(9017, 1 /* Error */, "Only_const_arrays_can_be_inferred_with_isolatedDeclarations_9017", "Only const arrays can be inferred with --isolatedDeclarations."),
|
|
7610
|
+
Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations: diag(9018, 1 /* Error */, "Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations_9018", "Arrays with spread elements can't inferred with --isolatedDeclarations."),
|
|
7611
|
+
Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations: diag(9019, 1 /* Error */, "Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations_9019", "Binding elements can't be exported directly with --isolatedDeclarations."),
|
|
7612
|
+
Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations: diag(9020, 1 /* Error */, "Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDecl_9020", "Enum member initializers must be computable without references to external symbols with --isolatedDeclarations."),
|
|
7613
|
+
Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations: diag(9021, 1 /* Error */, "Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations_9021", "Extends clause can't contain an expression with --isolatedDeclarations."),
|
|
7614
|
+
Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations: diag(9022, 1 /* Error */, "Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations_9022", "Inference from class expressions is not supported with --isolatedDeclarations."),
|
|
7615
|
+
Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function: diag(9023, 1 /* Error */, "Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations__9023", "Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function."),
|
|
7616
|
+
Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations: diag(9025, 1 /* Error */, "Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_su_9025", "Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations."),
|
|
7617
|
+
Declaration_emit_for_this_file_requires_preserving_this_import_for_augmentations_This_is_not_supported_with_isolatedDeclarations: diag(9026, 1 /* Error */, "Declaration_emit_for_this_file_requires_preserving_this_import_for_augmentations_This_is_not_support_9026", "Declaration emit for this file requires preserving this import for augmentations. This is not supported with --isolatedDeclarations."),
|
|
7618
|
+
Add_a_type_annotation_to_the_variable_0: diag(9027, 1 /* Error */, "Add_a_type_annotation_to_the_variable_0_9027", "Add a type annotation to the variable {0}."),
|
|
7619
|
+
Add_a_type_annotation_to_the_parameter_0: diag(9028, 1 /* Error */, "Add_a_type_annotation_to_the_parameter_0_9028", "Add a type annotation to the parameter {0}."),
|
|
7620
|
+
Add_a_type_annotation_to_the_property_0: diag(9029, 1 /* Error */, "Add_a_type_annotation_to_the_property_0_9029", "Add a type annotation to the property {0}."),
|
|
7621
|
+
Add_a_return_type_to_the_function_expression: diag(9030, 1 /* Error */, "Add_a_return_type_to_the_function_expression_9030", "Add a return type to the function expression."),
|
|
7622
|
+
Add_a_return_type_to_the_function_declaration: diag(9031, 1 /* Error */, "Add_a_return_type_to_the_function_declaration_9031", "Add a return type to the function declaration."),
|
|
7623
|
+
Add_a_return_type_to_the_get_accessor_declaration: diag(9032, 1 /* Error */, "Add_a_return_type_to_the_get_accessor_declaration_9032", "Add a return type to the get accessor declaration."),
|
|
7624
|
+
Add_a_type_to_parameter_of_the_set_accessor_declaration: diag(9033, 1 /* Error */, "Add_a_type_to_parameter_of_the_set_accessor_declaration_9033", "Add a type to parameter of the set accessor declaration."),
|
|
7625
|
+
Add_a_return_type_to_the_method: diag(9034, 1 /* Error */, "Add_a_return_type_to_the_method_9034", "Add a return type to the method"),
|
|
7626
|
+
Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit: diag(9035, 1 /* Error */, "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035", "Add satisfies and a type assertion to this expression (satisfies T as T) to make the type explicit."),
|
|
7627
|
+
Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
|
|
7628
|
+
Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
|
|
7561
7629
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
7562
7630
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
7563
7631
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
@@ -8030,6 +8098,26 @@ var textToToken = new Map(Object.entries({
|
|
|
8030
8098
|
"#": 63 /* HashToken */,
|
|
8031
8099
|
"`": 62 /* BacktickToken */
|
|
8032
8100
|
}));
|
|
8101
|
+
var charToRegExpFlag = new Map(Object.entries({
|
|
8102
|
+
d: 1 /* HasIndices */,
|
|
8103
|
+
g: 2 /* Global */,
|
|
8104
|
+
i: 4 /* IgnoreCase */,
|
|
8105
|
+
m: 8 /* Multiline */,
|
|
8106
|
+
s: 16 /* DotAll */,
|
|
8107
|
+
u: 32 /* Unicode */,
|
|
8108
|
+
v: 64 /* UnicodeSets */,
|
|
8109
|
+
y: 128 /* Sticky */
|
|
8110
|
+
}));
|
|
8111
|
+
var regExpFlagToFirstAvailableLanguageVersion = /* @__PURE__ */ new Map([
|
|
8112
|
+
[1 /* HasIndices */, 9 /* ES2022 */],
|
|
8113
|
+
[2 /* Global */, 0 /* ES3 */],
|
|
8114
|
+
[4 /* IgnoreCase */, 0 /* ES3 */],
|
|
8115
|
+
[8 /* Multiline */, 0 /* ES3 */],
|
|
8116
|
+
[16 /* DotAll */, 5 /* ES2018 */],
|
|
8117
|
+
[32 /* Unicode */, 2 /* ES2015 */],
|
|
8118
|
+
[64 /* UnicodeSets */, 99 /* ESNext */],
|
|
8119
|
+
[128 /* Sticky */, 2 /* ES2015 */]
|
|
8120
|
+
]);
|
|
8033
8121
|
var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6e3, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43e3, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
|
|
8034
8122
|
var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6e3, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43e3, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500];
|
|
8035
8123
|
var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6e3, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101];
|
|
@@ -8078,6 +8166,10 @@ function tokenToString(t) {
|
|
|
8078
8166
|
function stringToToken(s) {
|
|
8079
8167
|
return textToToken.get(s);
|
|
8080
8168
|
}
|
|
8169
|
+
var regExpFlagChars = makeReverseMap(charToRegExpFlag);
|
|
8170
|
+
function characterToRegularExpressionFlag(c) {
|
|
8171
|
+
return charToRegExpFlag.get(c);
|
|
8172
|
+
}
|
|
8081
8173
|
function computeLineStarts(text) {
|
|
8082
8174
|
const result = [];
|
|
8083
8175
|
let pos = 0;
|
|
@@ -8174,8 +8266,11 @@ function isDigit(ch) {
|
|
|
8174
8266
|
function isHexDigit(ch) {
|
|
8175
8267
|
return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */;
|
|
8176
8268
|
}
|
|
8177
|
-
function
|
|
8178
|
-
return
|
|
8269
|
+
function isASCIILetter(ch) {
|
|
8270
|
+
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */;
|
|
8271
|
+
}
|
|
8272
|
+
function isWordCharacter(ch) {
|
|
8273
|
+
return isASCIILetter(ch) || isDigit(ch) || ch === 95 /* _ */;
|
|
8179
8274
|
}
|
|
8180
8275
|
function isOctalDigit(ch) {
|
|
8181
8276
|
return ch >= 48 /* _0 */ && ch <= 55 /* _7 */;
|
|
@@ -8493,10 +8588,10 @@ function getShebang(text) {
|
|
|
8493
8588
|
}
|
|
8494
8589
|
}
|
|
8495
8590
|
function isIdentifierStart(ch, languageVersion) {
|
|
8496
|
-
return ch
|
|
8591
|
+
return isASCIILetter(ch) || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
|
|
8497
8592
|
}
|
|
8498
8593
|
function isIdentifierPart(ch, languageVersion, identifierVariant) {
|
|
8499
|
-
return ch
|
|
8594
|
+
return isWordCharacter(ch) || ch === 36 /* $ */ || // "-" and ":" are valid in JSX Identifiers
|
|
8500
8595
|
(identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
|
|
8501
8596
|
}
|
|
8502
8597
|
function isIdentifierText(name, languageVersion, identifierVariant) {
|
|
@@ -8817,7 +8912,9 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8817
8912
|
result += text.substring(start2, pos);
|
|
8818
8913
|
result += scanEscapeSequence(
|
|
8819
8914
|
/*shouldEmitInvalidEscapeError*/
|
|
8820
|
-
true
|
|
8915
|
+
true,
|
|
8916
|
+
/*isRegularExpression*/
|
|
8917
|
+
false
|
|
8821
8918
|
);
|
|
8822
8919
|
start2 = pos;
|
|
8823
8920
|
continue;
|
|
@@ -8861,7 +8958,11 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8861
8958
|
}
|
|
8862
8959
|
if (currChar === 92 /* backslash */) {
|
|
8863
8960
|
contents += text.substring(start2, pos);
|
|
8864
|
-
contents += scanEscapeSequence(
|
|
8961
|
+
contents += scanEscapeSequence(
|
|
8962
|
+
shouldEmitInvalidEscapeError,
|
|
8963
|
+
/*isRegularExpression*/
|
|
8964
|
+
false
|
|
8965
|
+
);
|
|
8865
8966
|
start2 = pos;
|
|
8866
8967
|
continue;
|
|
8867
8968
|
}
|
|
@@ -8881,7 +8982,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8881
8982
|
tokenValue = contents;
|
|
8882
8983
|
return resultingToken;
|
|
8883
8984
|
}
|
|
8884
|
-
function scanEscapeSequence(shouldEmitInvalidEscapeError) {
|
|
8985
|
+
function scanEscapeSequence(shouldEmitInvalidEscapeError, isRegularExpression) {
|
|
8885
8986
|
const start2 = pos;
|
|
8886
8987
|
pos++;
|
|
8887
8988
|
if (pos >= end) {
|
|
@@ -8909,7 +9010,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8909
9010
|
pos++;
|
|
8910
9011
|
}
|
|
8911
9012
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8912
|
-
if (shouldEmitInvalidEscapeError) {
|
|
9013
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8913
9014
|
const code = parseInt(text.substring(start2 + 1, pos), 8);
|
|
8914
9015
|
error(Diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start2, pos - start2, "\\x" + code.toString(16).padStart(2, "0"));
|
|
8915
9016
|
return String.fromCharCode(code);
|
|
@@ -8918,7 +9019,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8918
9019
|
case 56 /* _8 */:
|
|
8919
9020
|
case 57 /* _9 */:
|
|
8920
9021
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8921
|
-
if (shouldEmitInvalidEscapeError) {
|
|
9022
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8922
9023
|
error(Diagnostics.Escape_sequence_0_is_not_allowed, start2, pos - start2, text.substring(start2, pos));
|
|
8923
9024
|
return String.fromCharCode(ch);
|
|
8924
9025
|
}
|
|
@@ -8940,62 +9041,42 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
8940
9041
|
case 34 /* doubleQuote */:
|
|
8941
9042
|
return '"';
|
|
8942
9043
|
case 117 /* u */:
|
|
8943
|
-
if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
8944
|
-
pos
|
|
8945
|
-
|
|
8946
|
-
1,
|
|
8947
|
-
/*canHaveSeparators*/
|
|
8948
|
-
false
|
|
8949
|
-
);
|
|
8950
|
-
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
|
|
8951
|
-
if (escapedValue < 0) {
|
|
8952
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8953
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8954
|
-
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8955
|
-
}
|
|
8956
|
-
return text.substring(start2, pos);
|
|
8957
|
-
}
|
|
8958
|
-
if (!isCodePoint(escapedValue)) {
|
|
8959
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8960
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8961
|
-
error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
|
|
8962
|
-
}
|
|
8963
|
-
return text.substring(start2, pos);
|
|
8964
|
-
}
|
|
8965
|
-
if (pos >= end) {
|
|
8966
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8967
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8968
|
-
error(Diagnostics.Unexpected_end_of_text);
|
|
8969
|
-
}
|
|
8970
|
-
return text.substring(start2, pos);
|
|
8971
|
-
}
|
|
8972
|
-
if (text.charCodeAt(pos) !== 125 /* closeBrace */) {
|
|
8973
|
-
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8974
|
-
if (shouldEmitInvalidEscapeError) {
|
|
8975
|
-
error(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
8976
|
-
}
|
|
8977
|
-
return text.substring(start2, pos);
|
|
8978
|
-
}
|
|
8979
|
-
pos++;
|
|
8980
|
-
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
8981
|
-
return utf16EncodeAsString(escapedValue);
|
|
9044
|
+
if ((!isRegularExpression || shouldEmitInvalidEscapeError) && pos < end && text.charCodeAt(pos) === 123 /* openBrace */) {
|
|
9045
|
+
pos -= 2;
|
|
9046
|
+
return scanExtendedUnicodeEscape(isRegularExpression || shouldEmitInvalidEscapeError);
|
|
8982
9047
|
}
|
|
8983
9048
|
for (; pos < start2 + 6; pos++) {
|
|
8984
9049
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
8985
9050
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8986
|
-
if (shouldEmitInvalidEscapeError) {
|
|
9051
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8987
9052
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
8988
9053
|
}
|
|
8989
9054
|
return text.substring(start2, pos);
|
|
8990
9055
|
}
|
|
8991
9056
|
}
|
|
8992
9057
|
tokenFlags |= 1024 /* UnicodeEscape */;
|
|
8993
|
-
|
|
9058
|
+
const escapedValue = parseInt(text.substring(start2 + 2, pos), 16);
|
|
9059
|
+
const escapedValueString = String.fromCharCode(escapedValue);
|
|
9060
|
+
if (isRegularExpression && shouldEmitInvalidEscapeError && escapedValue >= 55296 && escapedValue <= 56319 && pos + 6 < end && text.substring(pos, pos + 2) === "\\u" && text.charCodeAt(pos + 2) !== 123 /* openBrace */) {
|
|
9061
|
+
const nextStart = pos;
|
|
9062
|
+
let nextPos = pos + 2;
|
|
9063
|
+
for (; nextPos < nextStart + 6; nextPos++) {
|
|
9064
|
+
if (!isHexDigit(text.charCodeAt(pos))) {
|
|
9065
|
+
return escapedValueString;
|
|
9066
|
+
}
|
|
9067
|
+
}
|
|
9068
|
+
const nextEscapedValue = parseInt(text.substring(nextStart + 2, nextPos), 16);
|
|
9069
|
+
if (nextEscapedValue >= 56320 && nextEscapedValue <= 57343) {
|
|
9070
|
+
pos = nextPos;
|
|
9071
|
+
return escapedValueString + String.fromCharCode(nextEscapedValue);
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9074
|
+
return escapedValueString;
|
|
8994
9075
|
case 120 /* x */:
|
|
8995
9076
|
for (; pos < start2 + 4; pos++) {
|
|
8996
9077
|
if (!(pos < end && isHexDigit(text.charCodeAt(pos)))) {
|
|
8997
9078
|
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
8998
|
-
if (shouldEmitInvalidEscapeError) {
|
|
9079
|
+
if (isRegularExpression || shouldEmitInvalidEscapeError) {
|
|
8999
9080
|
error(Diagnostics.Hexadecimal_digit_expected);
|
|
9000
9081
|
}
|
|
9001
9082
|
return text.substring(start2, pos);
|
|
@@ -9012,10 +9093,16 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9012
9093
|
case 8233 /* paragraphSeparator */:
|
|
9013
9094
|
return "";
|
|
9014
9095
|
default:
|
|
9096
|
+
if (isRegularExpression && (shouldEmitInvalidEscapeError || isIdentifierPart(ch, languageVersion))) {
|
|
9097
|
+
error(Diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, pos - 2, 2);
|
|
9098
|
+
}
|
|
9015
9099
|
return String.fromCharCode(ch);
|
|
9016
9100
|
}
|
|
9017
9101
|
}
|
|
9018
|
-
function scanExtendedUnicodeEscape() {
|
|
9102
|
+
function scanExtendedUnicodeEscape(shouldEmitInvalidEscapeError) {
|
|
9103
|
+
const start2 = pos;
|
|
9104
|
+
pos += 3;
|
|
9105
|
+
const escapedStart = pos;
|
|
9019
9106
|
const escapedValueString = scanMinimumNumberOfHexDigits(
|
|
9020
9107
|
1,
|
|
9021
9108
|
/*canHaveSeparators*/
|
|
@@ -9024,24 +9111,34 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9024
9111
|
const escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
|
|
9025
9112
|
let isInvalidExtendedEscape = false;
|
|
9026
9113
|
if (escapedValue < 0) {
|
|
9027
|
-
|
|
9114
|
+
if (shouldEmitInvalidEscapeError) {
|
|
9115
|
+
error(Diagnostics.Hexadecimal_digit_expected);
|
|
9116
|
+
}
|
|
9028
9117
|
isInvalidExtendedEscape = true;
|
|
9029
9118
|
} else if (escapedValue > 1114111) {
|
|
9030
|
-
|
|
9119
|
+
if (shouldEmitInvalidEscapeError) {
|
|
9120
|
+
error(Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive, escapedStart, pos - escapedStart);
|
|
9121
|
+
}
|
|
9031
9122
|
isInvalidExtendedEscape = true;
|
|
9032
9123
|
}
|
|
9033
9124
|
if (pos >= end) {
|
|
9034
|
-
|
|
9125
|
+
if (shouldEmitInvalidEscapeError) {
|
|
9126
|
+
error(Diagnostics.Unexpected_end_of_text);
|
|
9127
|
+
}
|
|
9035
9128
|
isInvalidExtendedEscape = true;
|
|
9036
9129
|
} else if (text.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
9037
9130
|
pos++;
|
|
9038
9131
|
} else {
|
|
9039
|
-
|
|
9132
|
+
if (shouldEmitInvalidEscapeError) {
|
|
9133
|
+
error(Diagnostics.Unterminated_Unicode_escape_sequence);
|
|
9134
|
+
}
|
|
9040
9135
|
isInvalidExtendedEscape = true;
|
|
9041
9136
|
}
|
|
9042
9137
|
if (isInvalidExtendedEscape) {
|
|
9043
|
-
|
|
9138
|
+
tokenFlags |= 2048 /* ContainsInvalidEscape */;
|
|
9139
|
+
return text.substring(start2, pos);
|
|
9044
9140
|
}
|
|
9141
|
+
tokenFlags |= 8 /* ExtendedUnicodeEscape */;
|
|
9045
9142
|
return utf16EncodeAsString(escapedValue);
|
|
9046
9143
|
}
|
|
9047
9144
|
function peekUnicodeEscape() {
|
|
@@ -9083,9 +9180,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9083
9180
|
} else if (ch === 92 /* backslash */) {
|
|
9084
9181
|
ch = peekExtendedUnicodeEscape();
|
|
9085
9182
|
if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9183
|
+
result += scanExtendedUnicodeEscape(
|
|
9184
|
+
/*shouldEmitInvalidEscapeError*/
|
|
9185
|
+
true
|
|
9186
|
+
);
|
|
9089
9187
|
start2 = pos;
|
|
9090
9188
|
continue;
|
|
9091
9189
|
}
|
|
@@ -9550,9 +9648,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9550
9648
|
case 92 /* backslash */:
|
|
9551
9649
|
const extendedCookedChar = peekExtendedUnicodeEscape();
|
|
9552
9650
|
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9651
|
+
tokenValue = scanExtendedUnicodeEscape(
|
|
9652
|
+
/*shouldEmitInvalidEscapeError*/
|
|
9653
|
+
true
|
|
9654
|
+
) + scanIdentifierParts();
|
|
9556
9655
|
return token = getIdentifierToken();
|
|
9557
9656
|
}
|
|
9558
9657
|
const cookedChar = peekUnicodeEscape();
|
|
@@ -9567,7 +9666,7 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9567
9666
|
return token = 0 /* Unknown */;
|
|
9568
9667
|
case 35 /* hash */:
|
|
9569
9668
|
if (pos !== 0 && text[pos + 1] === "!") {
|
|
9570
|
-
error(Diagnostics.can_only_be_used_at_the_start_of_a_file);
|
|
9669
|
+
error(Diagnostics.can_only_be_used_at_the_start_of_a_file, pos, 2);
|
|
9571
9670
|
pos++;
|
|
9572
9671
|
return token = 0 /* Unknown */;
|
|
9573
9672
|
}
|
|
@@ -9576,9 +9675,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9576
9675
|
pos++;
|
|
9577
9676
|
const extendedCookedChar2 = peekExtendedUnicodeEscape();
|
|
9578
9677
|
if (extendedCookedChar2 >= 0 && isIdentifierStart(extendedCookedChar2, languageVersion)) {
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9678
|
+
tokenValue = "#" + scanExtendedUnicodeEscape(
|
|
9679
|
+
/*shouldEmitInvalidEscapeError*/
|
|
9680
|
+
true
|
|
9681
|
+
) + scanIdentifierParts();
|
|
9582
9682
|
return token = 81 /* PrivateIdentifier */;
|
|
9583
9683
|
}
|
|
9584
9684
|
const cookedChar2 = peekUnicodeEscape();
|
|
@@ -9719,14 +9819,841 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9719
9819
|
}
|
|
9720
9820
|
p++;
|
|
9721
9821
|
}
|
|
9722
|
-
|
|
9822
|
+
const isUnterminated = !!(tokenFlags & 4 /* Unterminated */);
|
|
9823
|
+
const endOfBody = p - (isUnterminated ? 0 : 1);
|
|
9824
|
+
let regExpFlags = 0 /* None */;
|
|
9825
|
+
while (p < end) {
|
|
9826
|
+
const ch = text.charCodeAt(p);
|
|
9827
|
+
if (!isIdentifierPart(ch, languageVersion)) {
|
|
9828
|
+
break;
|
|
9829
|
+
}
|
|
9830
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
9831
|
+
if (flag === void 0) {
|
|
9832
|
+
error(Diagnostics.Unknown_regular_expression_flag, p, 1);
|
|
9833
|
+
} else if (regExpFlags & flag) {
|
|
9834
|
+
error(Diagnostics.Duplicate_regular_expression_flag, p, 1);
|
|
9835
|
+
} else if (((regExpFlags | flag) & 96 /* UnicodeMode */) === 96 /* UnicodeMode */) {
|
|
9836
|
+
error(Diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, 1);
|
|
9837
|
+
} else {
|
|
9838
|
+
regExpFlags |= flag;
|
|
9839
|
+
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
9840
|
+
if (languageVersion < availableFrom) {
|
|
9841
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, 1, getNameOfScriptTarget(availableFrom));
|
|
9842
|
+
}
|
|
9843
|
+
}
|
|
9723
9844
|
p++;
|
|
9724
9845
|
}
|
|
9725
|
-
pos =
|
|
9846
|
+
pos = tokenStart + 1;
|
|
9847
|
+
const saveTokenPos = tokenStart;
|
|
9848
|
+
const saveTokenFlags = tokenFlags;
|
|
9849
|
+
scanRegularExpressionWorker(text, endOfBody, regExpFlags, isUnterminated);
|
|
9850
|
+
if (!isUnterminated) {
|
|
9851
|
+
pos = p;
|
|
9852
|
+
}
|
|
9853
|
+
tokenStart = saveTokenPos;
|
|
9854
|
+
tokenFlags = saveTokenFlags;
|
|
9726
9855
|
tokenValue = text.substring(tokenStart, pos);
|
|
9727
9856
|
token = 14 /* RegularExpressionLiteral */;
|
|
9728
9857
|
}
|
|
9729
9858
|
return token;
|
|
9859
|
+
function scanRegularExpressionWorker(text2, end2, regExpFlags, isUnterminated) {
|
|
9860
|
+
const unicodeMode = !!(regExpFlags & 96 /* UnicodeMode */);
|
|
9861
|
+
const unicodeSetsMode = !!(regExpFlags & 64 /* UnicodeSets */);
|
|
9862
|
+
let mayContainStrings = false;
|
|
9863
|
+
let numberOfCapturingGroups = 0;
|
|
9864
|
+
const groupSpecifiers = /* @__PURE__ */ new Set();
|
|
9865
|
+
const groupNameReferences = [];
|
|
9866
|
+
const decimalEscapes = [];
|
|
9867
|
+
const namedCapturingGroups = [];
|
|
9868
|
+
function scanDisjunction(isInGroup) {
|
|
9869
|
+
while (true) {
|
|
9870
|
+
namedCapturingGroups.push(/* @__PURE__ */ new Set());
|
|
9871
|
+
scanAlternative(isInGroup);
|
|
9872
|
+
namedCapturingGroups.pop();
|
|
9873
|
+
if (text2.charCodeAt(pos) !== 124 /* bar */) {
|
|
9874
|
+
return;
|
|
9875
|
+
}
|
|
9876
|
+
pos++;
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
function scanAlternative(isInGroup) {
|
|
9880
|
+
let isPreviousTermQuantifiable = false;
|
|
9881
|
+
while (pos < end2) {
|
|
9882
|
+
const start2 = pos;
|
|
9883
|
+
const ch = text2.charCodeAt(pos);
|
|
9884
|
+
switch (ch) {
|
|
9885
|
+
case 94 /* caret */:
|
|
9886
|
+
case 36 /* $ */:
|
|
9887
|
+
pos++;
|
|
9888
|
+
isPreviousTermQuantifiable = false;
|
|
9889
|
+
break;
|
|
9890
|
+
case 92 /* backslash */:
|
|
9891
|
+
pos++;
|
|
9892
|
+
switch (text2.charCodeAt(pos)) {
|
|
9893
|
+
case 98 /* b */:
|
|
9894
|
+
case 66 /* B */:
|
|
9895
|
+
pos++;
|
|
9896
|
+
isPreviousTermQuantifiable = false;
|
|
9897
|
+
break;
|
|
9898
|
+
default:
|
|
9899
|
+
scanAtomEscape();
|
|
9900
|
+
isPreviousTermQuantifiable = true;
|
|
9901
|
+
break;
|
|
9902
|
+
}
|
|
9903
|
+
break;
|
|
9904
|
+
case 40 /* openParen */:
|
|
9905
|
+
pos++;
|
|
9906
|
+
if (text2.charCodeAt(pos) === 63 /* question */) {
|
|
9907
|
+
pos++;
|
|
9908
|
+
switch (text2.charCodeAt(pos)) {
|
|
9909
|
+
case 61 /* equals */:
|
|
9910
|
+
case 33 /* exclamation */:
|
|
9911
|
+
pos++;
|
|
9912
|
+
isPreviousTermQuantifiable = false;
|
|
9913
|
+
break;
|
|
9914
|
+
case 60 /* lessThan */:
|
|
9915
|
+
const groupNameStart = pos;
|
|
9916
|
+
pos++;
|
|
9917
|
+
switch (text2.charCodeAt(pos)) {
|
|
9918
|
+
case 61 /* equals */:
|
|
9919
|
+
case 33 /* exclamation */:
|
|
9920
|
+
pos++;
|
|
9921
|
+
isPreviousTermQuantifiable = false;
|
|
9922
|
+
break;
|
|
9923
|
+
default:
|
|
9924
|
+
scanGroupName(
|
|
9925
|
+
/*isReference*/
|
|
9926
|
+
false
|
|
9927
|
+
);
|
|
9928
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
9929
|
+
if (languageVersion < 5 /* ES2018 */) {
|
|
9930
|
+
error(Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, pos - groupNameStart);
|
|
9931
|
+
}
|
|
9932
|
+
numberOfCapturingGroups++;
|
|
9933
|
+
isPreviousTermQuantifiable = true;
|
|
9934
|
+
break;
|
|
9935
|
+
}
|
|
9936
|
+
break;
|
|
9937
|
+
default:
|
|
9938
|
+
const start3 = pos;
|
|
9939
|
+
const setFlags = scanPatternModifiers(0 /* None */);
|
|
9940
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
9941
|
+
pos++;
|
|
9942
|
+
scanPatternModifiers(setFlags);
|
|
9943
|
+
if (pos === start3 + 1) {
|
|
9944
|
+
error(Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start3, pos - start3);
|
|
9945
|
+
}
|
|
9946
|
+
}
|
|
9947
|
+
scanExpectedChar(58 /* colon */);
|
|
9948
|
+
isPreviousTermQuantifiable = true;
|
|
9949
|
+
break;
|
|
9950
|
+
}
|
|
9951
|
+
} else {
|
|
9952
|
+
numberOfCapturingGroups++;
|
|
9953
|
+
isPreviousTermQuantifiable = true;
|
|
9954
|
+
}
|
|
9955
|
+
scanDisjunction(
|
|
9956
|
+
/*isInGroup*/
|
|
9957
|
+
true
|
|
9958
|
+
);
|
|
9959
|
+
scanExpectedChar(41 /* closeParen */);
|
|
9960
|
+
break;
|
|
9961
|
+
case 123 /* openBrace */:
|
|
9962
|
+
pos++;
|
|
9963
|
+
const digitsStart = pos;
|
|
9964
|
+
scanDigits();
|
|
9965
|
+
const min2 = tokenValue;
|
|
9966
|
+
if (text2.charCodeAt(pos) === 44 /* comma */) {
|
|
9967
|
+
pos++;
|
|
9968
|
+
scanDigits();
|
|
9969
|
+
const max = tokenValue;
|
|
9970
|
+
if (!min2) {
|
|
9971
|
+
if (max || text2.charCodeAt(pos) === 125 /* closeBrace */) {
|
|
9972
|
+
error(Diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0);
|
|
9973
|
+
} else {
|
|
9974
|
+
if (unicodeMode) {
|
|
9975
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
9976
|
+
}
|
|
9977
|
+
isPreviousTermQuantifiable = true;
|
|
9978
|
+
break;
|
|
9979
|
+
}
|
|
9980
|
+
}
|
|
9981
|
+
if (max && Number.parseInt(min2) > Number.parseInt(max)) {
|
|
9982
|
+
error(Diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, pos - digitsStart);
|
|
9983
|
+
}
|
|
9984
|
+
} else if (!min2) {
|
|
9985
|
+
if (unicodeMode) {
|
|
9986
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start2, 1, String.fromCharCode(ch));
|
|
9987
|
+
}
|
|
9988
|
+
isPreviousTermQuantifiable = true;
|
|
9989
|
+
break;
|
|
9990
|
+
}
|
|
9991
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
9992
|
+
pos--;
|
|
9993
|
+
case 42 /* asterisk */:
|
|
9994
|
+
case 43 /* plus */:
|
|
9995
|
+
case 63 /* question */:
|
|
9996
|
+
pos++;
|
|
9997
|
+
if (text2.charCodeAt(pos) === 63 /* question */) {
|
|
9998
|
+
pos++;
|
|
9999
|
+
}
|
|
10000
|
+
if (!isPreviousTermQuantifiable) {
|
|
10001
|
+
error(Diagnostics.There_is_nothing_available_for_repetition, start2, pos - start2);
|
|
10002
|
+
}
|
|
10003
|
+
isPreviousTermQuantifiable = false;
|
|
10004
|
+
break;
|
|
10005
|
+
case 46 /* dot */:
|
|
10006
|
+
pos++;
|
|
10007
|
+
isPreviousTermQuantifiable = true;
|
|
10008
|
+
break;
|
|
10009
|
+
case 91 /* openBracket */:
|
|
10010
|
+
pos++;
|
|
10011
|
+
if (unicodeSetsMode) {
|
|
10012
|
+
scanClassSetExpression();
|
|
10013
|
+
} else {
|
|
10014
|
+
scanClassRanges();
|
|
10015
|
+
}
|
|
10016
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
10017
|
+
isPreviousTermQuantifiable = true;
|
|
10018
|
+
break;
|
|
10019
|
+
case 41 /* closeParen */:
|
|
10020
|
+
if (isInGroup) {
|
|
10021
|
+
return;
|
|
10022
|
+
}
|
|
10023
|
+
case 93 /* closeBracket */:
|
|
10024
|
+
case 125 /* closeBrace */:
|
|
10025
|
+
if (isUnterminated && !isInGroup) {
|
|
10026
|
+
return;
|
|
10027
|
+
}
|
|
10028
|
+
if (unicodeMode || ch === 41 /* closeParen */) {
|
|
10029
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10030
|
+
}
|
|
10031
|
+
pos++;
|
|
10032
|
+
isPreviousTermQuantifiable = true;
|
|
10033
|
+
break;
|
|
10034
|
+
case 47 /* slash */:
|
|
10035
|
+
case 124 /* bar */:
|
|
10036
|
+
return;
|
|
10037
|
+
default:
|
|
10038
|
+
scanSourceCharacter();
|
|
10039
|
+
isPreviousTermQuantifiable = true;
|
|
10040
|
+
break;
|
|
10041
|
+
}
|
|
10042
|
+
}
|
|
10043
|
+
}
|
|
10044
|
+
function scanPatternModifiers(currFlags) {
|
|
10045
|
+
while (pos < end2) {
|
|
10046
|
+
const ch = text2.charCodeAt(pos);
|
|
10047
|
+
if (!isIdentifierPart(ch, languageVersion)) {
|
|
10048
|
+
break;
|
|
10049
|
+
}
|
|
10050
|
+
const flag = characterToRegularExpressionFlag(String.fromCharCode(ch));
|
|
10051
|
+
if (flag === void 0) {
|
|
10052
|
+
error(Diagnostics.Unknown_regular_expression_flag, pos, 1);
|
|
10053
|
+
} else if (currFlags & flag) {
|
|
10054
|
+
error(Diagnostics.Duplicate_regular_expression_flag, pos, 1);
|
|
10055
|
+
} else if (!(flag & 28 /* Modifiers */)) {
|
|
10056
|
+
error(Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, pos, 1);
|
|
10057
|
+
} else {
|
|
10058
|
+
currFlags |= flag;
|
|
10059
|
+
const availableFrom = regExpFlagToFirstAvailableLanguageVersion.get(flag);
|
|
10060
|
+
if (languageVersion < availableFrom) {
|
|
10061
|
+
error(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, getNameOfScriptTarget(availableFrom));
|
|
10062
|
+
}
|
|
10063
|
+
}
|
|
10064
|
+
pos++;
|
|
10065
|
+
}
|
|
10066
|
+
return currFlags;
|
|
10067
|
+
}
|
|
10068
|
+
function scanAtomEscape() {
|
|
10069
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10070
|
+
switch (text2.charCodeAt(pos)) {
|
|
10071
|
+
case 107 /* k */:
|
|
10072
|
+
pos++;
|
|
10073
|
+
if (text2.charCodeAt(pos) === 60 /* lessThan */) {
|
|
10074
|
+
pos++;
|
|
10075
|
+
scanGroupName(
|
|
10076
|
+
/*isReference*/
|
|
10077
|
+
true
|
|
10078
|
+
);
|
|
10079
|
+
scanExpectedChar(62 /* greaterThan */);
|
|
10080
|
+
} else if (unicodeMode) {
|
|
10081
|
+
error(Diagnostics.k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, pos - 2, 2);
|
|
10082
|
+
}
|
|
10083
|
+
break;
|
|
10084
|
+
case 113 /* q */:
|
|
10085
|
+
if (unicodeSetsMode) {
|
|
10086
|
+
pos++;
|
|
10087
|
+
error(Diagnostics.q_is_only_available_inside_character_class, pos - 2, 2);
|
|
10088
|
+
break;
|
|
10089
|
+
}
|
|
10090
|
+
default:
|
|
10091
|
+
Debug.assert(scanCharacterClassEscape() || scanDecimalEscape() || scanCharacterEscape());
|
|
10092
|
+
break;
|
|
10093
|
+
}
|
|
10094
|
+
}
|
|
10095
|
+
function scanDecimalEscape() {
|
|
10096
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10097
|
+
const ch = text2.charCodeAt(pos);
|
|
10098
|
+
if (ch >= 49 /* _1 */ && ch <= 57 /* _9 */) {
|
|
10099
|
+
const start2 = pos;
|
|
10100
|
+
scanDigits();
|
|
10101
|
+
decimalEscapes.push({ pos: start2, end: pos, value: +tokenValue });
|
|
10102
|
+
return true;
|
|
10103
|
+
}
|
|
10104
|
+
return false;
|
|
10105
|
+
}
|
|
10106
|
+
function scanCharacterEscape() {
|
|
10107
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10108
|
+
let ch = text2.charCodeAt(pos);
|
|
10109
|
+
switch (ch) {
|
|
10110
|
+
case 99 /* c */:
|
|
10111
|
+
pos++;
|
|
10112
|
+
ch = text2.charCodeAt(pos);
|
|
10113
|
+
if (isASCIILetter(ch)) {
|
|
10114
|
+
pos++;
|
|
10115
|
+
return String.fromCharCode(ch & 31);
|
|
10116
|
+
}
|
|
10117
|
+
if (unicodeMode) {
|
|
10118
|
+
error(Diagnostics.c_must_be_followed_by_an_ASCII_letter, pos - 2, 2);
|
|
10119
|
+
}
|
|
10120
|
+
return String.fromCharCode(ch);
|
|
10121
|
+
case 94 /* caret */:
|
|
10122
|
+
case 36 /* $ */:
|
|
10123
|
+
case 47 /* slash */:
|
|
10124
|
+
case 92 /* backslash */:
|
|
10125
|
+
case 46 /* dot */:
|
|
10126
|
+
case 42 /* asterisk */:
|
|
10127
|
+
case 43 /* plus */:
|
|
10128
|
+
case 63 /* question */:
|
|
10129
|
+
case 40 /* openParen */:
|
|
10130
|
+
case 41 /* closeParen */:
|
|
10131
|
+
case 91 /* openBracket */:
|
|
10132
|
+
case 93 /* closeBracket */:
|
|
10133
|
+
case 123 /* openBrace */:
|
|
10134
|
+
case 125 /* closeBrace */:
|
|
10135
|
+
case 124 /* bar */:
|
|
10136
|
+
pos++;
|
|
10137
|
+
return String.fromCharCode(ch);
|
|
10138
|
+
default:
|
|
10139
|
+
if (pos >= end2) {
|
|
10140
|
+
error(Diagnostics.Undetermined_character_escape, pos - 1, 1, ch);
|
|
10141
|
+
return "\\";
|
|
10142
|
+
}
|
|
10143
|
+
pos--;
|
|
10144
|
+
return scanEscapeSequence(
|
|
10145
|
+
/*shouldEmitInvalidEscapeError*/
|
|
10146
|
+
unicodeMode,
|
|
10147
|
+
/*isRegularExpression*/
|
|
10148
|
+
true
|
|
10149
|
+
);
|
|
10150
|
+
}
|
|
10151
|
+
}
|
|
10152
|
+
function scanGroupName(isReference) {
|
|
10153
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 60 /* lessThan */);
|
|
10154
|
+
tokenStart = pos;
|
|
10155
|
+
scanIdentifier(codePointAt(text2, pos), languageVersion);
|
|
10156
|
+
if (pos === tokenStart) {
|
|
10157
|
+
error(Diagnostics.Expected_a_capturing_group_name);
|
|
10158
|
+
} else if (isReference) {
|
|
10159
|
+
groupNameReferences.push({ pos: tokenStart, end: pos, name: tokenValue });
|
|
10160
|
+
} else if (namedCapturingGroups.some((group2) => group2.has(tokenValue))) {
|
|
10161
|
+
error(Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, pos - tokenStart);
|
|
10162
|
+
} else {
|
|
10163
|
+
last(namedCapturingGroups).add(tokenValue);
|
|
10164
|
+
groupSpecifiers.add(tokenValue);
|
|
10165
|
+
}
|
|
10166
|
+
}
|
|
10167
|
+
function isClassContentExit(ch) {
|
|
10168
|
+
return ch === 93 /* closeBracket */ || pos >= end2;
|
|
10169
|
+
}
|
|
10170
|
+
function scanClassRanges() {
|
|
10171
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
|
|
10172
|
+
if (text2.charCodeAt(pos) === 94 /* caret */) {
|
|
10173
|
+
pos++;
|
|
10174
|
+
}
|
|
10175
|
+
while (pos < end2) {
|
|
10176
|
+
const ch = text2.charCodeAt(pos);
|
|
10177
|
+
if (isClassContentExit(ch)) {
|
|
10178
|
+
return;
|
|
10179
|
+
}
|
|
10180
|
+
const minStart = pos;
|
|
10181
|
+
const minCharacter = scanClassAtom();
|
|
10182
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
10183
|
+
pos++;
|
|
10184
|
+
const ch2 = text2.charCodeAt(pos);
|
|
10185
|
+
if (isClassContentExit(ch2)) {
|
|
10186
|
+
return;
|
|
10187
|
+
}
|
|
10188
|
+
if (!minCharacter) {
|
|
10189
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, pos - 1 - minStart);
|
|
10190
|
+
}
|
|
10191
|
+
const maxStart = pos;
|
|
10192
|
+
const maxCharacter = scanClassAtom();
|
|
10193
|
+
if (!maxCharacter) {
|
|
10194
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, pos - maxStart);
|
|
10195
|
+
continue;
|
|
10196
|
+
}
|
|
10197
|
+
if (!minCharacter) {
|
|
10198
|
+
continue;
|
|
10199
|
+
}
|
|
10200
|
+
const minCharacterValue = codePointAt(minCharacter, 0);
|
|
10201
|
+
const maxCharacterValue = codePointAt(maxCharacter, 0);
|
|
10202
|
+
if (minCharacter.length === charSize(minCharacterValue) && maxCharacter.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
10203
|
+
error(Diagnostics.Range_out_of_order_in_character_class, minStart, pos - minStart);
|
|
10204
|
+
}
|
|
10205
|
+
}
|
|
10206
|
+
}
|
|
10207
|
+
}
|
|
10208
|
+
function scanClassSetExpression() {
|
|
10209
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 91 /* openBracket */);
|
|
10210
|
+
let isCharacterComplement = false;
|
|
10211
|
+
if (text2.charCodeAt(pos) === 94 /* caret */) {
|
|
10212
|
+
pos++;
|
|
10213
|
+
isCharacterComplement = true;
|
|
10214
|
+
}
|
|
10215
|
+
let expressionMayContainStrings = false;
|
|
10216
|
+
let ch = text2.charCodeAt(pos);
|
|
10217
|
+
if (isClassContentExit(ch)) {
|
|
10218
|
+
return;
|
|
10219
|
+
}
|
|
10220
|
+
let start2 = pos;
|
|
10221
|
+
let oprand;
|
|
10222
|
+
switch (text2.slice(pos, pos + 2)) {
|
|
10223
|
+
case "--":
|
|
10224
|
+
case "&&":
|
|
10225
|
+
error(Diagnostics.Expected_a_class_set_oprand);
|
|
10226
|
+
mayContainStrings = false;
|
|
10227
|
+
break;
|
|
10228
|
+
default:
|
|
10229
|
+
oprand = scanClassSetOprand();
|
|
10230
|
+
break;
|
|
10231
|
+
}
|
|
10232
|
+
switch (text2.charCodeAt(pos)) {
|
|
10233
|
+
case 45 /* minus */:
|
|
10234
|
+
if (text2.charCodeAt(pos + 1) === 45 /* minus */) {
|
|
10235
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10236
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10237
|
+
}
|
|
10238
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10239
|
+
scanClassSetSubExpression(3 /* ClassSubtraction */);
|
|
10240
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10241
|
+
return;
|
|
10242
|
+
}
|
|
10243
|
+
break;
|
|
10244
|
+
case 38 /* ampersand */:
|
|
10245
|
+
if (text2.charCodeAt(pos + 1) === 38 /* ampersand */) {
|
|
10246
|
+
scanClassSetSubExpression(2 /* ClassIntersection */);
|
|
10247
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10248
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10249
|
+
}
|
|
10250
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10251
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10252
|
+
return;
|
|
10253
|
+
} else {
|
|
10254
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10255
|
+
}
|
|
10256
|
+
break;
|
|
10257
|
+
default:
|
|
10258
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10259
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start2, pos - start2);
|
|
10260
|
+
}
|
|
10261
|
+
expressionMayContainStrings = mayContainStrings;
|
|
10262
|
+
break;
|
|
10263
|
+
}
|
|
10264
|
+
while (pos < end2) {
|
|
10265
|
+
ch = text2.charCodeAt(pos);
|
|
10266
|
+
switch (ch) {
|
|
10267
|
+
case 45 /* minus */:
|
|
10268
|
+
pos++;
|
|
10269
|
+
ch = text2.charCodeAt(pos);
|
|
10270
|
+
if (isClassContentExit(ch)) {
|
|
10271
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10272
|
+
return;
|
|
10273
|
+
}
|
|
10274
|
+
if (ch === 45 /* minus */) {
|
|
10275
|
+
pos++;
|
|
10276
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10277
|
+
start2 = pos - 2;
|
|
10278
|
+
oprand = text2.slice(start2, pos);
|
|
10279
|
+
continue;
|
|
10280
|
+
} else {
|
|
10281
|
+
if (!oprand) {
|
|
10282
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start2, pos - 1 - start2);
|
|
10283
|
+
}
|
|
10284
|
+
const secondStart = pos;
|
|
10285
|
+
const secondOprand = scanClassSetOprand();
|
|
10286
|
+
if (isCharacterComplement && mayContainStrings) {
|
|
10287
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, pos - secondStart);
|
|
10288
|
+
}
|
|
10289
|
+
expressionMayContainStrings || (expressionMayContainStrings = mayContainStrings);
|
|
10290
|
+
if (!secondOprand) {
|
|
10291
|
+
error(Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, pos - secondStart);
|
|
10292
|
+
break;
|
|
10293
|
+
}
|
|
10294
|
+
if (!oprand) {
|
|
10295
|
+
break;
|
|
10296
|
+
}
|
|
10297
|
+
const minCharacterValue = codePointAt(oprand, 0);
|
|
10298
|
+
const maxCharacterValue = codePointAt(secondOprand, 0);
|
|
10299
|
+
if (oprand.length === charSize(minCharacterValue) && secondOprand.length === charSize(maxCharacterValue) && minCharacterValue > maxCharacterValue) {
|
|
10300
|
+
error(Diagnostics.Range_out_of_order_in_character_class, start2, pos - start2);
|
|
10301
|
+
}
|
|
10302
|
+
}
|
|
10303
|
+
break;
|
|
10304
|
+
case 38 /* ampersand */:
|
|
10305
|
+
start2 = pos;
|
|
10306
|
+
pos++;
|
|
10307
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10308
|
+
pos++;
|
|
10309
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10310
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10311
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10312
|
+
pos++;
|
|
10313
|
+
}
|
|
10314
|
+
} else {
|
|
10315
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10316
|
+
}
|
|
10317
|
+
oprand = text2.slice(start2, pos);
|
|
10318
|
+
continue;
|
|
10319
|
+
}
|
|
10320
|
+
if (isClassContentExit(text2.charCodeAt(pos))) {
|
|
10321
|
+
break;
|
|
10322
|
+
}
|
|
10323
|
+
start2 = pos;
|
|
10324
|
+
switch (text2.slice(pos, pos + 2)) {
|
|
10325
|
+
case "--":
|
|
10326
|
+
case "&&":
|
|
10327
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos, 2);
|
|
10328
|
+
pos += 2;
|
|
10329
|
+
oprand = text2.slice(start2, pos);
|
|
10330
|
+
break;
|
|
10331
|
+
default:
|
|
10332
|
+
oprand = scanClassSetOprand();
|
|
10333
|
+
break;
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
10337
|
+
}
|
|
10338
|
+
function scanClassSetSubExpression(expressionType) {
|
|
10339
|
+
let expressionMayContainStrings = mayContainStrings;
|
|
10340
|
+
while (pos < end2) {
|
|
10341
|
+
let ch = text2.charCodeAt(pos);
|
|
10342
|
+
if (isClassContentExit(ch)) {
|
|
10343
|
+
break;
|
|
10344
|
+
}
|
|
10345
|
+
switch (ch) {
|
|
10346
|
+
case 45 /* minus */:
|
|
10347
|
+
pos++;
|
|
10348
|
+
if (text2.charCodeAt(pos) === 45 /* minus */) {
|
|
10349
|
+
pos++;
|
|
10350
|
+
if (expressionType !== 3 /* ClassSubtraction */) {
|
|
10351
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10352
|
+
}
|
|
10353
|
+
} else {
|
|
10354
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 1, 1);
|
|
10355
|
+
}
|
|
10356
|
+
break;
|
|
10357
|
+
case 38 /* ampersand */:
|
|
10358
|
+
pos++;
|
|
10359
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10360
|
+
pos++;
|
|
10361
|
+
if (expressionType !== 2 /* ClassIntersection */) {
|
|
10362
|
+
error(Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, pos - 2, 2);
|
|
10363
|
+
}
|
|
10364
|
+
if (text2.charCodeAt(pos) === 38 /* ampersand */) {
|
|
10365
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10366
|
+
pos++;
|
|
10367
|
+
}
|
|
10368
|
+
} else {
|
|
10369
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos - 1, 1, String.fromCharCode(ch));
|
|
10370
|
+
}
|
|
10371
|
+
break;
|
|
10372
|
+
default:
|
|
10373
|
+
switch (expressionType) {
|
|
10374
|
+
case 3 /* ClassSubtraction */:
|
|
10375
|
+
error(Diagnostics._0_expected, pos, 0, "--");
|
|
10376
|
+
break;
|
|
10377
|
+
case 2 /* ClassIntersection */:
|
|
10378
|
+
error(Diagnostics._0_expected, pos, 0, "&&");
|
|
10379
|
+
break;
|
|
10380
|
+
default:
|
|
10381
|
+
break;
|
|
10382
|
+
}
|
|
10383
|
+
break;
|
|
10384
|
+
}
|
|
10385
|
+
ch = text2.charCodeAt(pos);
|
|
10386
|
+
if (isClassContentExit(ch)) {
|
|
10387
|
+
error(Diagnostics.Expected_a_class_set_oprand);
|
|
10388
|
+
break;
|
|
10389
|
+
}
|
|
10390
|
+
scanClassSetOprand();
|
|
10391
|
+
expressionMayContainStrings && (expressionMayContainStrings = mayContainStrings);
|
|
10392
|
+
}
|
|
10393
|
+
mayContainStrings = expressionMayContainStrings;
|
|
10394
|
+
}
|
|
10395
|
+
function scanClassSetOprand() {
|
|
10396
|
+
mayContainStrings = false;
|
|
10397
|
+
switch (text2.charCodeAt(pos)) {
|
|
10398
|
+
case 91 /* openBracket */:
|
|
10399
|
+
pos++;
|
|
10400
|
+
scanClassSetExpression();
|
|
10401
|
+
scanExpectedChar(93 /* closeBracket */);
|
|
10402
|
+
return "";
|
|
10403
|
+
case 92 /* backslash */:
|
|
10404
|
+
pos++;
|
|
10405
|
+
if (scanCharacterClassEscape()) {
|
|
10406
|
+
return "";
|
|
10407
|
+
} else if (text2.charCodeAt(pos) === 113 /* q */) {
|
|
10408
|
+
pos++;
|
|
10409
|
+
if (text2.charCodeAt(pos) === 123 /* openBrace */) {
|
|
10410
|
+
pos++;
|
|
10411
|
+
scanClassStringDisjunctionContents();
|
|
10412
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
10413
|
+
return "";
|
|
10414
|
+
} else {
|
|
10415
|
+
error(Diagnostics.q_must_be_followed_by_string_alternatives_enclosed_in_braces, pos - 2, 2);
|
|
10416
|
+
return "q";
|
|
10417
|
+
}
|
|
10418
|
+
}
|
|
10419
|
+
pos--;
|
|
10420
|
+
default:
|
|
10421
|
+
return scanClassSetCharacter();
|
|
10422
|
+
}
|
|
10423
|
+
}
|
|
10424
|
+
function scanClassStringDisjunctionContents() {
|
|
10425
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 123 /* openBrace */);
|
|
10426
|
+
let characterCount = 0;
|
|
10427
|
+
while (pos < end2) {
|
|
10428
|
+
const ch = text2.charCodeAt(pos);
|
|
10429
|
+
switch (ch) {
|
|
10430
|
+
case 125 /* closeBrace */:
|
|
10431
|
+
if (characterCount !== 1) {
|
|
10432
|
+
mayContainStrings = true;
|
|
10433
|
+
}
|
|
10434
|
+
return;
|
|
10435
|
+
case 124 /* bar */:
|
|
10436
|
+
if (characterCount !== 1) {
|
|
10437
|
+
mayContainStrings = true;
|
|
10438
|
+
}
|
|
10439
|
+
pos++;
|
|
10440
|
+
start = pos;
|
|
10441
|
+
characterCount = 0;
|
|
10442
|
+
break;
|
|
10443
|
+
default:
|
|
10444
|
+
scanClassSetCharacter();
|
|
10445
|
+
characterCount++;
|
|
10446
|
+
break;
|
|
10447
|
+
}
|
|
10448
|
+
}
|
|
10449
|
+
}
|
|
10450
|
+
function scanClassSetCharacter() {
|
|
10451
|
+
const ch = text2.charCodeAt(pos);
|
|
10452
|
+
if (ch === 92 /* backslash */) {
|
|
10453
|
+
pos++;
|
|
10454
|
+
const ch2 = text2.charCodeAt(pos);
|
|
10455
|
+
switch (ch2) {
|
|
10456
|
+
case 98 /* b */:
|
|
10457
|
+
pos++;
|
|
10458
|
+
return "\b";
|
|
10459
|
+
case 38 /* ampersand */:
|
|
10460
|
+
case 45 /* minus */:
|
|
10461
|
+
case 33 /* exclamation */:
|
|
10462
|
+
case 35 /* hash */:
|
|
10463
|
+
case 37 /* percent */:
|
|
10464
|
+
case 44 /* comma */:
|
|
10465
|
+
case 58 /* colon */:
|
|
10466
|
+
case 59 /* semicolon */:
|
|
10467
|
+
case 60 /* lessThan */:
|
|
10468
|
+
case 61 /* equals */:
|
|
10469
|
+
case 62 /* greaterThan */:
|
|
10470
|
+
case 64 /* at */:
|
|
10471
|
+
case 96 /* backtick */:
|
|
10472
|
+
case 126 /* tilde */:
|
|
10473
|
+
pos++;
|
|
10474
|
+
return String.fromCharCode(ch2);
|
|
10475
|
+
default:
|
|
10476
|
+
return scanCharacterEscape();
|
|
10477
|
+
}
|
|
10478
|
+
} else if (ch === text2.charCodeAt(pos + 1)) {
|
|
10479
|
+
switch (ch) {
|
|
10480
|
+
case 38 /* ampersand */:
|
|
10481
|
+
case 33 /* exclamation */:
|
|
10482
|
+
case 35 /* hash */:
|
|
10483
|
+
case 37 /* percent */:
|
|
10484
|
+
case 42 /* asterisk */:
|
|
10485
|
+
case 43 /* plus */:
|
|
10486
|
+
case 44 /* comma */:
|
|
10487
|
+
case 46 /* dot */:
|
|
10488
|
+
case 58 /* colon */:
|
|
10489
|
+
case 59 /* semicolon */:
|
|
10490
|
+
case 60 /* lessThan */:
|
|
10491
|
+
case 61 /* equals */:
|
|
10492
|
+
case 62 /* greaterThan */:
|
|
10493
|
+
case 63 /* question */:
|
|
10494
|
+
case 64 /* at */:
|
|
10495
|
+
case 96 /* backtick */:
|
|
10496
|
+
case 126 /* tilde */:
|
|
10497
|
+
error(Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, pos, 2);
|
|
10498
|
+
pos += 2;
|
|
10499
|
+
return text2.substring(pos - 2, pos);
|
|
10500
|
+
}
|
|
10501
|
+
}
|
|
10502
|
+
switch (ch) {
|
|
10503
|
+
case 47 /* slash */:
|
|
10504
|
+
case 40 /* openParen */:
|
|
10505
|
+
case 41 /* closeParen */:
|
|
10506
|
+
case 91 /* openBracket */:
|
|
10507
|
+
case 93 /* closeBracket */:
|
|
10508
|
+
case 123 /* openBrace */:
|
|
10509
|
+
case 125 /* closeBrace */:
|
|
10510
|
+
case 45 /* minus */:
|
|
10511
|
+
case 124 /* bar */:
|
|
10512
|
+
error(Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, pos, 1, String.fromCharCode(ch));
|
|
10513
|
+
pos++;
|
|
10514
|
+
return String.fromCharCode(ch);
|
|
10515
|
+
}
|
|
10516
|
+
return scanSourceCharacter();
|
|
10517
|
+
}
|
|
10518
|
+
function scanClassAtom() {
|
|
10519
|
+
if (text2.charCodeAt(pos) === 92 /* backslash */) {
|
|
10520
|
+
pos++;
|
|
10521
|
+
const ch = text2.charCodeAt(pos);
|
|
10522
|
+
switch (ch) {
|
|
10523
|
+
case 98 /* b */:
|
|
10524
|
+
pos++;
|
|
10525
|
+
return "\b";
|
|
10526
|
+
case 45 /* minus */:
|
|
10527
|
+
pos++;
|
|
10528
|
+
return String.fromCharCode(ch);
|
|
10529
|
+
default:
|
|
10530
|
+
if (scanCharacterClassEscape()) {
|
|
10531
|
+
return "";
|
|
10532
|
+
}
|
|
10533
|
+
return scanCharacterEscape();
|
|
10534
|
+
}
|
|
10535
|
+
} else {
|
|
10536
|
+
return scanSourceCharacter();
|
|
10537
|
+
}
|
|
10538
|
+
}
|
|
10539
|
+
function scanCharacterClassEscape() {
|
|
10540
|
+
Debug.assertEqual(text2.charCodeAt(pos - 1), 92 /* backslash */);
|
|
10541
|
+
let isCharacterComplement = false;
|
|
10542
|
+
const start2 = pos - 1;
|
|
10543
|
+
const ch = text2.charCodeAt(pos);
|
|
10544
|
+
switch (ch) {
|
|
10545
|
+
case 100 /* d */:
|
|
10546
|
+
case 68 /* D */:
|
|
10547
|
+
case 115 /* s */:
|
|
10548
|
+
case 83 /* S */:
|
|
10549
|
+
case 119 /* w */:
|
|
10550
|
+
case 87 /* W */:
|
|
10551
|
+
pos++;
|
|
10552
|
+
return true;
|
|
10553
|
+
case 80 /* P */:
|
|
10554
|
+
isCharacterComplement = true;
|
|
10555
|
+
case 112 /* p */:
|
|
10556
|
+
pos++;
|
|
10557
|
+
if (text2.charCodeAt(pos) === 123 /* openBrace */) {
|
|
10558
|
+
pos++;
|
|
10559
|
+
const propertyNameOrValueStart = pos;
|
|
10560
|
+
const propertyNameOrValue = scanWordCharacters();
|
|
10561
|
+
if (text2.charCodeAt(pos) === 61 /* equals */) {
|
|
10562
|
+
const propertyName = nonBinaryUnicodeProperties.get(propertyNameOrValue);
|
|
10563
|
+
if (pos === propertyNameOrValueStart) {
|
|
10564
|
+
error(Diagnostics.Expected_a_Unicode_property_name);
|
|
10565
|
+
} else if (propertyName === void 0) {
|
|
10566
|
+
error(Diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10567
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, nonBinaryUnicodeProperties.keys(), identity);
|
|
10568
|
+
if (suggestion) {
|
|
10569
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10570
|
+
}
|
|
10571
|
+
}
|
|
10572
|
+
pos++;
|
|
10573
|
+
const propertyValueStart = pos;
|
|
10574
|
+
const propertyValue = scanWordCharacters();
|
|
10575
|
+
if (pos === propertyValueStart) {
|
|
10576
|
+
error(Diagnostics.Expected_a_Unicode_property_value);
|
|
10577
|
+
} else if (propertyName !== void 0 && !valuesOfNonBinaryUnicodeProperties[propertyName].has(propertyValue)) {
|
|
10578
|
+
error(Diagnostics.Unknown_Unicode_property_value, propertyValueStart, pos - propertyValueStart);
|
|
10579
|
+
const suggestion = getSpellingSuggestion(propertyValue, valuesOfNonBinaryUnicodeProperties[propertyName], identity);
|
|
10580
|
+
if (suggestion) {
|
|
10581
|
+
error(Diagnostics.Did_you_mean_0, propertyValueStart, pos - propertyValueStart, suggestion);
|
|
10582
|
+
}
|
|
10583
|
+
}
|
|
10584
|
+
} else {
|
|
10585
|
+
if (pos === propertyNameOrValueStart) {
|
|
10586
|
+
error(Diagnostics.Expected_a_Unicode_property_name_or_value);
|
|
10587
|
+
} else if (binaryUnicodePropertiesOfStrings.has(propertyNameOrValue)) {
|
|
10588
|
+
if (!unicodeSetsMode) {
|
|
10589
|
+
error(Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10590
|
+
} else if (isCharacterComplement) {
|
|
10591
|
+
error(Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10592
|
+
} else {
|
|
10593
|
+
mayContainStrings = true;
|
|
10594
|
+
}
|
|
10595
|
+
} else if (!valuesOfNonBinaryUnicodeProperties.General_Category.has(propertyNameOrValue) && !binaryUnicodeProperties.has(propertyNameOrValue)) {
|
|
10596
|
+
error(Diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, pos - propertyNameOrValueStart);
|
|
10597
|
+
const suggestion = getSpellingSuggestion(propertyNameOrValue, [...valuesOfNonBinaryUnicodeProperties.General_Category, ...binaryUnicodeProperties, ...binaryUnicodePropertiesOfStrings], identity);
|
|
10598
|
+
if (suggestion) {
|
|
10599
|
+
error(Diagnostics.Did_you_mean_0, propertyNameOrValueStart, pos - propertyNameOrValueStart, suggestion);
|
|
10600
|
+
}
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10603
|
+
scanExpectedChar(125 /* closeBrace */);
|
|
10604
|
+
if (!unicodeMode) {
|
|
10605
|
+
error(Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start2, pos - start2);
|
|
10606
|
+
}
|
|
10607
|
+
} else if (unicodeMode) {
|
|
10608
|
+
error(Diagnostics._0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, pos - 2, 2, String.fromCharCode(ch));
|
|
10609
|
+
}
|
|
10610
|
+
return true;
|
|
10611
|
+
}
|
|
10612
|
+
return false;
|
|
10613
|
+
}
|
|
10614
|
+
function scanWordCharacters() {
|
|
10615
|
+
let value = "";
|
|
10616
|
+
while (pos < end2) {
|
|
10617
|
+
const ch = text2.charCodeAt(pos);
|
|
10618
|
+
if (!isWordCharacter(ch)) {
|
|
10619
|
+
break;
|
|
10620
|
+
}
|
|
10621
|
+
value += String.fromCharCode(ch);
|
|
10622
|
+
pos++;
|
|
10623
|
+
}
|
|
10624
|
+
return value;
|
|
10625
|
+
}
|
|
10626
|
+
function scanSourceCharacter() {
|
|
10627
|
+
const size = unicodeMode ? charSize(codePointAt(text2, pos)) : 1;
|
|
10628
|
+
pos += size;
|
|
10629
|
+
return text2.substring(pos - size, pos);
|
|
10630
|
+
}
|
|
10631
|
+
function scanExpectedChar(ch) {
|
|
10632
|
+
if (text2.charCodeAt(pos) === ch) {
|
|
10633
|
+
pos++;
|
|
10634
|
+
} else {
|
|
10635
|
+
error(Diagnostics._0_expected, pos, 0, String.fromCharCode(ch));
|
|
10636
|
+
}
|
|
10637
|
+
}
|
|
10638
|
+
scanDisjunction(
|
|
10639
|
+
/*isInGroup*/
|
|
10640
|
+
false
|
|
10641
|
+
);
|
|
10642
|
+
forEach(groupNameReferences, (reference) => {
|
|
10643
|
+
if (!groupSpecifiers.has(reference.name)) {
|
|
10644
|
+
error(Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end - reference.pos, reference.name);
|
|
10645
|
+
}
|
|
10646
|
+
});
|
|
10647
|
+
forEach(decimalEscapes, (escape) => {
|
|
10648
|
+
if (escape.value > numberOfCapturingGroups) {
|
|
10649
|
+
if (numberOfCapturingGroups) {
|
|
10650
|
+
error(Diagnostics.A_decimal_escape_must_refer_to_an_existent_capturing_group_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end - escape.pos, numberOfCapturingGroups);
|
|
10651
|
+
} else {
|
|
10652
|
+
error(Diagnostics.Decimal_escapes_are_invalid_when_there_are_no_capturing_groups_in_a_regular_expression, escape.pos, escape.end - escape.pos);
|
|
10653
|
+
}
|
|
10654
|
+
}
|
|
10655
|
+
});
|
|
10656
|
+
}
|
|
9730
10657
|
}
|
|
9731
10658
|
function appendIfCommentDirective(commentDirectives2, text2, commentDirectiveRegEx, lineStart) {
|
|
9732
10659
|
const type = getDirectiveFromComment(text2.trimStart(), commentDirectiveRegEx);
|
|
@@ -9953,9 +10880,10 @@ function createScanner(languageVersion, skipTrivia2, languageVariant = 0 /* Stan
|
|
|
9953
10880
|
pos--;
|
|
9954
10881
|
const extendedCookedChar = peekExtendedUnicodeEscape();
|
|
9955
10882
|
if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
10883
|
+
tokenValue = scanExtendedUnicodeEscape(
|
|
10884
|
+
/*shouldEmitInvalidEscapeError*/
|
|
10885
|
+
true
|
|
10886
|
+
) + scanIdentifierParts();
|
|
9959
10887
|
return token = getIdentifierToken();
|
|
9960
10888
|
}
|
|
9961
10889
|
const cookedChar = peekUnicodeEscape();
|
|
@@ -10095,6 +11023,22 @@ var utf16EncodeAsStringWorker = String.fromCodePoint ? (codePoint) => String.fro
|
|
|
10095
11023
|
function utf16EncodeAsString(codePoint) {
|
|
10096
11024
|
return utf16EncodeAsStringWorker(codePoint);
|
|
10097
11025
|
}
|
|
11026
|
+
var nonBinaryUnicodeProperties = new Map(Object.entries({
|
|
11027
|
+
General_Category: "General_Category",
|
|
11028
|
+
gc: "General_Category",
|
|
11029
|
+
Script: "Script",
|
|
11030
|
+
sc: "Script",
|
|
11031
|
+
Script_Extensions: "Script_Extensions",
|
|
11032
|
+
scx: "Script_Extensions"
|
|
11033
|
+
}));
|
|
11034
|
+
var binaryUnicodeProperties = /* @__PURE__ */ new Set(["ASCII", "ASCII_Hex_Digit", "AHex", "Alphabetic", "Alpha", "Any", "Assigned", "Bidi_Control", "Bidi_C", "Bidi_Mirrored", "Bidi_M", "Case_Ignorable", "CI", "Cased", "Changes_When_Casefolded", "CWCF", "Changes_When_Casemapped", "CWCM", "Changes_When_Lowercased", "CWL", "Changes_When_NFKC_Casefolded", "CWKCF", "Changes_When_Titlecased", "CWT", "Changes_When_Uppercased", "CWU", "Dash", "Default_Ignorable_Code_Point", "DI", "Deprecated", "Dep", "Diacritic", "Dia", "Emoji", "Emoji_Component", "EComp", "Emoji_Modifier", "EMod", "Emoji_Modifier_Base", "EBase", "Emoji_Presentation", "EPres", "Extended_Pictographic", "ExtPict", "Extender", "Ext", "Grapheme_Base", "Gr_Base", "Grapheme_Extend", "Gr_Ext", "Hex_Digit", "Hex", "IDS_Binary_Operator", "IDSB", "IDS_Trinary_Operator", "IDST", "ID_Continue", "IDC", "ID_Start", "IDS", "Ideographic", "Ideo", "Join_Control", "Join_C", "Logical_Order_Exception", "LOE", "Lowercase", "Lower", "Math", "Noncharacter_Code_Point", "NChar", "Pattern_Syntax", "Pat_Syn", "Pattern_White_Space", "Pat_WS", "Quotation_Mark", "QMark", "Radical", "Regional_Indicator", "RI", "Sentence_Terminal", "STerm", "Soft_Dotted", "SD", "Terminal_Punctuation", "Term", "Unified_Ideograph", "UIdeo", "Uppercase", "Upper", "Variation_Selector", "VS", "White_Space", "space", "XID_Continue", "XIDC", "XID_Start", "XIDS"]);
|
|
11035
|
+
var binaryUnicodePropertiesOfStrings = /* @__PURE__ */ new Set(["Basic_Emoji", "Emoji_Keycap_Sequence", "RGI_Emoji_Modifier_Sequence", "RGI_Emoji_Flag_Sequence", "RGI_Emoji_Tag_Sequence", "RGI_Emoji_ZWJ_Sequence", "RGI_Emoji"]);
|
|
11036
|
+
var valuesOfNonBinaryUnicodeProperties = {
|
|
11037
|
+
General_Category: /* @__PURE__ */ new Set(["C", "Other", "Cc", "Control", "cntrl", "Cf", "Format", "Cn", "Unassigned", "Co", "Private_Use", "Cs", "Surrogate", "L", "Letter", "LC", "Cased_Letter", "Ll", "Lowercase_Letter", "Lm", "Modifier_Letter", "Lo", "Other_Letter", "Lt", "Titlecase_Letter", "Lu", "Uppercase_Letter", "M", "Mark", "Combining_Mark", "Mc", "Spacing_Mark", "Me", "Enclosing_Mark", "Mn", "Nonspacing_Mark", "N", "Number", "Nd", "Decimal_Number", "digit", "Nl", "Letter_Number", "No", "Other_Number", "P", "Punctuation", "punct", "Pc", "Connector_Punctuation", "Pd", "Dash_Punctuation", "Pe", "Close_Punctuation", "Pf", "Final_Punctuation", "Pi", "Initial_Punctuation", "Po", "Other_Punctuation", "Ps", "Open_Punctuation", "S", "Symbol", "Sc", "Currency_Symbol", "Sk", "Modifier_Symbol", "Sm", "Math_Symbol", "So", "Other_Symbol", "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator"]),
|
|
11038
|
+
Script: /* @__PURE__ */ new Set(["Adlm", "Adlam", "Aghb", "Caucasian_Albanian", "Ahom", "Ahom", "Arab", "Arabic", "Armi", "Imperial_Aramaic", "Armn", "Armenian", "Avst", "Avestan", "Bali", "Balinese", "Bamu", "Bamum", "Bass", "Bassa_Vah", "Batk", "Batak", "Beng", "Bengali", "Bhks", "Bhaiksuki", "Bopo", "Bopomofo", "Brah", "Brahmi", "Brai", "Braille", "Bugi", "Buginese", "Buhd", "Buhid", "Cakm", "Chakma", "Cans", "Canadian_Aboriginal", "Cari", "Carian", "Cham", "Cham", "Cher", "Cherokee", "Chrs", "Chorasmian", "Copt", "Coptic", "Qaac", "Cpmn", "Cypro_Minoan", "Cprt", "Cypriot", "Cyrl", "Cyrillic", "Deva", "Devanagari", "Diak", "Dives_Akuru", "Dogr", "Dogra", "Dsrt", "Deseret", "Dupl", "Duployan", "Egyp", "Egyptian_Hieroglyphs", "Elba", "Elbasan", "Elym", "Elymaic", "Ethi", "Ethiopic", "Geor", "Georgian", "Glag", "Glagolitic", "Gong", "Gunjala_Gondi", "Gonm", "Masaram_Gondi", "Goth", "Gothic", "Gran", "Grantha", "Grek", "Greek", "Gujr", "Gujarati", "Guru", "Gurmukhi", "Hang", "Hangul", "Hani", "Han", "Hano", "Hanunoo", "Hatr", "Hatran", "Hebr", "Hebrew", "Hira", "Hiragana", "Hluw", "Anatolian_Hieroglyphs", "Hmng", "Pahawh_Hmong", "Hmnp", "Nyiakeng_Puachue_Hmong", "Hrkt", "Katakana_Or_Hiragana", "Hung", "Old_Hungarian", "Ital", "Old_Italic", "Java", "Javanese", "Kali", "Kayah_Li", "Kana", "Katakana", "Kawi", "Kawi", "Khar", "Kharoshthi", "Khmr", "Khmer", "Khoj", "Khojki", "Kits", "Khitan_Small_Script", "Knda", "Kannada", "Kthi", "Kaithi", "Lana", "Tai_Tham", "Laoo", "Lao", "Latn", "Latin", "Lepc", "Lepcha", "Limb", "Limbu", "Lina", "Linear_A", "Linb", "Linear_B", "Lisu", "Lisu", "Lyci", "Lycian", "Lydi", "Lydian", "Mahj", "Mahajani", "Maka", "Makasar", "Mand", "Mandaic", "Mani", "Manichaean", "Marc", "Marchen", "Medf", "Medefaidrin", "Mend", "Mende_Kikakui", "Merc", "Meroitic_Cursive", "Mero", "Meroitic_Hieroglyphs", "Mlym", "Malayalam", "Modi", "Modi", "Mong", "Mongolian", "Mroo", "Mro", "Mtei", "Meetei_Mayek", "Mult", "Multani", "Mymr", "Myanmar", "Nagm", "Nag_Mundari", "Nand", "Nandinagari", "Narb", "Old_North_Arabian", "Nbat", "Nabataean", "Newa", "Newa", "Nkoo", "Nko", "Nshu", "Nushu", "Ogam", "Ogham", "Olck", "Ol_Chiki", "Orkh", "Old_Turkic", "Orya", "Oriya", "Osge", "Osage", "Osma", "Osmanya", "Ougr", "Old_Uyghur", "Palm", "Palmyrene", "Pauc", "Pau_Cin_Hau", "Perm", "Old_Permic", "Phag", "Phags_Pa", "Phli", "Inscriptional_Pahlavi", "Phlp", "Psalter_Pahlavi", "Phnx", "Phoenician", "Plrd", "Miao", "Prti", "Inscriptional_Parthian", "Rjng", "Rejang", "Rohg", "Hanifi_Rohingya", "Runr", "Runic", "Samr", "Samaritan", "Sarb", "Old_South_Arabian", "Saur", "Saurashtra", "Sgnw", "SignWriting", "Shaw", "Shavian", "Shrd", "Sharada", "Sidd", "Siddham", "Sind", "Khudawadi", "Sinh", "Sinhala", "Sogd", "Sogdian", "Sogo", "Old_Sogdian", "Sora", "Sora_Sompeng", "Soyo", "Soyombo", "Sund", "Sundanese", "Sylo", "Syloti_Nagri", "Syrc", "Syriac", "Tagb", "Tagbanwa", "Takr", "Takri", "Tale", "Tai_Le", "Talu", "New_Tai_Lue", "Taml", "Tamil", "Tang", "Tangut", "Tavt", "Tai_Viet", "Telu", "Telugu", "Tfng", "Tifinagh", "Tglg", "Tagalog", "Thaa", "Thaana", "Thai", "Thai", "Tibt", "Tibetan", "Tirh", "Tirhuta", "Tnsa", "Tangsa", "Toto", "Toto", "Ugar", "Ugaritic", "Vaii", "Vai", "Vith", "Vithkuqi", "Wara", "Warang_Citi", "Wcho", "Wancho", "Xpeo", "Old_Persian", "Xsux", "Cuneiform", "Yezi", "Yezidi", "Yiii", "Yi", "Zanb", "Zanabazar_Square", "Zinh", "Inherited", "Qaai", "Zyyy", "Common", "Zzzz", "Unknown"]),
|
|
11039
|
+
Script_Extensions: /* @__PURE__ */ new Set()
|
|
11040
|
+
// Currently empty
|
|
11041
|
+
};
|
|
10098
11042
|
|
|
10099
11043
|
// src/compiler/utilitiesPublic.ts
|
|
10100
11044
|
function isExternalModuleNameRelative(moduleName) {
|
|
@@ -12721,6 +13665,10 @@ function isVarUsing(node) {
|
|
|
12721
13665
|
function isVarConst(node) {
|
|
12722
13666
|
return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 2 /* Const */;
|
|
12723
13667
|
}
|
|
13668
|
+
function isVarConstLike(node) {
|
|
13669
|
+
const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
|
|
13670
|
+
return blockScopeKind === 2 /* Const */ || blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */;
|
|
13671
|
+
}
|
|
12724
13672
|
function isLet(node) {
|
|
12725
13673
|
return (getCombinedNodeFlags(node) & 7 /* BlockScoped */) === 1 /* Let */;
|
|
12726
13674
|
}
|
|
@@ -16730,6 +17678,9 @@ function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)
|
|
|
16730
17678
|
function getStrictOptionValue(compilerOptions, flag) {
|
|
16731
17679
|
return compilerOptions[flag] === void 0 ? !!compilerOptions.strict : !!compilerOptions[flag];
|
|
16732
17680
|
}
|
|
17681
|
+
function getNameOfScriptTarget(scriptTarget) {
|
|
17682
|
+
return forEachEntry(targetOptionDeclaration.type, (value, key) => value === scriptTarget ? key : void 0);
|
|
17683
|
+
}
|
|
16733
17684
|
function getEmitStandardClassFields(compilerOptions) {
|
|
16734
17685
|
return compilerOptions.useDefineForClassFields !== false && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */;
|
|
16735
17686
|
}
|
|
@@ -17786,26 +18737,28 @@ function replaceFirstStar(s, replacement) {
|
|
|
17786
18737
|
function getNameFromImportAttribute(node) {
|
|
17787
18738
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17788
18739
|
}
|
|
17789
|
-
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false) {
|
|
17790
|
-
return { value, isSyntacticallyString, resolvedOtherFiles };
|
|
18740
|
+
function evaluatorResult(value, isSyntacticallyString = false, resolvedOtherFiles = false, hasExternalReferences = false) {
|
|
18741
|
+
return { value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences };
|
|
17791
18742
|
}
|
|
17792
18743
|
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
17793
18744
|
function evaluate(expr, location) {
|
|
17794
18745
|
let isSyntacticallyString = false;
|
|
17795
18746
|
let resolvedOtherFiles = false;
|
|
18747
|
+
let hasExternalReferences = false;
|
|
17796
18748
|
expr = skipParentheses(expr);
|
|
17797
18749
|
switch (expr.kind) {
|
|
17798
18750
|
case 224 /* PrefixUnaryExpression */:
|
|
17799
18751
|
const result = evaluate(expr.operand, location);
|
|
17800
18752
|
resolvedOtherFiles = result.resolvedOtherFiles;
|
|
18753
|
+
hasExternalReferences = result.hasExternalReferences;
|
|
17801
18754
|
if (typeof result.value === "number") {
|
|
17802
18755
|
switch (expr.operator) {
|
|
17803
18756
|
case 40 /* PlusToken */:
|
|
17804
|
-
return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18757
|
+
return evaluatorResult(result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17805
18758
|
case 41 /* MinusToken */:
|
|
17806
|
-
return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18759
|
+
return evaluatorResult(-result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17807
18760
|
case 55 /* TildeToken */:
|
|
17808
|
-
return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18761
|
+
return evaluatorResult(~result.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17809
18762
|
}
|
|
17810
18763
|
}
|
|
17811
18764
|
break;
|
|
@@ -17814,38 +18767,40 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17814
18767
|
const right = evaluate(expr.right, location);
|
|
17815
18768
|
isSyntacticallyString = (left.isSyntacticallyString || right.isSyntacticallyString) && expr.operatorToken.kind === 40 /* PlusToken */;
|
|
17816
18769
|
resolvedOtherFiles = left.resolvedOtherFiles || right.resolvedOtherFiles;
|
|
18770
|
+
hasExternalReferences = left.hasExternalReferences || right.hasExternalReferences;
|
|
17817
18771
|
if (typeof left.value === "number" && typeof right.value === "number") {
|
|
17818
18772
|
switch (expr.operatorToken.kind) {
|
|
17819
18773
|
case 52 /* BarToken */:
|
|
17820
|
-
return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18774
|
+
return evaluatorResult(left.value | right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17821
18775
|
case 51 /* AmpersandToken */:
|
|
17822
|
-
return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18776
|
+
return evaluatorResult(left.value & right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17823
18777
|
case 49 /* GreaterThanGreaterThanToken */:
|
|
17824
|
-
return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18778
|
+
return evaluatorResult(left.value >> right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17825
18779
|
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
17826
|
-
return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18780
|
+
return evaluatorResult(left.value >>> right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17827
18781
|
case 48 /* LessThanLessThanToken */:
|
|
17828
|
-
return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18782
|
+
return evaluatorResult(left.value << right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17829
18783
|
case 53 /* CaretToken */:
|
|
17830
|
-
return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18784
|
+
return evaluatorResult(left.value ^ right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17831
18785
|
case 42 /* AsteriskToken */:
|
|
17832
|
-
return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18786
|
+
return evaluatorResult(left.value * right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17833
18787
|
case 44 /* SlashToken */:
|
|
17834
|
-
return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18788
|
+
return evaluatorResult(left.value / right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17835
18789
|
case 40 /* PlusToken */:
|
|
17836
|
-
return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18790
|
+
return evaluatorResult(left.value + right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17837
18791
|
case 41 /* MinusToken */:
|
|
17838
|
-
return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18792
|
+
return evaluatorResult(left.value - right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17839
18793
|
case 45 /* PercentToken */:
|
|
17840
|
-
return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18794
|
+
return evaluatorResult(left.value % right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17841
18795
|
case 43 /* AsteriskAsteriskToken */:
|
|
17842
|
-
return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles);
|
|
18796
|
+
return evaluatorResult(left.value ** right.value, isSyntacticallyString, resolvedOtherFiles, hasExternalReferences);
|
|
17843
18797
|
}
|
|
17844
18798
|
} else if ((typeof left.value === "string" || typeof left.value === "number") && (typeof right.value === "string" || typeof right.value === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17845
18799
|
return evaluatorResult(
|
|
17846
18800
|
"" + left.value + right.value,
|
|
17847
18801
|
isSyntacticallyString,
|
|
17848
|
-
resolvedOtherFiles
|
|
18802
|
+
resolvedOtherFiles,
|
|
18803
|
+
hasExternalReferences
|
|
17849
18804
|
);
|
|
17850
18805
|
}
|
|
17851
18806
|
break;
|
|
@@ -17875,12 +18830,14 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17875
18830
|
/*value*/
|
|
17876
18831
|
void 0,
|
|
17877
18832
|
isSyntacticallyString,
|
|
17878
|
-
resolvedOtherFiles
|
|
18833
|
+
resolvedOtherFiles,
|
|
18834
|
+
hasExternalReferences
|
|
17879
18835
|
);
|
|
17880
18836
|
}
|
|
17881
18837
|
function evaluateTemplateExpression(expr, location) {
|
|
17882
18838
|
let result = expr.head.text;
|
|
17883
18839
|
let resolvedOtherFiles = false;
|
|
18840
|
+
let hasExternalReferences = false;
|
|
17884
18841
|
for (const span of expr.templateSpans) {
|
|
17885
18842
|
const spanResult = evaluate(span.expression, location);
|
|
17886
18843
|
if (spanResult.value === void 0) {
|
|
@@ -17894,12 +18851,14 @@ function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameEx
|
|
|
17894
18851
|
result += spanResult.value;
|
|
17895
18852
|
result += span.literal.text;
|
|
17896
18853
|
resolvedOtherFiles || (resolvedOtherFiles = spanResult.resolvedOtherFiles);
|
|
18854
|
+
hasExternalReferences || (hasExternalReferences = spanResult.hasExternalReferences);
|
|
17897
18855
|
}
|
|
17898
18856
|
return evaluatorResult(
|
|
17899
18857
|
result,
|
|
17900
18858
|
/*isSyntacticallyString*/
|
|
17901
18859
|
true,
|
|
17902
|
-
resolvedOtherFiles
|
|
18860
|
+
resolvedOtherFiles,
|
|
18861
|
+
hasExternalReferences
|
|
17903
18862
|
);
|
|
17904
18863
|
}
|
|
17905
18864
|
return evaluate;
|
|
@@ -18278,6 +19237,55 @@ function createNameResolver({
|
|
|
18278
19237
|
return false;
|
|
18279
19238
|
}
|
|
18280
19239
|
}
|
|
19240
|
+
function isPrimitiveLiteralValue(node, includeBigInt = true) {
|
|
19241
|
+
Debug.type(node);
|
|
19242
|
+
switch (node.kind) {
|
|
19243
|
+
case 112 /* TrueKeyword */:
|
|
19244
|
+
case 97 /* FalseKeyword */:
|
|
19245
|
+
case 9 /* NumericLiteral */:
|
|
19246
|
+
case 11 /* StringLiteral */:
|
|
19247
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
19248
|
+
return true;
|
|
19249
|
+
case 10 /* BigIntLiteral */:
|
|
19250
|
+
return includeBigInt;
|
|
19251
|
+
case 224 /* PrefixUnaryExpression */:
|
|
19252
|
+
if (node.operator === 41 /* MinusToken */) {
|
|
19253
|
+
return isNumericLiteral(node.operand) || includeBigInt && isBigIntLiteral(node.operand);
|
|
19254
|
+
}
|
|
19255
|
+
if (node.operator === 40 /* PlusToken */) {
|
|
19256
|
+
return isNumericLiteral(node.operand);
|
|
19257
|
+
}
|
|
19258
|
+
return false;
|
|
19259
|
+
default:
|
|
19260
|
+
assertType(node);
|
|
19261
|
+
return false;
|
|
19262
|
+
}
|
|
19263
|
+
}
|
|
19264
|
+
function unwrapParenthesizedExpression(o) {
|
|
19265
|
+
while (o.kind === 217 /* ParenthesizedExpression */) {
|
|
19266
|
+
o = o.expression;
|
|
19267
|
+
}
|
|
19268
|
+
return o;
|
|
19269
|
+
}
|
|
19270
|
+
function hasInferredType(node) {
|
|
19271
|
+
Debug.type(node);
|
|
19272
|
+
switch (node.kind) {
|
|
19273
|
+
case 169 /* Parameter */:
|
|
19274
|
+
case 171 /* PropertySignature */:
|
|
19275
|
+
case 172 /* PropertyDeclaration */:
|
|
19276
|
+
case 208 /* BindingElement */:
|
|
19277
|
+
case 211 /* PropertyAccessExpression */:
|
|
19278
|
+
case 212 /* ElementAccessExpression */:
|
|
19279
|
+
case 226 /* BinaryExpression */:
|
|
19280
|
+
case 260 /* VariableDeclaration */:
|
|
19281
|
+
case 277 /* ExportAssignment */:
|
|
19282
|
+
case 303 /* PropertyAssignment */:
|
|
19283
|
+
return true;
|
|
19284
|
+
default:
|
|
19285
|
+
assertType(node);
|
|
19286
|
+
return false;
|
|
19287
|
+
}
|
|
19288
|
+
}
|
|
18281
19289
|
|
|
18282
19290
|
// src/compiler/factory/baseNodeFactory.ts
|
|
18283
19291
|
function createBaseNodeFactory() {
|
|
@@ -24843,6 +25851,9 @@ function isNewExpression(node) {
|
|
|
24843
25851
|
function isTaggedTemplateExpression(node) {
|
|
24844
25852
|
return node.kind === 215 /* TaggedTemplateExpression */;
|
|
24845
25853
|
}
|
|
25854
|
+
function isTypeAssertionExpression(node) {
|
|
25855
|
+
return node.kind === 216 /* TypeAssertionExpression */;
|
|
25856
|
+
}
|
|
24846
25857
|
function isParenthesizedExpression(node) {
|
|
24847
25858
|
return node.kind === 217 /* ParenthesizedExpression */;
|
|
24848
25859
|
}
|
|
@@ -24885,6 +25896,9 @@ function isOmittedExpression(node) {
|
|
|
24885
25896
|
function isExpressionWithTypeArguments(node) {
|
|
24886
25897
|
return node.kind === 233 /* ExpressionWithTypeArguments */;
|
|
24887
25898
|
}
|
|
25899
|
+
function isAsExpression(node) {
|
|
25900
|
+
return node.kind === 234 /* AsExpression */;
|
|
25901
|
+
}
|
|
24888
25902
|
function isSatisfiesExpression(node) {
|
|
24889
25903
|
return node.kind === 238 /* SatisfiesExpression */;
|
|
24890
25904
|
}
|
|
@@ -27495,7 +28509,10 @@ var Parser;
|
|
|
27495
28509
|
function parseErrorAtPosition(start, length2, message, ...args) {
|
|
27496
28510
|
const lastError = lastOrUndefined(parseDiagnostics);
|
|
27497
28511
|
let result;
|
|
27498
|
-
if (
|
|
28512
|
+
if (message.category === 3 /* Message */ && lastError && start === lastError.start && length2 === lastError.length) {
|
|
28513
|
+
result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
|
|
28514
|
+
addRelatedInfo(lastError, result);
|
|
28515
|
+
} else if (!lastError || start !== lastError.start) {
|
|
27499
28516
|
result = createDetachedDiagnostic(fileName, sourceText, start, length2, message, ...args);
|
|
27500
28517
|
parseDiagnostics.push(result);
|
|
27501
28518
|
}
|
|
@@ -27651,7 +28668,7 @@ var Parser;
|
|
|
27651
28668
|
parseErrorForInvalidName(Diagnostics.Type_alias_name_cannot_be_0, Diagnostics.Type_alias_must_be_given_a_name, 64 /* EqualsToken */);
|
|
27652
28669
|
return;
|
|
27653
28670
|
}
|
|
27654
|
-
const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions,
|
|
28671
|
+
const suggestion = getSpellingSuggestion(expressionText, viableKeywordSuggestions, identity) ?? getSpaceSuggestion(expressionText);
|
|
27655
28672
|
if (suggestion) {
|
|
27656
28673
|
parseErrorAt(pos, node.end, Diagnostics.Unknown_keyword_or_identifier_Did_you_mean_0, suggestion);
|
|
27657
28674
|
return;
|
|
@@ -35017,6 +36034,15 @@ var commandOptionsWithoutBuild = [
|
|
|
35017
36034
|
description: Diagnostics.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,
|
|
35018
36035
|
defaultValueDescription: false
|
|
35019
36036
|
},
|
|
36037
|
+
{
|
|
36038
|
+
name: "isolatedDeclarations",
|
|
36039
|
+
type: "boolean",
|
|
36040
|
+
category: Diagnostics.Interop_Constraints,
|
|
36041
|
+
description: Diagnostics.Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files,
|
|
36042
|
+
defaultValueDescription: false,
|
|
36043
|
+
affectsBuildInfo: true,
|
|
36044
|
+
affectsSemanticDiagnostics: true
|
|
36045
|
+
},
|
|
35020
36046
|
// Strict Type Checks
|
|
35021
36047
|
{
|
|
35022
36048
|
name: "strict",
|
|
@@ -44258,6 +45284,17 @@ function createTypeChecker(host) {
|
|
|
44258
45284
|
var checkBinaryExpression = createCheckBinaryExpression();
|
|
44259
45285
|
var emitResolver = createResolver();
|
|
44260
45286
|
var nodeBuilder = createNodeBuilder();
|
|
45287
|
+
var syntacticNodeBuilder = createSyntacticTypeNodeBuilder(compilerOptions, {
|
|
45288
|
+
isEntityNameVisible,
|
|
45289
|
+
isExpandoFunctionDeclaration,
|
|
45290
|
+
isNonNarrowedBindableName,
|
|
45291
|
+
getAllAccessorDeclarations: getAllAccessorDeclarationsForDeclaration,
|
|
45292
|
+
requiresAddingImplicitUndefined,
|
|
45293
|
+
isUndefinedIdentifierExpression(node) {
|
|
45294
|
+
Debug.assert(isExpressionNode(node));
|
|
45295
|
+
return getSymbolAtLocation(node) === undefinedSymbol;
|
|
45296
|
+
}
|
|
45297
|
+
});
|
|
44261
45298
|
var evaluate = createEvaluator({
|
|
44262
45299
|
evaluateElementAccessExpression,
|
|
44263
45300
|
evaluateEntityNameExpression
|
|
@@ -48284,7 +49321,7 @@ function createTypeChecker(host) {
|
|
|
48284
49321
|
}
|
|
48285
49322
|
return meaning;
|
|
48286
49323
|
}
|
|
48287
|
-
function isEntityNameVisible(entityName, enclosingDeclaration) {
|
|
49324
|
+
function isEntityNameVisible(entityName, enclosingDeclaration, shouldComputeAliasToMakeVisible = true) {
|
|
48288
49325
|
const meaning = getMeaningOfEntityNameReference(entityName);
|
|
48289
49326
|
const firstIdentifier = getFirstIdentifier(entityName);
|
|
48290
49327
|
const symbol = resolveName(
|
|
@@ -48314,11 +49351,7 @@ function createTypeChecker(host) {
|
|
|
48314
49351
|
).accessibility === 0 /* Accessible */) {
|
|
48315
49352
|
return { accessibility: 0 /* Accessible */ };
|
|
48316
49353
|
}
|
|
48317
|
-
return symbol && hasVisibleDeclarations(
|
|
48318
|
-
symbol,
|
|
48319
|
-
/*shouldComputeAliasToMakeVisible*/
|
|
48320
|
-
true
|
|
48321
|
-
) || {
|
|
49354
|
+
return symbol && hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
|
|
48322
49355
|
accessibility: 1 /* NotAccessible */,
|
|
48323
49356
|
errorSymbolName: getTextOfNode(firstIdentifier),
|
|
48324
49357
|
errorNode: firstIdentifier
|
|
@@ -48467,6 +49500,16 @@ function createTypeChecker(host) {
|
|
|
48467
49500
|
return setTextRange(setOriginalNode(range, location), location);
|
|
48468
49501
|
}
|
|
48469
49502
|
function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
|
|
49503
|
+
const oldFlags = context.flags;
|
|
49504
|
+
if (expr && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
|
|
49505
|
+
syntacticNodeBuilder.serializeTypeOfExpression(expr, context, addUndefined);
|
|
49506
|
+
}
|
|
49507
|
+
context.flags |= -2147483648 /* NoSyntacticPrinter */;
|
|
49508
|
+
const result = expressionOrTypeToTypeNodeHelper(context, expr, type, addUndefined);
|
|
49509
|
+
context.flags = oldFlags;
|
|
49510
|
+
return result;
|
|
49511
|
+
}
|
|
49512
|
+
function expressionOrTypeToTypeNodeHelper(context, expr, type, addUndefined) {
|
|
48470
49513
|
if (expr) {
|
|
48471
49514
|
const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
|
|
48472
49515
|
if (typeNode && !isConstTypeReference(typeNode)) {
|
|
@@ -50411,6 +51454,10 @@ function createTypeChecker(host) {
|
|
|
50411
51454
|
}
|
|
50412
51455
|
const decl = declaration ?? symbol.valueDeclaration ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
50413
51456
|
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
|
|
51457
|
+
if (decl && hasInferredType(decl) && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
|
|
51458
|
+
syntacticNodeBuilder.serializeTypeOfDeclaration(decl, context);
|
|
51459
|
+
}
|
|
51460
|
+
context.flags |= -2147483648 /* NoSyntacticPrinter */;
|
|
50414
51461
|
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
|
|
50415
51462
|
context.flags = oldFlags;
|
|
50416
51463
|
return result;
|
|
@@ -50432,6 +51479,10 @@ function createTypeChecker(host) {
|
|
|
50432
51479
|
let returnTypeNode;
|
|
50433
51480
|
const returnType = getReturnTypeOfSignature(signature);
|
|
50434
51481
|
if (returnType && !(suppressAny && isTypeAny(returnType))) {
|
|
51482
|
+
if (signature.declaration && !(context.flags & -2147483648 /* NoSyntacticPrinter */)) {
|
|
51483
|
+
syntacticNodeBuilder.serializeReturnTypeForSignature(signature.declaration, context);
|
|
51484
|
+
}
|
|
51485
|
+
context.flags |= -2147483648 /* NoSyntacticPrinter */;
|
|
50435
51486
|
returnTypeNode = serializeReturnTypeForSignatureWorker(context, signature);
|
|
50436
51487
|
} else if (!suppressAny) {
|
|
50437
51488
|
returnTypeNode = factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
@@ -67035,7 +68086,7 @@ function createTypeChecker(host) {
|
|
|
67035
68086
|
case 206 /* ObjectBindingPattern */:
|
|
67036
68087
|
case 207 /* ArrayBindingPattern */:
|
|
67037
68088
|
const rootDeclaration = getRootDeclaration(node.parent);
|
|
67038
|
-
return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) &&
|
|
68089
|
+
return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike2(rootDeclaration);
|
|
67039
68090
|
}
|
|
67040
68091
|
return false;
|
|
67041
68092
|
}
|
|
@@ -67174,7 +68225,7 @@ function createTypeChecker(host) {
|
|
|
67174
68225
|
if (!isReachableFlowNode(flow)) {
|
|
67175
68226
|
return unreachableNeverType;
|
|
67176
68227
|
}
|
|
67177
|
-
if (isVariableDeclaration(node) && (isInJSFile(node) ||
|
|
68228
|
+
if (isVariableDeclaration(node) && (isInJSFile(node) || isVarConstLike2(node))) {
|
|
67178
68229
|
const init = getDeclaredExpandoInitializer(node);
|
|
67179
68230
|
if (init && (init.kind === 218 /* FunctionExpression */ || init.kind === 219 /* ArrowFunction */)) {
|
|
67180
68231
|
return getTypeAtFlowNode(flow.antecedent);
|
|
@@ -73661,7 +74712,7 @@ function createTypeChecker(host) {
|
|
|
73661
74712
|
let name;
|
|
73662
74713
|
let decl;
|
|
73663
74714
|
if (isVariableDeclaration(node.parent) && node.parent.initializer === node) {
|
|
73664
|
-
if (!isInJSFile(node) && !(
|
|
74715
|
+
if (!isInJSFile(node) && !(isVarConstLike2(node.parent) && isFunctionLikeDeclaration(node))) {
|
|
73665
74716
|
return void 0;
|
|
73666
74717
|
}
|
|
73667
74718
|
name = node.parent.name;
|
|
@@ -75942,7 +76993,7 @@ function createTypeChecker(host) {
|
|
|
75942
76993
|
parent = parent.parent;
|
|
75943
76994
|
}
|
|
75944
76995
|
if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent)) {
|
|
75945
|
-
|
|
76996
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
|
|
75946
76997
|
}
|
|
75947
76998
|
checkTruthinessOfType(leftType, node.left);
|
|
75948
76999
|
}
|
|
@@ -76500,7 +77551,7 @@ function createTypeChecker(host) {
|
|
|
76500
77551
|
}
|
|
76501
77552
|
function checkConditionalExpression(node, checkMode) {
|
|
76502
77553
|
const type = checkTruthinessExpression(node.condition, checkMode);
|
|
76503
|
-
|
|
77554
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.condition, type, node.whenTrue);
|
|
76504
77555
|
const type1 = checkExpression(node.whenTrue, checkMode);
|
|
76505
77556
|
const type2 = checkExpression(node.whenFalse, checkMode);
|
|
76506
77557
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -79548,14 +80599,14 @@ function createTypeChecker(host) {
|
|
|
79548
80599
|
function checkIfStatement(node) {
|
|
79549
80600
|
checkGrammarStatementInAmbientContext(node);
|
|
79550
80601
|
const type = checkTruthinessExpression(node.expression);
|
|
79551
|
-
|
|
80602
|
+
checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.expression, type, node.thenStatement);
|
|
79552
80603
|
checkSourceElement(node.thenStatement);
|
|
79553
80604
|
if (node.thenStatement.kind === 242 /* EmptyStatement */) {
|
|
79554
80605
|
error(node.thenStatement, Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
79555
80606
|
}
|
|
79556
80607
|
checkSourceElement(node.elseStatement);
|
|
79557
80608
|
}
|
|
79558
|
-
function
|
|
80609
|
+
function checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(condExpr, condType, body) {
|
|
79559
80610
|
if (!strictNullChecks)
|
|
79560
80611
|
return;
|
|
79561
80612
|
bothHelper(condExpr, body);
|
|
@@ -79577,6 +80628,10 @@ function createTypeChecker(host) {
|
|
|
79577
80628
|
return;
|
|
79578
80629
|
}
|
|
79579
80630
|
const type = location === condExpr2 ? condType : checkTruthinessExpression(location);
|
|
80631
|
+
if (type.flags & 1024 /* EnumLiteral */ && isPropertyAccessExpression(location) && (getNodeLinks(location.expression).resolvedSymbol ?? unknownSymbol).flags & 384 /* Enum */) {
|
|
80632
|
+
error(location, Diagnostics.This_condition_will_always_return_0, !!type.value ? "true" : "false");
|
|
80633
|
+
return;
|
|
80634
|
+
}
|
|
79580
80635
|
const isPropertyExpressionCast = isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
79581
80636
|
if (!hasTypeFacts(type, 4194304 /* Truthy */) || isPropertyExpressionCast)
|
|
79582
80637
|
return;
|
|
@@ -81537,10 +82592,18 @@ function createTypeChecker(host) {
|
|
|
81537
82592
|
/*isSyntacticallyString*/
|
|
81538
82593
|
false,
|
|
81539
82594
|
/*resolvedOtherFiles*/
|
|
82595
|
+
true,
|
|
82596
|
+
/*hasExternalReferences*/
|
|
81540
82597
|
true
|
|
81541
82598
|
);
|
|
81542
82599
|
}
|
|
81543
|
-
return
|
|
82600
|
+
return evaluatorResult(
|
|
82601
|
+
result.value,
|
|
82602
|
+
result.isSyntacticallyString,
|
|
82603
|
+
result.resolvedOtherFiles,
|
|
82604
|
+
/*hasExternalReferences*/
|
|
82605
|
+
true
|
|
82606
|
+
);
|
|
81544
82607
|
}
|
|
81545
82608
|
}
|
|
81546
82609
|
return evaluatorResult(
|
|
@@ -81587,7 +82650,17 @@ function createTypeChecker(host) {
|
|
|
81587
82650
|
0
|
|
81588
82651
|
);
|
|
81589
82652
|
}
|
|
81590
|
-
|
|
82653
|
+
const value = getEnumMemberValue(declaration);
|
|
82654
|
+
if (location.parent !== declaration.parent) {
|
|
82655
|
+
return evaluatorResult(
|
|
82656
|
+
value.value,
|
|
82657
|
+
value.isSyntacticallyString,
|
|
82658
|
+
value.resolvedOtherFiles,
|
|
82659
|
+
/*hasExternalReferences*/
|
|
82660
|
+
true
|
|
82661
|
+
);
|
|
82662
|
+
}
|
|
82663
|
+
return value;
|
|
81591
82664
|
}
|
|
81592
82665
|
function checkEnumDeclaration(node) {
|
|
81593
82666
|
addLazyDiagnostic(() => checkEnumDeclarationWorker(node));
|
|
@@ -83698,12 +84771,24 @@ function createTypeChecker(host) {
|
|
|
83698
84771
|
return strictNullChecks && isOptionalParameter(parameter) && (isJSDocParameterTag(parameter) || !parameter.initializer) && hasSyntacticModifier(parameter, 31 /* ParameterPropertyModifier */);
|
|
83699
84772
|
}
|
|
83700
84773
|
function isExpandoFunctionDeclaration(node) {
|
|
83701
|
-
const declaration = getParseTreeNode(node, isFunctionDeclaration);
|
|
84774
|
+
const declaration = getParseTreeNode(node, (n) => isFunctionDeclaration(n) || isVariableDeclaration(n));
|
|
83702
84775
|
if (!declaration) {
|
|
83703
84776
|
return false;
|
|
83704
84777
|
}
|
|
83705
|
-
|
|
83706
|
-
if (
|
|
84778
|
+
let symbol;
|
|
84779
|
+
if (isVariableDeclaration(declaration)) {
|
|
84780
|
+
if (declaration.type || !isInJSFile(declaration) && !isVarConstLike2(declaration)) {
|
|
84781
|
+
return false;
|
|
84782
|
+
}
|
|
84783
|
+
const initializer = getDeclaredExpandoInitializer(declaration);
|
|
84784
|
+
if (!initializer || !canHaveSymbol(initializer)) {
|
|
84785
|
+
return false;
|
|
84786
|
+
}
|
|
84787
|
+
symbol = getSymbolOfDeclaration(initializer);
|
|
84788
|
+
} else {
|
|
84789
|
+
symbol = getSymbolOfDeclaration(declaration);
|
|
84790
|
+
}
|
|
84791
|
+
if (!symbol || !(symbol.flags & 16 /* Function */ | 3 /* Variable */)) {
|
|
83707
84792
|
return false;
|
|
83708
84793
|
}
|
|
83709
84794
|
return !!forEachEntry(getExportsOfSymbol(symbol), (p) => p.flags & 111551 /* Value */ && isExpandoPropertyDeclaration(p.valueDeclaration));
|
|
@@ -84007,11 +85092,27 @@ function createTypeChecker(host) {
|
|
|
84007
85092
|
return void 0;
|
|
84008
85093
|
}
|
|
84009
85094
|
function isLiteralConstDeclaration(node) {
|
|
84010
|
-
if (isDeclarationReadonly(node) || isVariableDeclaration(node) &&
|
|
85095
|
+
if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConstLike2(node)) {
|
|
84011
85096
|
return isFreshLiteralType(getTypeOfSymbol(getSymbolOfDeclaration(node)));
|
|
84012
85097
|
}
|
|
84013
85098
|
return false;
|
|
84014
85099
|
}
|
|
85100
|
+
function isNonNarrowedBindableName(node) {
|
|
85101
|
+
if (!hasBindableName(node.parent)) {
|
|
85102
|
+
return false;
|
|
85103
|
+
}
|
|
85104
|
+
const expression = node.expression;
|
|
85105
|
+
if (!isEntityNameExpression(expression)) {
|
|
85106
|
+
return true;
|
|
85107
|
+
}
|
|
85108
|
+
const type = getTypeOfExpression(expression);
|
|
85109
|
+
const symbol = getSymbolAtLocation(expression);
|
|
85110
|
+
if (!symbol) {
|
|
85111
|
+
return false;
|
|
85112
|
+
}
|
|
85113
|
+
const declaredType = getTypeOfSymbol(symbol);
|
|
85114
|
+
return declaredType === type;
|
|
85115
|
+
}
|
|
84015
85116
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
84016
85117
|
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
84017
85118
|
type.symbol,
|
|
@@ -84131,6 +85232,7 @@ function createTypeChecker(host) {
|
|
|
84131
85232
|
return node && getExternalModuleFileFromDeclaration(node);
|
|
84132
85233
|
},
|
|
84133
85234
|
isLiteralConstDeclaration,
|
|
85235
|
+
isNonNarrowedBindableName,
|
|
84134
85236
|
isLateBound: (nodeIn) => {
|
|
84135
85237
|
const node = getParseTreeNode(nodeIn, isDeclaration);
|
|
84136
85238
|
const symbol = node && getSymbolOfDeclaration(node);
|
|
@@ -85502,7 +86604,7 @@ function createTypeChecker(host) {
|
|
|
85502
86604
|
const initializer = node.initializer;
|
|
85503
86605
|
if (initializer) {
|
|
85504
86606
|
const isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || initializer.kind === 112 /* TrueKeyword */ || initializer.kind === 97 /* FalseKeyword */ || isBigIntLiteralExpression(initializer));
|
|
85505
|
-
const isConstOrReadonly = isDeclarationReadonly(node) || isVariableDeclaration(node) &&
|
|
86607
|
+
const isConstOrReadonly = isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConstLike2(node);
|
|
85506
86608
|
if (isConstOrReadonly && !node.type) {
|
|
85507
86609
|
if (isInvalidInitializer) {
|
|
85508
86610
|
return grammarErrorOnNode(initializer, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
|
|
@@ -85967,7 +87069,7 @@ function createTypeChecker(host) {
|
|
|
85967
87069
|
lastGetCombinedNodeFlagsResult = getCombinedNodeFlags(node);
|
|
85968
87070
|
return lastGetCombinedNodeFlagsResult;
|
|
85969
87071
|
}
|
|
85970
|
-
function
|
|
87072
|
+
function isVarConstLike2(node) {
|
|
85971
87073
|
const blockScopeKind = getCombinedNodeFlagsCached(node) & 7 /* BlockScoped */;
|
|
85972
87074
|
return blockScopeKind === 2 /* Const */ || blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */;
|
|
85973
87075
|
}
|
|
@@ -86121,6 +87223,12 @@ var SymbolTrackerImpl = class _SymbolTrackerImpl {
|
|
|
86121
87223
|
onDiagnosticReported() {
|
|
86122
87224
|
this.context.reportedDiagnostic = true;
|
|
86123
87225
|
}
|
|
87226
|
+
reportInferenceFallback(node) {
|
|
87227
|
+
var _a;
|
|
87228
|
+
if ((_a = this.inner) == null ? void 0 : _a.reportInferenceFallback) {
|
|
87229
|
+
this.inner.reportInferenceFallback(node);
|
|
87230
|
+
}
|
|
87231
|
+
}
|
|
86124
87232
|
};
|
|
86125
87233
|
|
|
86126
87234
|
// src/compiler/visitorPublic.ts
|
|
@@ -90163,7 +91271,7 @@ function transformTypeScript(context) {
|
|
|
90163
91271
|
}
|
|
90164
91272
|
function visitParenthesizedExpression(node) {
|
|
90165
91273
|
const innerExpression = skipOuterExpressions(node.expression, ~6 /* Assertions */);
|
|
90166
|
-
if (isAssertionExpression(innerExpression)) {
|
|
91274
|
+
if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
|
|
90167
91275
|
const expression = visitNode(node.expression, visitor, isExpression);
|
|
90168
91276
|
Debug.assert(expression);
|
|
90169
91277
|
return factory2.createPartiallyEmittedExpression(expression, node);
|
|
@@ -109086,6 +110194,194 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) {
|
|
|
109086
110194
|
};
|
|
109087
110195
|
}
|
|
109088
110196
|
}
|
|
110197
|
+
function createGetIsolatedDeclarationErrors(resolver) {
|
|
110198
|
+
const relatedSuggestionByDeclarationKind = {
|
|
110199
|
+
[219 /* ArrowFunction */]: Diagnostics.Add_a_return_type_to_the_function_expression,
|
|
110200
|
+
[218 /* FunctionExpression */]: Diagnostics.Add_a_return_type_to_the_function_expression,
|
|
110201
|
+
[174 /* MethodDeclaration */]: Diagnostics.Add_a_return_type_to_the_method,
|
|
110202
|
+
[177 /* GetAccessor */]: Diagnostics.Add_a_return_type_to_the_get_accessor_declaration,
|
|
110203
|
+
[178 /* SetAccessor */]: Diagnostics.Add_a_type_to_parameter_of_the_set_accessor_declaration,
|
|
110204
|
+
[262 /* FunctionDeclaration */]: Diagnostics.Add_a_return_type_to_the_function_declaration,
|
|
110205
|
+
[180 /* ConstructSignature */]: Diagnostics.Add_a_return_type_to_the_function_declaration,
|
|
110206
|
+
[169 /* Parameter */]: Diagnostics.Add_a_type_annotation_to_the_parameter_0,
|
|
110207
|
+
[260 /* VariableDeclaration */]: Diagnostics.Add_a_type_annotation_to_the_variable_0,
|
|
110208
|
+
[172 /* PropertyDeclaration */]: Diagnostics.Add_a_type_annotation_to_the_property_0,
|
|
110209
|
+
[171 /* PropertySignature */]: Diagnostics.Add_a_type_annotation_to_the_property_0,
|
|
110210
|
+
[277 /* ExportAssignment */]: Diagnostics.Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it
|
|
110211
|
+
};
|
|
110212
|
+
const errorByDeclarationKind = {
|
|
110213
|
+
[218 /* FunctionExpression */]: Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110214
|
+
[262 /* FunctionDeclaration */]: Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110215
|
+
[219 /* ArrowFunction */]: Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110216
|
+
[174 /* MethodDeclaration */]: Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110217
|
+
[180 /* ConstructSignature */]: Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110218
|
+
[177 /* GetAccessor */]: Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110219
|
+
[178 /* SetAccessor */]: Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations,
|
|
110220
|
+
[169 /* Parameter */]: Diagnostics.Parameter_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110221
|
+
[260 /* VariableDeclaration */]: Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110222
|
+
[172 /* PropertyDeclaration */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110223
|
+
[171 /* PropertySignature */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110224
|
+
[167 /* ComputedPropertyName */]: Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations,
|
|
110225
|
+
[305 /* SpreadAssignment */]: Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations,
|
|
110226
|
+
[304 /* ShorthandPropertyAssignment */]: Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations,
|
|
110227
|
+
[209 /* ArrayLiteralExpression */]: Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations,
|
|
110228
|
+
[277 /* ExportAssignment */]: Diagnostics.Default_exports_can_t_be_inferred_with_isolatedDeclarations,
|
|
110229
|
+
[230 /* SpreadElement */]: Diagnostics.Arrays_with_spread_elements_can_t_inferred_with_isolatedDeclarations
|
|
110230
|
+
};
|
|
110231
|
+
return getDiagnostic;
|
|
110232
|
+
function getDiagnostic(node) {
|
|
110233
|
+
const heritageClause = findAncestor(node, isHeritageClause);
|
|
110234
|
+
if (heritageClause) {
|
|
110235
|
+
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
|
110236
|
+
}
|
|
110237
|
+
Debug.type(node);
|
|
110238
|
+
switch (node.kind) {
|
|
110239
|
+
case 177 /* GetAccessor */:
|
|
110240
|
+
case 178 /* SetAccessor */:
|
|
110241
|
+
return createAccessorTypeError(node);
|
|
110242
|
+
case 167 /* ComputedPropertyName */:
|
|
110243
|
+
case 304 /* ShorthandPropertyAssignment */:
|
|
110244
|
+
case 305 /* SpreadAssignment */:
|
|
110245
|
+
return createObjectLiteralError(node);
|
|
110246
|
+
case 209 /* ArrayLiteralExpression */:
|
|
110247
|
+
case 230 /* SpreadElement */:
|
|
110248
|
+
return createArrayLiteralError(node);
|
|
110249
|
+
case 174 /* MethodDeclaration */:
|
|
110250
|
+
case 180 /* ConstructSignature */:
|
|
110251
|
+
case 218 /* FunctionExpression */:
|
|
110252
|
+
case 219 /* ArrowFunction */:
|
|
110253
|
+
case 262 /* FunctionDeclaration */:
|
|
110254
|
+
return createReturnTypeError(node);
|
|
110255
|
+
case 208 /* BindingElement */:
|
|
110256
|
+
return createBindingElementError(node);
|
|
110257
|
+
case 172 /* PropertyDeclaration */:
|
|
110258
|
+
case 260 /* VariableDeclaration */:
|
|
110259
|
+
return createVariableOrPropertyError(node);
|
|
110260
|
+
case 169 /* Parameter */:
|
|
110261
|
+
return createParameterError(node);
|
|
110262
|
+
case 303 /* PropertyAssignment */:
|
|
110263
|
+
return createExpressionError(node.initializer);
|
|
110264
|
+
case 231 /* ClassExpression */:
|
|
110265
|
+
return createClassExpressionError(node);
|
|
110266
|
+
default:
|
|
110267
|
+
assertType(node);
|
|
110268
|
+
return createExpressionError(node);
|
|
110269
|
+
}
|
|
110270
|
+
}
|
|
110271
|
+
function findNearestDeclaration(node) {
|
|
110272
|
+
const result = findAncestor(node, (n) => isExportAssignment(n) || (isStatement(n) ? "quit" : isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n)));
|
|
110273
|
+
return result;
|
|
110274
|
+
}
|
|
110275
|
+
function createAccessorTypeError(node) {
|
|
110276
|
+
const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
|
|
110277
|
+
const targetNode = (isSetAccessor(node) ? node.parameters[0] : node) ?? node;
|
|
110278
|
+
const diag2 = createDiagnosticForNode(targetNode, errorByDeclarationKind[node.kind]);
|
|
110279
|
+
if (setAccessor) {
|
|
110280
|
+
addRelatedInfo(diag2, createDiagnosticForNode(setAccessor, relatedSuggestionByDeclarationKind[setAccessor.kind]));
|
|
110281
|
+
}
|
|
110282
|
+
if (getAccessor) {
|
|
110283
|
+
addRelatedInfo(diag2, createDiagnosticForNode(getAccessor, relatedSuggestionByDeclarationKind[getAccessor.kind]));
|
|
110284
|
+
}
|
|
110285
|
+
return diag2;
|
|
110286
|
+
}
|
|
110287
|
+
function createObjectLiteralError(node) {
|
|
110288
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110289
|
+
const parentDeclaration = findNearestDeclaration(node);
|
|
110290
|
+
if (parentDeclaration) {
|
|
110291
|
+
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110292
|
+
parentDeclaration.name,
|
|
110293
|
+
/*includeTrivia*/
|
|
110294
|
+
false
|
|
110295
|
+
);
|
|
110296
|
+
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110297
|
+
}
|
|
110298
|
+
return diag2;
|
|
110299
|
+
}
|
|
110300
|
+
function createArrayLiteralError(node) {
|
|
110301
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110302
|
+
const parentDeclaration = findNearestDeclaration(node);
|
|
110303
|
+
if (parentDeclaration) {
|
|
110304
|
+
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110305
|
+
parentDeclaration.name,
|
|
110306
|
+
/*includeTrivia*/
|
|
110307
|
+
false
|
|
110308
|
+
);
|
|
110309
|
+
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110310
|
+
}
|
|
110311
|
+
return diag2;
|
|
110312
|
+
}
|
|
110313
|
+
function createReturnTypeError(node) {
|
|
110314
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110315
|
+
const parentDeclaration = findNearestDeclaration(node);
|
|
110316
|
+
if (parentDeclaration) {
|
|
110317
|
+
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110318
|
+
parentDeclaration.name,
|
|
110319
|
+
/*includeTrivia*/
|
|
110320
|
+
false
|
|
110321
|
+
);
|
|
110322
|
+
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110323
|
+
}
|
|
110324
|
+
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
|
|
110325
|
+
return diag2;
|
|
110326
|
+
}
|
|
110327
|
+
function createBindingElementError(node) {
|
|
110328
|
+
return createDiagnosticForNode(node, Diagnostics.Binding_elements_can_t_be_exported_directly_with_isolatedDeclarations);
|
|
110329
|
+
}
|
|
110330
|
+
function createVariableOrPropertyError(node) {
|
|
110331
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110332
|
+
const targetStr = getTextOfNode(
|
|
110333
|
+
node.name,
|
|
110334
|
+
/*includeTrivia*/
|
|
110335
|
+
false
|
|
110336
|
+
);
|
|
110337
|
+
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind], targetStr));
|
|
110338
|
+
return diag2;
|
|
110339
|
+
}
|
|
110340
|
+
function createParameterError(node) {
|
|
110341
|
+
if (isSetAccessor(node.parent)) {
|
|
110342
|
+
return createAccessorTypeError(node.parent);
|
|
110343
|
+
}
|
|
110344
|
+
const addUndefined = resolver.requiresAddingImplicitUndefined(node);
|
|
110345
|
+
if (!addUndefined && node.initializer) {
|
|
110346
|
+
return createExpressionError(node.initializer);
|
|
110347
|
+
}
|
|
110348
|
+
const message = addUndefined ? Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations : errorByDeclarationKind[node.kind];
|
|
110349
|
+
const diag2 = createDiagnosticForNode(node, message);
|
|
110350
|
+
const targetStr = getTextOfNode(
|
|
110351
|
+
node.name,
|
|
110352
|
+
/*includeTrivia*/
|
|
110353
|
+
false
|
|
110354
|
+
);
|
|
110355
|
+
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind], targetStr));
|
|
110356
|
+
return diag2;
|
|
110357
|
+
}
|
|
110358
|
+
function createClassExpressionError(node) {
|
|
110359
|
+
return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
|
|
110360
|
+
}
|
|
110361
|
+
function createExpressionError(node, diagnosticMessage) {
|
|
110362
|
+
const parentDeclaration = findNearestDeclaration(node);
|
|
110363
|
+
let diag2;
|
|
110364
|
+
if (parentDeclaration) {
|
|
110365
|
+
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110366
|
+
parentDeclaration.name,
|
|
110367
|
+
/*includeTrivia*/
|
|
110368
|
+
false
|
|
110369
|
+
);
|
|
110370
|
+
const parent = findAncestor(node.parent, (n) => isExportAssignment(n) || (isStatement(n) ? "quit" : !isParenthesizedExpression(n) && !isTypeAssertionExpression(n) && !isAsExpression(n)));
|
|
110371
|
+
if (parentDeclaration === parent) {
|
|
110372
|
+
diag2 = createDiagnosticForNode(node, diagnosticMessage ?? errorByDeclarationKind[parentDeclaration.kind]);
|
|
110373
|
+
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110374
|
+
} else {
|
|
110375
|
+
diag2 = createDiagnosticForNode(node, diagnosticMessage ?? Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations);
|
|
110376
|
+
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110377
|
+
addRelatedInfo(diag2, createDiagnosticForNode(node, Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit));
|
|
110378
|
+
}
|
|
110379
|
+
} else {
|
|
110380
|
+
diag2 = createDiagnosticForNode(node, diagnosticMessage ?? Diagnostics.Expression_type_can_t_be_inferred_with_isolatedDeclarations);
|
|
110381
|
+
}
|
|
110382
|
+
return diag2;
|
|
110383
|
+
}
|
|
110384
|
+
}
|
|
109089
110385
|
|
|
109090
110386
|
// src/compiler/transformers/declarations.ts
|
|
109091
110387
|
function getDeclarationDiagnostics(host, resolver, file) {
|
|
@@ -109127,7 +110423,8 @@ function transformDeclarations(context) {
|
|
|
109127
110423
|
reportTruncationError,
|
|
109128
110424
|
moduleResolverHost: host,
|
|
109129
110425
|
reportNonlocalAugmentation,
|
|
109130
|
-
reportNonSerializableProperty
|
|
110426
|
+
reportNonSerializableProperty,
|
|
110427
|
+
reportInferenceFallback
|
|
109131
110428
|
};
|
|
109132
110429
|
let errorNameNode;
|
|
109133
110430
|
let errorFallbackNode;
|
|
@@ -109137,8 +110434,29 @@ function transformDeclarations(context) {
|
|
|
109137
110434
|
let rawLibReferenceDirectives;
|
|
109138
110435
|
const resolver = context.getEmitResolver();
|
|
109139
110436
|
const options = context.getCompilerOptions();
|
|
109140
|
-
const
|
|
110437
|
+
const getIsolatedDeclarationError = createGetIsolatedDeclarationErrors(resolver);
|
|
110438
|
+
const { stripInternal, isolatedDeclarations } = options;
|
|
109141
110439
|
return transformRoot;
|
|
110440
|
+
function reportExpandoFunctionErrors(node) {
|
|
110441
|
+
resolver.getPropertiesOfContainerFunction(node).forEach((p) => {
|
|
110442
|
+
if (isExpandoPropertyDeclaration(p.valueDeclaration)) {
|
|
110443
|
+
const errorTarget = isBinaryExpression(p.valueDeclaration) ? p.valueDeclaration.left : p.valueDeclaration;
|
|
110444
|
+
context.addDiagnostic(createDiagnosticForNode(
|
|
110445
|
+
errorTarget,
|
|
110446
|
+
Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function
|
|
110447
|
+
));
|
|
110448
|
+
}
|
|
110449
|
+
});
|
|
110450
|
+
}
|
|
110451
|
+
function reportInferenceFallback(node) {
|
|
110452
|
+
if (!isolatedDeclarations || isSourceFileJS(currentSourceFile))
|
|
110453
|
+
return;
|
|
110454
|
+
if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
|
|
110455
|
+
reportExpandoFunctionErrors(node);
|
|
110456
|
+
} else {
|
|
110457
|
+
context.addDiagnostic(getIsolatedDeclarationError(node));
|
|
110458
|
+
}
|
|
110459
|
+
}
|
|
109142
110460
|
function handleSymbolAccessibilityError(symbolAccessibilityResult) {
|
|
109143
110461
|
if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) {
|
|
109144
110462
|
if (symbolAccessibilityResult.aliasesToMakeVisible) {
|
|
@@ -109442,7 +110760,8 @@ function transformDeclarations(context) {
|
|
|
109442
110760
|
elem.dotDotDotToken,
|
|
109443
110761
|
elem.propertyName,
|
|
109444
110762
|
filterBindingPatternInitializers(elem.name),
|
|
109445
|
-
|
|
110763
|
+
/*initializer*/
|
|
110764
|
+
void 0
|
|
109446
110765
|
);
|
|
109447
110766
|
}
|
|
109448
110767
|
}
|
|
@@ -109473,11 +110792,15 @@ function transformDeclarations(context) {
|
|
|
109473
110792
|
return newParam;
|
|
109474
110793
|
}
|
|
109475
110794
|
function shouldPrintWithInitializer(node) {
|
|
109476
|
-
return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(getParseTreeNode(node));
|
|
110795
|
+
return canHaveLiteralInitializer(node) && !!node.initializer && resolver.isLiteralConstDeclaration(getParseTreeNode(node));
|
|
109477
110796
|
}
|
|
109478
110797
|
function ensureNoInitializer(node) {
|
|
109479
110798
|
if (shouldPrintWithInitializer(node)) {
|
|
109480
|
-
|
|
110799
|
+
const unwrappedInitializer = unwrapParenthesizedExpression(node.initializer);
|
|
110800
|
+
if (!isPrimitiveLiteralValue(unwrappedInitializer)) {
|
|
110801
|
+
reportInferenceFallback(node);
|
|
110802
|
+
}
|
|
110803
|
+
return resolver.createLiteralConstValue(getParseTreeNode(node, canHaveLiteralInitializer), symbolTracker);
|
|
109481
110804
|
}
|
|
109482
110805
|
return void 0;
|
|
109483
110806
|
}
|
|
@@ -109719,6 +111042,9 @@ function transformDeclarations(context) {
|
|
|
109719
111042
|
);
|
|
109720
111043
|
}
|
|
109721
111044
|
if (resolver.isImportRequiredByAugmentation(decl)) {
|
|
111045
|
+
if (isolatedDeclarations) {
|
|
111046
|
+
context.addDiagnostic(createDiagnosticForNode(decl, Diagnostics.Declaration_emit_for_this_file_requires_preserving_this_import_for_augmentations_This_is_not_supported_with_isolatedDeclarations));
|
|
111047
|
+
}
|
|
109722
111048
|
return factory2.updateImportDeclaration(
|
|
109723
111049
|
decl,
|
|
109724
111050
|
decl.modifiers,
|
|
@@ -109773,6 +111099,9 @@ function transformDeclarations(context) {
|
|
|
109773
111099
|
if (isDeclarationAndNotVisible(input))
|
|
109774
111100
|
return;
|
|
109775
111101
|
if (hasDynamicName(input) && !resolver.isLateBound(getParseTreeNode(input))) {
|
|
111102
|
+
if (isolatedDeclarations && isClassDeclaration(input.parent) && isEntityNameExpression(input.name.expression) && resolver.isEntityNameVisible(input.name.expression, input.parent).accessibility === 0 /* Accessible */ && !resolver.isNonNarrowedBindableName(input.name)) {
|
|
111103
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
|
|
111104
|
+
}
|
|
109776
111105
|
return;
|
|
109777
111106
|
}
|
|
109778
111107
|
}
|
|
@@ -110213,6 +111542,9 @@ function transformDeclarations(context) {
|
|
|
110213
111542
|
));
|
|
110214
111543
|
if (clean2 && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) {
|
|
110215
111544
|
const props = resolver.getPropertiesOfContainerFunction(input);
|
|
111545
|
+
if (isolatedDeclarations) {
|
|
111546
|
+
reportExpandoFunctionErrors(input);
|
|
111547
|
+
}
|
|
110216
111548
|
const fakespace = parseNodeFactory.createModuleDeclaration(
|
|
110217
111549
|
/*modifiers*/
|
|
110218
111550
|
void 0,
|
|
@@ -110233,7 +111565,7 @@ function transformDeclarations(context) {
|
|
|
110233
111565
|
return void 0;
|
|
110234
111566
|
}
|
|
110235
111567
|
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
|
|
110236
|
-
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags
|
|
111568
|
+
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags | -2147483648 /* NoSyntacticPrinter */, symbolTracker);
|
|
110237
111569
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
110238
111570
|
const isNonContextualKeywordName = isStringANonContextualKeyword(nameStr);
|
|
110239
111571
|
const name = isNonContextualKeywordName ? factory2.getGeneratedNameForNode(p.valueDeclaration) : factory2.createIdentifier(nameStr);
|
|
@@ -110487,7 +111819,12 @@ function transformDeclarations(context) {
|
|
|
110487
111819
|
factory2.createNodeArray(mapDefined(input.members, (m) => {
|
|
110488
111820
|
if (shouldStripInternal(m))
|
|
110489
111821
|
return;
|
|
110490
|
-
const
|
|
111822
|
+
const enumValue = resolver.getEnumMemberValue(m);
|
|
111823
|
+
const constValue = enumValue == null ? void 0 : enumValue.value;
|
|
111824
|
+
if (isolatedDeclarations && m.initializer && (enumValue == null ? void 0 : enumValue.hasExternalReferences) && // This will be its own compiler error instead, so don't report.
|
|
111825
|
+
!isComputedPropertyName(m.name)) {
|
|
111826
|
+
context.addDiagnostic(createDiagnosticForNode(m, Diagnostics.Enum_member_initializers_must_be_computable_without_references_to_external_symbols_with_isolatedDeclarations));
|
|
111827
|
+
}
|
|
110491
111828
|
const newInitializer = constValue === void 0 ? void 0 : typeof constValue === "string" ? factory2.createStringLiteral(constValue) : constValue < 0 ? factory2.createPrefixUnaryExpression(41 /* MinusToken */, factory2.createNumericLiteral(-constValue)) : factory2.createNumericLiteral(constValue);
|
|
110492
111829
|
return preserveJsDoc(factory2.updateEnumMember(m, m.name, newInitializer), m);
|
|
110493
111830
|
}))
|
|
@@ -111723,6 +113060,7 @@ var notImplementedResolver = {
|
|
|
111723
113060
|
isArgumentsLocalBinding: notImplemented,
|
|
111724
113061
|
getExternalModuleFileFromDeclaration: notImplemented,
|
|
111725
113062
|
isLiteralConstDeclaration: notImplemented,
|
|
113063
|
+
isNonNarrowedBindableName: notImplemented,
|
|
111726
113064
|
getJsxFactoryEntity: notImplemented,
|
|
111727
113065
|
getJsxFragmentFactoryEntity: notImplemented,
|
|
111728
113066
|
isBindingCapturedByNode: notImplemented,
|
|
@@ -119700,6 +121038,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119700
121038
|
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", options.verbatimModuleSyntax ? "verbatimModuleSyntax" : "isolatedModules");
|
|
119701
121039
|
}
|
|
119702
121040
|
}
|
|
121041
|
+
if (options.isolatedDeclarations) {
|
|
121042
|
+
if (getAllowJSCompilerOption(options)) {
|
|
121043
|
+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "isolatedDeclarations");
|
|
121044
|
+
}
|
|
121045
|
+
if (!getEmitDeclarations(options)) {
|
|
121046
|
+
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "isolatedDeclarations", "declaration", "composite");
|
|
121047
|
+
}
|
|
121048
|
+
}
|
|
119703
121049
|
if (options.inlineSourceMap) {
|
|
119704
121050
|
if (options.sourceMap) {
|
|
119705
121051
|
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
|
|
@@ -120203,7 +121549,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
120203
121549
|
message = Diagnostics.File_is_library_specified_here;
|
|
120204
121550
|
break;
|
|
120205
121551
|
}
|
|
120206
|
-
const target =
|
|
121552
|
+
const target = getNameOfScriptTarget(getEmitScriptTarget(options));
|
|
120207
121553
|
configFileNode = target ? getOptionsSyntaxByValue("target", target) : void 0;
|
|
120208
121554
|
message = Diagnostics.File_is_default_library_for_target_specified_here;
|
|
120209
121555
|
break;
|
|
@@ -123884,7 +125230,7 @@ function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
|
|
|
123884
125230
|
Diagnostics.Library_0_specified_in_compilerOptions,
|
|
123885
125231
|
options.lib[reason.index]
|
|
123886
125232
|
);
|
|
123887
|
-
const target =
|
|
125233
|
+
const target = getNameOfScriptTarget(getEmitScriptTarget(options));
|
|
123888
125234
|
const messageAndArgs = target ? [Diagnostics.Default_library_for_target_0, target] : [Diagnostics.Default_library];
|
|
123889
125235
|
return chainDiagnosticMessages(
|
|
123890
125236
|
/*details*/
|
|
@@ -127909,6 +129255,443 @@ function writeConfigFile(sys2, reportDiagnostic, options, fileNames) {
|
|
|
127909
129255
|
return;
|
|
127910
129256
|
}
|
|
127911
129257
|
|
|
129258
|
+
// src/compiler/expressionToTypeNode.ts
|
|
129259
|
+
function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
129260
|
+
const strictNullChecks = getStrictOptionValue(options, "strictNullChecks");
|
|
129261
|
+
return {
|
|
129262
|
+
typeFromExpression,
|
|
129263
|
+
serializeTypeOfDeclaration,
|
|
129264
|
+
serializeReturnTypeForSignature,
|
|
129265
|
+
serializeTypeOfExpression
|
|
129266
|
+
};
|
|
129267
|
+
function serializeExistingTypeAnnotation(type) {
|
|
129268
|
+
return type === void 0 ? void 0 : !type.parent || !isParameter(type.parent) || !resolver.requiresAddingImplicitUndefined(type.parent) || canAddUndefined(type);
|
|
129269
|
+
}
|
|
129270
|
+
function serializeTypeOfExpression(expr, context, addUndefined, preserveLiterals) {
|
|
129271
|
+
return typeFromExpression(
|
|
129272
|
+
expr,
|
|
129273
|
+
context,
|
|
129274
|
+
/*isConstContext*/
|
|
129275
|
+
false,
|
|
129276
|
+
addUndefined,
|
|
129277
|
+
preserveLiterals
|
|
129278
|
+
) ?? inferExpressionType(expr, context);
|
|
129279
|
+
}
|
|
129280
|
+
function serializeTypeOfDeclaration(node, context) {
|
|
129281
|
+
switch (node.kind) {
|
|
129282
|
+
case 171 /* PropertySignature */:
|
|
129283
|
+
return serializeExistingTypeAnnotation(getEffectiveTypeAnnotationNode(node));
|
|
129284
|
+
case 169 /* Parameter */:
|
|
129285
|
+
return typeFromParameter(node, context);
|
|
129286
|
+
case 260 /* VariableDeclaration */:
|
|
129287
|
+
return typeFromVariable(node, context);
|
|
129288
|
+
case 172 /* PropertyDeclaration */:
|
|
129289
|
+
return typeFromProperty(node, context);
|
|
129290
|
+
case 208 /* BindingElement */:
|
|
129291
|
+
return inferTypeOfDeclaration(node, context);
|
|
129292
|
+
case 277 /* ExportAssignment */:
|
|
129293
|
+
return serializeTypeOfExpression(
|
|
129294
|
+
node.expression,
|
|
129295
|
+
context,
|
|
129296
|
+
/*addUndefined*/
|
|
129297
|
+
void 0,
|
|
129298
|
+
/*preserveLiterals*/
|
|
129299
|
+
true
|
|
129300
|
+
);
|
|
129301
|
+
case 211 /* PropertyAccessExpression */:
|
|
129302
|
+
case 212 /* ElementAccessExpression */:
|
|
129303
|
+
case 226 /* BinaryExpression */:
|
|
129304
|
+
return serializeExistingTypeAnnotation(getEffectiveTypeAnnotationNode(node)) || inferTypeOfDeclaration(node, context);
|
|
129305
|
+
case 303 /* PropertyAssignment */:
|
|
129306
|
+
return typeFromExpression(node.initializer, context) || inferTypeOfDeclaration(node, context);
|
|
129307
|
+
default:
|
|
129308
|
+
Debug.assertNever(node, `Node needs to be an inferrable node, found ${Debug.formatSyntaxKind(node.kind)}`);
|
|
129309
|
+
}
|
|
129310
|
+
}
|
|
129311
|
+
function serializeReturnTypeForSignature(node, context) {
|
|
129312
|
+
switch (node.kind) {
|
|
129313
|
+
case 177 /* GetAccessor */:
|
|
129314
|
+
return typeFromAccessor(node, context);
|
|
129315
|
+
case 174 /* MethodDeclaration */:
|
|
129316
|
+
case 262 /* FunctionDeclaration */:
|
|
129317
|
+
case 180 /* ConstructSignature */:
|
|
129318
|
+
case 173 /* MethodSignature */:
|
|
129319
|
+
case 179 /* CallSignature */:
|
|
129320
|
+
case 176 /* Constructor */:
|
|
129321
|
+
case 178 /* SetAccessor */:
|
|
129322
|
+
case 181 /* IndexSignature */:
|
|
129323
|
+
case 184 /* FunctionType */:
|
|
129324
|
+
case 185 /* ConstructorType */:
|
|
129325
|
+
case 218 /* FunctionExpression */:
|
|
129326
|
+
case 219 /* ArrowFunction */:
|
|
129327
|
+
case 317 /* JSDocFunctionType */:
|
|
129328
|
+
case 323 /* JSDocSignature */:
|
|
129329
|
+
return createReturnFromSignature(node, context);
|
|
129330
|
+
default:
|
|
129331
|
+
Debug.assertNever(node, `Node needs to be an inferrable node, found ${Debug.formatSyntaxKind(node.kind)}`);
|
|
129332
|
+
}
|
|
129333
|
+
}
|
|
129334
|
+
function getTypeAnnotationFromAccessor2(accessor) {
|
|
129335
|
+
if (accessor) {
|
|
129336
|
+
return accessor.kind === 177 /* GetAccessor */ ? getEffectiveReturnTypeNode(accessor) : accessor.parameters.length > 0 ? getEffectiveTypeAnnotationNode(accessor.parameters[0]) : void 0;
|
|
129337
|
+
}
|
|
129338
|
+
}
|
|
129339
|
+
function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
|
|
129340
|
+
let accessorType = getTypeAnnotationFromAccessor2(node);
|
|
129341
|
+
if (!accessorType && node !== accessors.firstAccessor) {
|
|
129342
|
+
accessorType = getTypeAnnotationFromAccessor2(accessors.firstAccessor);
|
|
129343
|
+
}
|
|
129344
|
+
if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
|
|
129345
|
+
accessorType = getTypeAnnotationFromAccessor2(accessors.secondAccessor);
|
|
129346
|
+
}
|
|
129347
|
+
return accessorType;
|
|
129348
|
+
}
|
|
129349
|
+
function typeFromAccessor(node, context) {
|
|
129350
|
+
const accessorDeclarations = resolver.getAllAccessorDeclarations(node);
|
|
129351
|
+
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessorDeclarations);
|
|
129352
|
+
if (accessorType) {
|
|
129353
|
+
return serializeExistingTypeAnnotation(accessorType);
|
|
129354
|
+
}
|
|
129355
|
+
if (accessorDeclarations.getAccessor) {
|
|
129356
|
+
return createReturnFromSignature(accessorDeclarations.getAccessor, context);
|
|
129357
|
+
}
|
|
129358
|
+
return false;
|
|
129359
|
+
}
|
|
129360
|
+
function typeFromVariable(node, context) {
|
|
129361
|
+
const declaredType = getEffectiveTypeAnnotationNode(node);
|
|
129362
|
+
if (declaredType) {
|
|
129363
|
+
return serializeExistingTypeAnnotation(declaredType);
|
|
129364
|
+
}
|
|
129365
|
+
let resultType;
|
|
129366
|
+
if (node.initializer) {
|
|
129367
|
+
if (!resolver.isExpandoFunctionDeclaration(node)) {
|
|
129368
|
+
resultType = typeFromExpression(
|
|
129369
|
+
node.initializer,
|
|
129370
|
+
context,
|
|
129371
|
+
/*isConstContext*/
|
|
129372
|
+
void 0,
|
|
129373
|
+
/*requiresAddingUndefined*/
|
|
129374
|
+
void 0,
|
|
129375
|
+
isVarConstLike(node)
|
|
129376
|
+
);
|
|
129377
|
+
}
|
|
129378
|
+
}
|
|
129379
|
+
return resultType ?? inferTypeOfDeclaration(node, context);
|
|
129380
|
+
}
|
|
129381
|
+
function typeFromParameter(node, context) {
|
|
129382
|
+
const parent = node.parent;
|
|
129383
|
+
if (parent.kind === 178 /* SetAccessor */) {
|
|
129384
|
+
return typeFromAccessor(parent, context);
|
|
129385
|
+
}
|
|
129386
|
+
const declaredType = getEffectiveTypeAnnotationNode(node);
|
|
129387
|
+
const addUndefined = resolver.requiresAddingImplicitUndefined(node);
|
|
129388
|
+
let resultType;
|
|
129389
|
+
if (!addUndefined) {
|
|
129390
|
+
if (declaredType) {
|
|
129391
|
+
return serializeExistingTypeAnnotation(declaredType);
|
|
129392
|
+
}
|
|
129393
|
+
if (node.initializer && isIdentifier(node.name)) {
|
|
129394
|
+
resultType = typeFromExpression(node.initializer, context);
|
|
129395
|
+
}
|
|
129396
|
+
}
|
|
129397
|
+
return resultType ?? inferTypeOfDeclaration(node, context);
|
|
129398
|
+
}
|
|
129399
|
+
function typeFromProperty(node, context) {
|
|
129400
|
+
const declaredType = getEffectiveTypeAnnotationNode(node);
|
|
129401
|
+
if (declaredType) {
|
|
129402
|
+
return serializeExistingTypeAnnotation(declaredType);
|
|
129403
|
+
}
|
|
129404
|
+
let resultType;
|
|
129405
|
+
if (node.initializer) {
|
|
129406
|
+
const isReadonly = isDeclarationReadonly(node);
|
|
129407
|
+
resultType = typeFromExpression(
|
|
129408
|
+
node.initializer,
|
|
129409
|
+
context,
|
|
129410
|
+
/*isConstContext*/
|
|
129411
|
+
void 0,
|
|
129412
|
+
/*requiresAddingUndefined*/
|
|
129413
|
+
void 0,
|
|
129414
|
+
isReadonly
|
|
129415
|
+
);
|
|
129416
|
+
}
|
|
129417
|
+
return resultType ?? inferTypeOfDeclaration(node, context);
|
|
129418
|
+
}
|
|
129419
|
+
function inferTypeOfDeclaration(node, context) {
|
|
129420
|
+
context.tracker.reportInferenceFallback(node);
|
|
129421
|
+
return false;
|
|
129422
|
+
}
|
|
129423
|
+
function inferExpressionType(node, context) {
|
|
129424
|
+
context.tracker.reportInferenceFallback(node);
|
|
129425
|
+
return false;
|
|
129426
|
+
}
|
|
129427
|
+
function inferReturnTypeOfSignatureSignature(node, context) {
|
|
129428
|
+
context.tracker.reportInferenceFallback(node);
|
|
129429
|
+
return false;
|
|
129430
|
+
}
|
|
129431
|
+
function inferAccessorType(node, allAccessors, context) {
|
|
129432
|
+
if (node.kind === 177 /* GetAccessor */) {
|
|
129433
|
+
return createReturnFromSignature(node, context);
|
|
129434
|
+
} else {
|
|
129435
|
+
context.tracker.reportInferenceFallback(node);
|
|
129436
|
+
return false;
|
|
129437
|
+
}
|
|
129438
|
+
}
|
|
129439
|
+
function typeFromTypeAssertion(expression, type, context, requiresAddingUndefined) {
|
|
129440
|
+
if (isConstTypeReference(type)) {
|
|
129441
|
+
return typeFromExpression(
|
|
129442
|
+
expression,
|
|
129443
|
+
context,
|
|
129444
|
+
/*isConstContext*/
|
|
129445
|
+
true,
|
|
129446
|
+
requiresAddingUndefined
|
|
129447
|
+
);
|
|
129448
|
+
}
|
|
129449
|
+
if (requiresAddingUndefined && !canAddUndefined(type)) {
|
|
129450
|
+
context.tracker.reportInferenceFallback(type);
|
|
129451
|
+
}
|
|
129452
|
+
return serializeExistingTypeAnnotation(type);
|
|
129453
|
+
}
|
|
129454
|
+
function typeFromExpression(node, context, isConstContext = false, requiresAddingUndefined = false, preserveLiterals = false) {
|
|
129455
|
+
switch (node.kind) {
|
|
129456
|
+
case 217 /* ParenthesizedExpression */:
|
|
129457
|
+
if (isJSDocTypeAssertion(node)) {
|
|
129458
|
+
return typeFromTypeAssertion(node.expression, getJSDocTypeAssertionType(node), context, requiresAddingUndefined);
|
|
129459
|
+
}
|
|
129460
|
+
return typeFromExpression(node.expression, context, isConstContext, requiresAddingUndefined);
|
|
129461
|
+
case 80 /* Identifier */:
|
|
129462
|
+
if (resolver.isUndefinedIdentifierExpression(node)) {
|
|
129463
|
+
return true;
|
|
129464
|
+
}
|
|
129465
|
+
break;
|
|
129466
|
+
case 106 /* NullKeyword */:
|
|
129467
|
+
return true;
|
|
129468
|
+
case 219 /* ArrowFunction */:
|
|
129469
|
+
case 218 /* FunctionExpression */:
|
|
129470
|
+
return typeFromFunctionLikeExpression(node, context);
|
|
129471
|
+
case 216 /* TypeAssertionExpression */:
|
|
129472
|
+
case 234 /* AsExpression */:
|
|
129473
|
+
const asExpression = node;
|
|
129474
|
+
return typeFromTypeAssertion(asExpression.expression, asExpression.type, context, requiresAddingUndefined);
|
|
129475
|
+
case 224 /* PrefixUnaryExpression */:
|
|
129476
|
+
const unaryExpression = node;
|
|
129477
|
+
if (isPrimitiveLiteralValue(unaryExpression)) {
|
|
129478
|
+
if (unaryExpression.operand.kind === 10 /* BigIntLiteral */) {
|
|
129479
|
+
return typeFromPrimitiveLiteral();
|
|
129480
|
+
}
|
|
129481
|
+
if (unaryExpression.operand.kind === 9 /* NumericLiteral */) {
|
|
129482
|
+
return typeFromPrimitiveLiteral();
|
|
129483
|
+
}
|
|
129484
|
+
}
|
|
129485
|
+
break;
|
|
129486
|
+
case 9 /* NumericLiteral */:
|
|
129487
|
+
return typeFromPrimitiveLiteral();
|
|
129488
|
+
case 228 /* TemplateExpression */:
|
|
129489
|
+
if (!isConstContext && !preserveLiterals) {
|
|
129490
|
+
return true;
|
|
129491
|
+
}
|
|
129492
|
+
break;
|
|
129493
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
129494
|
+
case 11 /* StringLiteral */:
|
|
129495
|
+
return typeFromPrimitiveLiteral();
|
|
129496
|
+
case 10 /* BigIntLiteral */:
|
|
129497
|
+
return typeFromPrimitiveLiteral();
|
|
129498
|
+
case 112 /* TrueKeyword */:
|
|
129499
|
+
case 97 /* FalseKeyword */:
|
|
129500
|
+
return typeFromPrimitiveLiteral();
|
|
129501
|
+
case 209 /* ArrayLiteralExpression */:
|
|
129502
|
+
return typeFromArrayLiteral(node, context, isConstContext);
|
|
129503
|
+
case 210 /* ObjectLiteralExpression */:
|
|
129504
|
+
return typeFromObjectLiteral(node, context, isConstContext);
|
|
129505
|
+
case 231 /* ClassExpression */:
|
|
129506
|
+
return inferExpressionType(node, context);
|
|
129507
|
+
}
|
|
129508
|
+
return void 0;
|
|
129509
|
+
}
|
|
129510
|
+
function typeFromFunctionLikeExpression(fnNode, context) {
|
|
129511
|
+
const returnType = serializeExistingTypeAnnotation(fnNode.type) ?? createReturnFromSignature(fnNode, context);
|
|
129512
|
+
const typeParameters = reuseTypeParameters(fnNode.typeParameters);
|
|
129513
|
+
const parameters = fnNode.parameters.every((p) => ensureParameter(p, context));
|
|
129514
|
+
return returnType && typeParameters && parameters;
|
|
129515
|
+
}
|
|
129516
|
+
function canGetTypeFromArrayLiteral(arrayLiteral, context, isConstContext) {
|
|
129517
|
+
if (!isConstContext) {
|
|
129518
|
+
context.tracker.reportInferenceFallback(arrayLiteral);
|
|
129519
|
+
return false;
|
|
129520
|
+
}
|
|
129521
|
+
for (const element of arrayLiteral.elements) {
|
|
129522
|
+
if (element.kind === 230 /* SpreadElement */) {
|
|
129523
|
+
context.tracker.reportInferenceFallback(element);
|
|
129524
|
+
return false;
|
|
129525
|
+
}
|
|
129526
|
+
}
|
|
129527
|
+
return true;
|
|
129528
|
+
}
|
|
129529
|
+
function typeFromArrayLiteral(arrayLiteral, context, isConstContext) {
|
|
129530
|
+
if (!canGetTypeFromArrayLiteral(arrayLiteral, context, isConstContext)) {
|
|
129531
|
+
return false;
|
|
129532
|
+
}
|
|
129533
|
+
let canInferArray = true;
|
|
129534
|
+
for (const element of arrayLiteral.elements) {
|
|
129535
|
+
Debug.assert(element.kind !== 230 /* SpreadElement */);
|
|
129536
|
+
if (element.kind !== 232 /* OmittedExpression */) {
|
|
129537
|
+
canInferArray = (typeFromExpression(element, context, isConstContext) ?? inferExpressionType(element, context)) && canInferArray;
|
|
129538
|
+
}
|
|
129539
|
+
}
|
|
129540
|
+
return true;
|
|
129541
|
+
}
|
|
129542
|
+
function canGetTypeFromObjectLiteral(objectLiteral, context) {
|
|
129543
|
+
let result = true;
|
|
129544
|
+
for (const prop of objectLiteral.properties) {
|
|
129545
|
+
if (prop.flags & 262144 /* ThisNodeHasError */) {
|
|
129546
|
+
result = false;
|
|
129547
|
+
break;
|
|
129548
|
+
}
|
|
129549
|
+
if (prop.kind === 304 /* ShorthandPropertyAssignment */ || prop.kind === 305 /* SpreadAssignment */) {
|
|
129550
|
+
context.tracker.reportInferenceFallback(prop);
|
|
129551
|
+
result = false;
|
|
129552
|
+
} else if (prop.name.flags & 262144 /* ThisNodeHasError */) {
|
|
129553
|
+
result = false;
|
|
129554
|
+
break;
|
|
129555
|
+
} else if (prop.name.kind === 81 /* PrivateIdentifier */) {
|
|
129556
|
+
result = false;
|
|
129557
|
+
} else if (prop.name.kind === 167 /* ComputedPropertyName */) {
|
|
129558
|
+
const expression = prop.name.expression;
|
|
129559
|
+
if (!isPrimitiveLiteralValue(
|
|
129560
|
+
expression,
|
|
129561
|
+
/*includeBigInt*/
|
|
129562
|
+
false
|
|
129563
|
+
) && !isEntityNameExpression(expression)) {
|
|
129564
|
+
context.tracker.reportInferenceFallback(prop.name);
|
|
129565
|
+
result = false;
|
|
129566
|
+
}
|
|
129567
|
+
}
|
|
129568
|
+
}
|
|
129569
|
+
return result;
|
|
129570
|
+
}
|
|
129571
|
+
function typeFromObjectLiteral(objectLiteral, context, isConstContext) {
|
|
129572
|
+
if (!canGetTypeFromObjectLiteral(objectLiteral, context))
|
|
129573
|
+
return false;
|
|
129574
|
+
let canInferObjectLiteral = true;
|
|
129575
|
+
for (const prop of objectLiteral.properties) {
|
|
129576
|
+
Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
|
|
129577
|
+
const name = prop.name;
|
|
129578
|
+
if (prop.name.kind === 167 /* ComputedPropertyName */) {
|
|
129579
|
+
if (!resolver.isNonNarrowedBindableName(prop.name)) {
|
|
129580
|
+
context.tracker.reportInferenceFallback(prop.name);
|
|
129581
|
+
} else if (isEntityNameExpression(prop.name.expression)) {
|
|
129582
|
+
const visibilityResult = resolver.isEntityNameVisible(
|
|
129583
|
+
prop.name.expression,
|
|
129584
|
+
context.enclosingDeclaration,
|
|
129585
|
+
/*shouldComputeAliasToMakeVisible*/
|
|
129586
|
+
false
|
|
129587
|
+
);
|
|
129588
|
+
if (visibilityResult.accessibility !== 0 /* Accessible */) {
|
|
129589
|
+
context.tracker.reportInferenceFallback(prop.name);
|
|
129590
|
+
}
|
|
129591
|
+
}
|
|
129592
|
+
}
|
|
129593
|
+
switch (prop.kind) {
|
|
129594
|
+
case 174 /* MethodDeclaration */:
|
|
129595
|
+
canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
|
|
129596
|
+
break;
|
|
129597
|
+
case 303 /* PropertyAssignment */:
|
|
129598
|
+
canInferObjectLiteral = !!typeFromObjectLiteralPropertyAssignment(prop, name, context, isConstContext) && canInferObjectLiteral;
|
|
129599
|
+
break;
|
|
129600
|
+
case 178 /* SetAccessor */:
|
|
129601
|
+
case 177 /* GetAccessor */:
|
|
129602
|
+
canInferObjectLiteral = !!typeFromObjectLiteralAccessor(prop, name, context) && canInferObjectLiteral;
|
|
129603
|
+
break;
|
|
129604
|
+
}
|
|
129605
|
+
}
|
|
129606
|
+
return canInferObjectLiteral;
|
|
129607
|
+
}
|
|
129608
|
+
function typeFromObjectLiteralPropertyAssignment(prop, name, context, isConstContext) {
|
|
129609
|
+
return typeFromExpression(prop.initializer, context, isConstContext) ?? inferTypeOfDeclaration(prop, context);
|
|
129610
|
+
}
|
|
129611
|
+
function ensureParameter(p, context) {
|
|
129612
|
+
return typeFromParameter(p, context);
|
|
129613
|
+
}
|
|
129614
|
+
function reuseTypeParameters(typeParameters) {
|
|
129615
|
+
return (typeParameters == null ? void 0 : typeParameters.every(
|
|
129616
|
+
(tp) => serializeExistingTypeAnnotation(tp.constraint) && serializeExistingTypeAnnotation(tp.default)
|
|
129617
|
+
)) ?? true;
|
|
129618
|
+
}
|
|
129619
|
+
function typeFromObjectLiteralMethod(method, name, context) {
|
|
129620
|
+
const returnType = createReturnFromSignature(method, context);
|
|
129621
|
+
const typeParameters = reuseTypeParameters(method.typeParameters);
|
|
129622
|
+
const parameters = method.parameters.every((p) => ensureParameter(p, context));
|
|
129623
|
+
return returnType && typeParameters && parameters;
|
|
129624
|
+
}
|
|
129625
|
+
function typeFromObjectLiteralAccessor(accessor, name, context) {
|
|
129626
|
+
const allAccessors = resolver.getAllAccessorDeclarations(accessor);
|
|
129627
|
+
const getAccessorType = allAccessors.getAccessor && getTypeAnnotationFromAccessor2(allAccessors.getAccessor);
|
|
129628
|
+
const setAccessorType = allAccessors.setAccessor && getTypeAnnotationFromAccessor2(allAccessors.setAccessor);
|
|
129629
|
+
if (getAccessorType !== void 0 && setAccessorType !== void 0) {
|
|
129630
|
+
const parameters = accessor.parameters.every((p) => ensureParameter(p, context));
|
|
129631
|
+
if (isGetAccessor(accessor)) {
|
|
129632
|
+
return parameters && serializeExistingTypeAnnotation(getAccessorType);
|
|
129633
|
+
} else {
|
|
129634
|
+
return parameters;
|
|
129635
|
+
}
|
|
129636
|
+
} else if (allAccessors.firstAccessor === accessor) {
|
|
129637
|
+
const foundType = getAccessorType ?? setAccessorType;
|
|
129638
|
+
const propertyType = foundType ? serializeExistingTypeAnnotation(foundType) : inferAccessorType(accessor, allAccessors, context);
|
|
129639
|
+
return propertyType;
|
|
129640
|
+
}
|
|
129641
|
+
return false;
|
|
129642
|
+
}
|
|
129643
|
+
function typeFromPrimitiveLiteral() {
|
|
129644
|
+
return true;
|
|
129645
|
+
}
|
|
129646
|
+
function canAddUndefined(node) {
|
|
129647
|
+
if (!strictNullChecks)
|
|
129648
|
+
return true;
|
|
129649
|
+
if (isKeyword(node.kind) || node.kind === 201 /* LiteralType */ || node.kind === 184 /* FunctionType */ || node.kind === 185 /* ConstructorType */ || node.kind === 188 /* ArrayType */ || node.kind === 189 /* TupleType */ || node.kind === 187 /* TypeLiteral */ || node.kind === 203 /* TemplateLiteralType */ || node.kind === 197 /* ThisType */) {
|
|
129650
|
+
return true;
|
|
129651
|
+
}
|
|
129652
|
+
if (node.kind === 196 /* ParenthesizedType */) {
|
|
129653
|
+
return canAddUndefined(node.type);
|
|
129654
|
+
}
|
|
129655
|
+
if (node.kind === 192 /* UnionType */ || node.kind === 193 /* IntersectionType */) {
|
|
129656
|
+
return node.types.every(canAddUndefined);
|
|
129657
|
+
}
|
|
129658
|
+
return false;
|
|
129659
|
+
}
|
|
129660
|
+
function createReturnFromSignature(fn, context) {
|
|
129661
|
+
let returnType;
|
|
129662
|
+
const returnTypeNode = getEffectiveReturnTypeNode(fn);
|
|
129663
|
+
if (returnTypeNode) {
|
|
129664
|
+
returnType = serializeExistingTypeAnnotation(returnTypeNode);
|
|
129665
|
+
}
|
|
129666
|
+
if (!returnType && isValueSignatureDeclaration(fn)) {
|
|
129667
|
+
returnType = typeFromSingleReturnExpression(fn, context);
|
|
129668
|
+
}
|
|
129669
|
+
return returnType ?? inferReturnTypeOfSignatureSignature(fn, context);
|
|
129670
|
+
}
|
|
129671
|
+
function typeFromSingleReturnExpression(declaration, context) {
|
|
129672
|
+
let candidateExpr;
|
|
129673
|
+
if (declaration && !nodeIsMissing(declaration.body)) {
|
|
129674
|
+
const body = declaration.body;
|
|
129675
|
+
if (body && isBlock(body)) {
|
|
129676
|
+
forEachReturnStatement(body, (s) => {
|
|
129677
|
+
if (!candidateExpr) {
|
|
129678
|
+
candidateExpr = s.expression;
|
|
129679
|
+
} else {
|
|
129680
|
+
candidateExpr = void 0;
|
|
129681
|
+
return true;
|
|
129682
|
+
}
|
|
129683
|
+
});
|
|
129684
|
+
} else {
|
|
129685
|
+
candidateExpr = body;
|
|
129686
|
+
}
|
|
129687
|
+
}
|
|
129688
|
+
if (candidateExpr) {
|
|
129689
|
+
return typeFromExpression(candidateExpr, context);
|
|
129690
|
+
}
|
|
129691
|
+
return void 0;
|
|
129692
|
+
}
|
|
129693
|
+
}
|
|
129694
|
+
|
|
127912
129695
|
// src/tsc/tsc.ts
|
|
127913
129696
|
Debug.loggingHost = {
|
|
127914
129697
|
log(_level, s) {
|