diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3aa4d143a05b8..80115dbd35dab 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -839,12 +839,14 @@ namespace ts { // grammar errors Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement.code, Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement.code, + Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name.code, Diagnostics.A_class_member_cannot_have_the_0_keyword.code, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name.code, Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement.code, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement.code, Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement.code, Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement.code, + Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration.code, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context.code, Diagnostics.A_destructuring_declaration_must_have_an_initializer.code, Diagnostics.A_get_accessor_cannot_have_parameters.code, @@ -855,13 +857,21 @@ namespace ts { Diagnostics.A_rest_parameter_cannot_have_an_initializer.code, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code, Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code, + Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code, + Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code, Diagnostics.A_set_accessor_cannot_have_rest_parameter.code, Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code, + Diagnostics.An_export_declaration_can_only_be_used_in_a_module.code, + Diagnostics.An_export_declaration_cannot_have_modifiers.code, + Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module.code, + Diagnostics.An_import_declaration_cannot_have_modifiers.code, Diagnostics.An_object_member_cannot_be_declared_optional.code, Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code, Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable.code, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause.code, + Diagnostics.Catch_clause_variable_cannot_have_an_initializer.code, Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator.code, + Diagnostics.Classes_can_only_extend_a_single_class.code, Diagnostics.Classes_may_not_have_a_field_named_constructor.code, Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code, Diagnostics.Duplicate_label_0.code, @@ -873,6 +883,7 @@ namespace ts { Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names.code, Diagnostics.Jump_target_cannot_cross_function_boundary.code, Diagnostics.Line_terminator_not_permitted_before_arrow.code, + Diagnostics.Modifiers_cannot_appear_here.code, Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement.code, Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement.code, Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies.code, @@ -897,6 +908,7 @@ namespace ts { Diagnostics._0_modifier_must_precede_1_modifier.code, Diagnostics.const_declarations_can_only_be_declared_inside_a_block.code, Diagnostics.const_declarations_must_be_initialized.code, + Diagnostics.extends_clause_already_seen.code, Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code, ]); diff --git a/tests/baselines/reference/plainJSGrammarErrors.errors.txt b/tests/baselines/reference/plainJSGrammarErrors.errors.txt index 4ae227eeb3a32..fa3affdb840ed 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.errors.txt +++ b/tests/baselines/reference/plainJSGrammarErrors.errors.txt @@ -2,94 +2,108 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(3,9): error TS1451: Privat tests/cases/conformance/salsa/plainJSGrammarErrors.js(5,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression tests/cases/conformance/salsa/plainJSGrammarErrors.js(10,15): error TS2803: Cannot assign to private method '#m'. Private methods are not writable. tests/cases/conformance/salsa/plainJSGrammarErrors.js(14,13): error TS18038: 'For await' loops cannot be used inside a class static block. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(19,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(20,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(21,5): error TS8009: The 'const' modifier can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(21,11): error TS1248: A class member cannot have the 'const' keyword. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(17,9): error TS18041: A 'return' statement cannot be used inside a class static block. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(20,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. tests/cases/conformance/salsa/plainJSGrammarErrors.js(22,5): error TS8009: The 'const' modifier can only be used in TypeScript files. tests/cases/conformance/salsa/plainJSGrammarErrors.js(22,11): error TS1248: A class member cannot have the 'const' keyword. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(25,11): error TS1030: 'async' modifier already seen. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(27,11): error TS1029: 'static' modifier must precede 'async' modifier. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(28,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(28,5): error TS8009: The 'export' modifier can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(23,5): error TS8009: The 'const' modifier can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(23,11): error TS1248: A class member cannot have the 'const' keyword. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(26,11): error TS1030: 'async' modifier already seen. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(28,11): error TS1029: 'static' modifier must precede 'async' modifier. tests/cases/conformance/salsa/plainJSGrammarErrors.js(29,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(33,22): error TS1005: '{' expected. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(34,9): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(35,9): error TS1049: A 'set' accessor must have exactly one parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(29,5): error TS8009: The 'export' modifier can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(30,5): error TS1031: 'export' modifier cannot appear on class elements of this kind. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(34,22): error TS1005: '{' expected. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(35,9): error TS1054: A 'get' accessor cannot have parameters. tests/cases/conformance/salsa/plainJSGrammarErrors.js(36,9): error TS1049: A 'set' accessor must have exactly one parameter. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(37,18): error TS1053: A 'set' accessor cannot have rest parameter. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(40,5): error TS18006: Classes may not have a field named 'constructor'. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(43,1): error TS18016: Private identifiers are not allowed outside class bodies. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(44,6): error TS18016: Private identifiers are not allowed outside class bodies. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(45,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(48,8): error TS1030: 'export' modifier already seen. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(49,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(50,22): error TS1090: 'static' modifier cannot appear on a parameter. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(50,22): error TS8012: Parameter modifiers can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(51,7): error TS1029: 'export' modifier must precede 'async' modifier. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(52,26): error TS1090: 'export' modifier cannot appear on a parameter. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(52,26): error TS8012: Parameter modifiers can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(53,25): error TS1090: 'async' modifier cannot appear on a parameter. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(53,25): error TS8012: Parameter modifiers can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(54,7): error TS1030: 'async' modifier already seen. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(55,1): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,5): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,5): error TS8009: The 'async' modifier can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(58,1): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(59,1): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(60,1): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(63,25): error TS1014: A rest parameter must be last in a parameter list. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(65,37): error TS1048: A rest parameter cannot have an initializer. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(67,41): error TS1013: A rest parameter or binding pattern may not have a trailing comma. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(69,8): error TS2501: A rest element cannot contain a binding pattern. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(71,12): error TS2462: A rest element must be last in a destructuring pattern. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(72,33): error TS2566: A rest element cannot have a property name. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(73,42): error TS1186: A rest element cannot have an initializer. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(76,4): error TS1123: Variable declaration list cannot be empty. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(77,9): error TS5076: '||' and '??' operations cannot be mixed without parentheses. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(78,14): error TS5076: '||' and '??' operations cannot be mixed without parentheses. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(80,3): error TS1200: Line terminator not permitted before arrow. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(82,4): error TS1358: Tagged template expressions are not permitted in an optional chain. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(84,6): error TS1171: A comma expression is not allowed in a computed property name. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(85,5): error TS18016: Private identifiers are not allowed outside class bodies. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(86,5): error TS1042: 'export' modifier cannot be used here. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(88,25): error TS1162: An object member cannot be declared optional. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(89,6): error TS1162: An object member cannot be declared optional. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(89,6): error TS8009: The '?' modifier can only be used in TypeScript files. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(90,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(91,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(94,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(96,24): error TS1009: Trailing comma not allowed. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(97,29): error TS1097: 'extends' list cannot be empty. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(100,7): error TS1182: A destructuring declaration must have an initializer. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(101,7): error TS1155: 'const' declarations must be initialized. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(102,5): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(102,5): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(104,5): error TS1157: 'let' declarations can only be declared inside a block. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(106,5): error TS1156: 'const' declarations can only be declared inside a block. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(111,6): error TS1106: The left-hand side of a 'for...of' statement may not be 'async'. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(114,12): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(117,12): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(120,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(123,13): error TS1091: Only a single variable declaration is allowed in a 'for...in' statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(134,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(141,11): error TS2492: Cannot redeclare identifier 'e' in catch clause. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(145,5): error TS1114: Duplicate label 'label'. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(154,13): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(162,13): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(166,5): error TS1107: Jump target cannot cross function boundary. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(169,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(170,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(172,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(173,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -tests/cases/conformance/salsa/plainJSGrammarErrors.js(176,28): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/salsa/plainJSGrammarErrors.js(177,22): error TS17012: 'targe' is not a valid meta-property for keyword 'new'. Did you mean 'target'? -tests/cases/conformance/salsa/plainJSGrammarErrors.js(178,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments -tests/cases/conformance/salsa/plainJSGrammarErrors.js(179,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments -tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Argument of dynamic import cannot be spread element. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(37,9): error TS1049: A 'set' accessor must have exactly one parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(38,18): error TS1053: A 'set' accessor cannot have rest parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(41,5): error TS18006: Classes may not have a field named 'constructor'. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(43,1): error TS1211: A class declaration without the 'default' modifier must have a name. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(46,25): error TS1172: 'extends' clause already seen. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(47,25): error TS1174: Classes can only extend a single class. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(49,1): error TS18016: Private identifiers are not allowed outside class bodies. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(50,6): error TS18016: Private identifiers are not allowed outside class bodies. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(51,9): error TS18013: Property '#m' is not accessible outside class 'C' because it has a private identifier. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(54,8): error TS1030: 'export' modifier already seen. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(55,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,22): error TS1090: 'static' modifier cannot appear on a parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(56,22): error TS8012: Parameter modifiers can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(57,7): error TS1029: 'export' modifier must precede 'async' modifier. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(58,26): error TS1090: 'export' modifier cannot appear on a parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(58,26): error TS8012: Parameter modifiers can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(59,25): error TS1090: 'async' modifier cannot appear on a parameter. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(59,25): error TS8012: Parameter modifiers can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(60,7): error TS1030: 'async' modifier already seen. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(61,1): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(62,5): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(62,5): error TS8009: The 'async' modifier can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(64,1): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(65,1): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(66,1): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(67,1): error TS1191: An import declaration cannot have modifiers. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(68,1): error TS1193: An export declaration cannot have modifiers. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(70,5): error TS1233: An export declaration can only be used in a module. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(71,5): error TS1232: An import declaration can only be used in a namespace or module. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(72,5): error TS1258: A default export must be at the top level of a file or module declaration. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(75,5): error TS1184: Modifiers cannot appear here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(78,5): error TS1042: 'static' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(78,5): error TS1184: Modifiers cannot appear here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(83,25): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(85,37): error TS1048: A rest parameter cannot have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(87,41): error TS1013: A rest parameter or binding pattern may not have a trailing comma. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(89,8): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(91,12): error TS2462: A rest element must be last in a destructuring pattern. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(92,33): error TS2566: A rest element cannot have a property name. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(93,42): error TS1186: A rest element cannot have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(96,4): error TS1123: Variable declaration list cannot be empty. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(97,9): error TS5076: '||' and '??' operations cannot be mixed without parentheses. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(98,14): error TS5076: '||' and '??' operations cannot be mixed without parentheses. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(100,3): error TS1200: Line terminator not permitted before arrow. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(102,4): error TS1358: Tagged template expressions are not permitted in an optional chain. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(104,6): error TS1171: A comma expression is not allowed in a computed property name. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(105,5): error TS18016: Private identifiers are not allowed outside class bodies. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(106,5): error TS1042: 'export' modifier cannot be used here. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(108,25): error TS1162: An object member cannot be declared optional. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(109,6): error TS1162: An object member cannot be declared optional. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(109,6): error TS8009: The '?' modifier can only be used in TypeScript files. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(110,15): error TS1255: A definite assignment assertion '!' is not permitted in this context. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(111,19): error TS1255: A definite assignment assertion '!' is not permitted in this context. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(114,16): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(116,24): error TS1009: Trailing comma not allowed. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(117,29): error TS1097: 'extends' list cannot be empty. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(120,7): error TS1182: A destructuring declaration must have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(121,7): error TS1155: 'const' declarations must be initialized. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(122,5): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(122,5): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(124,5): error TS1157: 'let' declarations can only be declared inside a block. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(126,5): error TS1156: 'const' declarations can only be declared inside a block. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(131,6): error TS1106: The left-hand side of a 'for...of' statement may not be 'async'. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(134,12): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(137,12): error TS1189: The variable declaration of a 'for...in' statement cannot have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(140,13): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(143,13): error TS1091: Only a single variable declaration is allowed in a 'for...in' statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(154,5): error TS1113: A 'default' clause cannot appear more than once in a 'switch' statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(161,11): error TS2492: Cannot redeclare identifier 'e' in catch clause. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(167,12): error TS1197: Catch clause variable cannot have an initializer. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(170,5): error TS1114: Duplicate label 'label'. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(179,13): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(187,13): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(191,5): error TS1107: Jump target cannot cross function boundary. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(194,5): error TS1116: A 'break' statement can only jump to a label of an enclosing statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(195,5): error TS1115: A 'continue' statement can only jump to a label of an enclosing iteration statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(197,1): error TS1105: A 'break' statement can only be used within an enclosing iteration or switch statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(198,1): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(201,28): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? +tests/cases/conformance/salsa/plainJSGrammarErrors.js(202,22): error TS17012: 'targe' is not a valid meta-property for keyword 'new'. Did you mean 'target'? +tests/cases/conformance/salsa/plainJSGrammarErrors.js(203,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments +tests/cases/conformance/salsa/plainJSGrammarErrors.js(204,30): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments +tests/cases/conformance/salsa/plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot be spread element. +tests/cases/conformance/salsa/plainJSGrammarErrors.js(207,1): error TS1108: A 'return' statement can only be used within a function body. -==== tests/cases/conformance/salsa/plainJSGrammarErrors.js (89 errors) ==== +==== tests/cases/conformance/salsa/plainJSGrammarErrors.js (103 errors) ==== class C { // #private mistakes q = #unbound @@ -114,6 +128,9 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Arg !!! error TS18038: 'For await' loops cannot be used inside a class static block. console.log(x) } + return null + ~~~~~~ +!!! error TS18041: A 'return' statement cannot be used inside a class static block. } // modifier mistakes static constructor() { } @@ -173,6 +190,17 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Arg ~~~~~~~~~~~~~ !!! error TS18006: Classes may not have a field named 'constructor'. } + class { + ~~~~~ +!!! error TS1211: A class declaration without the 'default' modifier must have a name. + missingName = true + } + class Doubler extends C extends C { } + ~~~~~~~ +!!! error TS1172: 'extends' clause already seen. + class Trebler extends C,C,C { } + ~ +!!! error TS1174: Classes can only extend a single class. // #private mistakes #unrelated ~~~~~~~~~~ @@ -230,6 +258,36 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Arg async export { CantAsyncClass } ~~~~~ !!! error TS1042: 'async' modifier cannot be used here. + export import 'fs' + ~~~~~~ +!!! error TS1191: An import declaration cannot have modifiers. + export export { C } + ~~~~~~ +!!! error TS1193: An export declaration cannot have modifiers. + function nestedExports() { + export { staticParam } + ~~~~~~ +!!! error TS1233: An export declaration can only be used in a module. + import 'fs' + ~~~~~~ +!!! error TS1232: An import declaration can only be used in a namespace or module. + export default 12 + ~~~~~~ +!!! error TS1258: A default export must be at the top level of a file or module declaration. + } + function outerStaticFunction() { + static function staticFunction() { } + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + const noStaticLiteralMethods = { + static m() { + ~~~~~~ +!!! error TS1042: 'static' modifier cannot be used here. + ~~~~~~ +!!! error TS1184: Modifiers cannot appear here. + } + } // rest parameters function restMustBeLast(...x, y) { @@ -385,6 +443,13 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Arg !!! error TS2492: Cannot redeclare identifier 'e' in catch clause. console.log(e) } + try { + throw 20 + } + catch (e = 0) { + ~ +!!! error TS1197: Catch clause variable cannot have an initializer. + } label: for (const x in [1,2,3]) { label: for (const y in [1,2,3]) { ~~~~~ @@ -448,4 +513,8 @@ tests/cases/conformance/salsa/plainJSGrammarErrors.js(180,36): error TS1325: Arg const spreadDynamicImport = import(...[]) ~~~~~ !!! error TS1325: Argument of dynamic import cannot be spread element. + + return + ~~~~~~ +!!! error TS1108: A 'return' statement can only be used within a function body. \ No newline at end of file diff --git a/tests/baselines/reference/plainJSGrammarErrors.js b/tests/baselines/reference/plainJSGrammarErrors.js index dbdfb17a8ee81..4dcf2472ac61d 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.js +++ b/tests/baselines/reference/plainJSGrammarErrors.js @@ -15,6 +15,7 @@ class C { for await (const x of [1,2,3]) { console.log(x) } + return null } // modifier mistakes static constructor() { } @@ -40,6 +41,11 @@ class C { // other "constructor" = 16 } +class { + missingName = true +} +class Doubler extends C extends C { } +class Trebler extends C,C,C { } // #private mistakes #unrelated junk.#m @@ -59,6 +65,20 @@ async class CantAsyncClass { async const cantAsyncConst = 2 async import 'assert' async export { CantAsyncClass } +export import 'fs' +export export { C } +function nestedExports() { + export { staticParam } + import 'fs' + export default 12 +} +function outerStaticFunction() { + static function staticFunction() { } +} +const noStaticLiteralMethods = { + static m() { + } +} // rest parameters function restMustBeLast(...x, y) { @@ -142,6 +162,11 @@ catch (e) { const e = 1 console.log(e) } +try { + throw 20 +} +catch (e = 0) { +} label: for (const x in [1,2,3]) { label: for (const y in [1,2,3]) { break label; @@ -179,6 +204,8 @@ function foo() { new.targe } const nullaryDynamicImport = import() const trinaryDynamicImport = import('1', '2', '3') const spreadDynamicImport = import(...[]) + +return //// [plainJSGrammarErrors.js] @@ -198,6 +225,7 @@ class C { for await (const x of [1, 2, 3]) { console.log(x); } + return null; } // modifier mistakes static constructor() { } @@ -221,6 +249,13 @@ class C { // other "constructor" = 16; } +class { + missingName = true; +} +class Doubler extends C extends C { +} +class Trebler extends C, C, C { +} // #private mistakes #unrelated; junk.#m; @@ -239,6 +274,20 @@ async class CantAsyncClass { async const cantAsyncConst = 2; async import 'assert'; export { CantAsyncClass }; +export import 'fs'; +export { C }; +function nestedExports() { + export { staticParam }; + import 'fs'; + export default 12; +} +function outerStaticFunction() { + static function staticFunction() { } +} +const noStaticLiteralMethods = { + static m() { + } +}; // rest parameters function restMustBeLast(...x, y) { } @@ -318,6 +367,11 @@ catch (e) { const e = 1; console.log(e); } +try { + throw 20; +} +catch (e = 0) { +} label: for (const x in [1, 2, 3]) { label: for (const y in [1, 2, 3]) { break label; @@ -353,3 +407,4 @@ function foo() { new.targe; } const nullaryDynamicImport = import(); const trinaryDynamicImport = import('1', '2', '3'); const spreadDynamicImport = import(...[]); +return; diff --git a/tests/baselines/reference/plainJSGrammarErrors.symbols b/tests/baselines/reference/plainJSGrammarErrors.symbols index ff6a479f8e59f..cc3420d34f985 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.symbols +++ b/tests/baselines/reference/plainJSGrammarErrors.symbols @@ -32,55 +32,71 @@ class C { >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >x : Symbol(x, Decl(plainJSGrammarErrors.js, 13, 24)) } + return null } // modifier mistakes static constructor() { } async constructor() { } const x = 1 ->x : Symbol(C.x, Decl(plainJSGrammarErrors.js, 19, 27)) +>x : Symbol(C.x, Decl(plainJSGrammarErrors.js, 20, 27)) const y() { ->y : Symbol(C.y, Decl(plainJSGrammarErrors.js, 20, 15)) +>y : Symbol(C.y, Decl(plainJSGrammarErrors.js, 21, 15)) return 12 } async async extremelyAsync() { ->extremelyAsync : Symbol(C.extremelyAsync, Decl(plainJSGrammarErrors.js, 23, 5)) +>extremelyAsync : Symbol(C.extremelyAsync, Decl(plainJSGrammarErrors.js, 24, 5)) } async static oorder(){ } ->oorder : Symbol(C.oorder, Decl(plainJSGrammarErrors.js, 25, 5)) +>oorder : Symbol(C.oorder, Decl(plainJSGrammarErrors.js, 26, 5)) export cantExportProperty = 1 ->cantExportProperty : Symbol(C.cantExportProperty, Decl(plainJSGrammarErrors.js, 26, 28)) +>cantExportProperty : Symbol(C.cantExportProperty, Decl(plainJSGrammarErrors.js, 27, 28)) export cantExportMethod() { ->cantExportMethod : Symbol(C.cantExportMethod, Decl(plainJSGrammarErrors.js, 27, 33)) +>cantExportMethod : Symbol(C.cantExportMethod, Decl(plainJSGrammarErrors.js, 28, 33)) } // accessor mistakes get incorporeal(); ->incorporeal : Symbol(C.incorporeal, Decl(plainJSGrammarErrors.js, 29, 5)) +>incorporeal : Symbol(C.incorporeal, Decl(plainJSGrammarErrors.js, 30, 5)) get parametric(n) { return 1 } ->parametric : Symbol(C.parametric, Decl(plainJSGrammarErrors.js, 32, 22)) ->n : Symbol(n, Decl(plainJSGrammarErrors.js, 33, 19)) +>parametric : Symbol(C.parametric, Decl(plainJSGrammarErrors.js, 33, 22)) +>n : Symbol(n, Decl(plainJSGrammarErrors.js, 34, 19)) set invariant() { } ->invariant : Symbol(C.invariant, Decl(plainJSGrammarErrors.js, 33, 34)) +>invariant : Symbol(C.invariant, Decl(plainJSGrammarErrors.js, 34, 34)) set binary(fst, snd) { } ->binary : Symbol(C.binary, Decl(plainJSGrammarErrors.js, 34, 23)) ->fst : Symbol(fst, Decl(plainJSGrammarErrors.js, 35, 15)) ->snd : Symbol(snd, Decl(plainJSGrammarErrors.js, 35, 19)) +>binary : Symbol(C.binary, Decl(plainJSGrammarErrors.js, 35, 23)) +>fst : Symbol(fst, Decl(plainJSGrammarErrors.js, 36, 15)) +>snd : Symbol(snd, Decl(plainJSGrammarErrors.js, 36, 19)) set variable(...n) { } ->variable : Symbol(C.variable, Decl(plainJSGrammarErrors.js, 35, 28)) ->n : Symbol(n, Decl(plainJSGrammarErrors.js, 36, 17)) +>variable : Symbol(C.variable, Decl(plainJSGrammarErrors.js, 36, 28)) +>n : Symbol(n, Decl(plainJSGrammarErrors.js, 37, 17)) // other "constructor" = 16 ->"constructor" : Symbol(C["constructor"], Decl(plainJSGrammarErrors.js, 36, 26)) +>"constructor" : Symbol(C["constructor"], Decl(plainJSGrammarErrors.js, 37, 26)) } +class { + missingName = true +>missingName : Symbol(__missing.missingName, Decl(plainJSGrammarErrors.js, 42, 7)) +} +class Doubler extends C extends C { } +>Doubler : Symbol(Doubler, Decl(plainJSGrammarErrors.js, 44, 1)) +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0)) +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0)) + +class Trebler extends C,C,C { } +>Trebler : Symbol(Trebler, Decl(plainJSGrammarErrors.js, 45, 37)) +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0)) +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0)) +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 0, 0)) + // #private mistakes #unrelated junk.#m @@ -89,234 +105,261 @@ new C().#m // modifier mistakes export export var extremelyExported = 10 ->extremelyExported : Symbol(extremelyExported, Decl(plainJSGrammarErrors.js, 47, 17)) +>extremelyExported : Symbol(extremelyExported, Decl(plainJSGrammarErrors.js, 53, 17)) export static var staticExport = 1 ->staticExport : Symbol(staticExport, Decl(plainJSGrammarErrors.js, 48, 17)) +>staticExport : Symbol(staticExport, Decl(plainJSGrammarErrors.js, 54, 17)) function staticParam(static x = 1) { return x } ->staticParam : Symbol(staticParam, Decl(plainJSGrammarErrors.js, 48, 34)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 49, 21)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 49, 21)) +>staticParam : Symbol(staticParam, Decl(plainJSGrammarErrors.js, 54, 34)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 55, 21)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 55, 21)) async export function oorder(x = 1) { return x } ->oorder : Symbol(oorder, Decl(plainJSGrammarErrors.js, 49, 47)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 50, 29)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 50, 29)) +>oorder : Symbol(oorder, Decl(plainJSGrammarErrors.js, 55, 47)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 56, 29)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 56, 29)) function cantExportParam(export x = 1) { return x } ->cantExportParam : Symbol(cantExportParam, Decl(plainJSGrammarErrors.js, 50, 48)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 51, 25)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 51, 25)) +>cantExportParam : Symbol(cantExportParam, Decl(plainJSGrammarErrors.js, 56, 48)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 57, 25)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 57, 25)) function cantAsyncParam(async x = 1) { return x } ->cantAsyncParam : Symbol(cantAsyncParam, Decl(plainJSGrammarErrors.js, 51, 51)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 52, 24)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 52, 24)) +>cantAsyncParam : Symbol(cantAsyncParam, Decl(plainJSGrammarErrors.js, 57, 51)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 58, 24)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 58, 24)) async async function extremelyAsync() {} ->extremelyAsync : Symbol(extremelyAsync, Decl(plainJSGrammarErrors.js, 52, 49)) +>extremelyAsync : Symbol(extremelyAsync, Decl(plainJSGrammarErrors.js, 58, 49)) async class CantAsyncClass { ->CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 53, 40)) +>CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 59, 40)) async cantAsyncPropert = 1 ->cantAsyncPropert : Symbol(CantAsyncClass.cantAsyncPropert, Decl(plainJSGrammarErrors.js, 54, 28)) +>cantAsyncPropert : Symbol(CantAsyncClass.cantAsyncPropert, Decl(plainJSGrammarErrors.js, 60, 28)) } async const cantAsyncConst = 2 ->cantAsyncConst : Symbol(cantAsyncConst, Decl(plainJSGrammarErrors.js, 57, 11)) +>cantAsyncConst : Symbol(cantAsyncConst, Decl(plainJSGrammarErrors.js, 63, 11)) async import 'assert' async export { CantAsyncClass } ->CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 59, 14)) +>CantAsyncClass : Symbol(CantAsyncClass, Decl(plainJSGrammarErrors.js, 65, 14)) + +export import 'fs' +export export { C } +>C : Symbol(C, Decl(plainJSGrammarErrors.js, 67, 15)) + +function nestedExports() { +>nestedExports : Symbol(nestedExports, Decl(plainJSGrammarErrors.js, 67, 19)) + + export { staticParam } +>staticParam : Symbol(staticParam, Decl(plainJSGrammarErrors.js, 69, 12)) + + import 'fs' + export default 12 +} +function outerStaticFunction() { +>outerStaticFunction : Symbol(outerStaticFunction, Decl(plainJSGrammarErrors.js, 72, 1)) + + static function staticFunction() { } +>staticFunction : Symbol(staticFunction, Decl(plainJSGrammarErrors.js, 73, 32)) +} +const noStaticLiteralMethods = { +>noStaticLiteralMethods : Symbol(noStaticLiteralMethods, Decl(plainJSGrammarErrors.js, 76, 5)) + + static m() { +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 76, 32)) + } +} // rest parameters function restMustBeLast(...x, y) { ->restMustBeLast : Symbol(restMustBeLast, Decl(plainJSGrammarErrors.js, 59, 31)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 62, 24)) ->y : Symbol(y, Decl(plainJSGrammarErrors.js, 62, 29)) +>restMustBeLast : Symbol(restMustBeLast, Decl(plainJSGrammarErrors.js, 79, 1)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 82, 24)) +>y : Symbol(y, Decl(plainJSGrammarErrors.js, 82, 29)) } function restCantHaveInitialiser(...x = [1,2,3]) { ->restCantHaveInitialiser : Symbol(restCantHaveInitialiser, Decl(plainJSGrammarErrors.js, 63, 1)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 64, 33)) +>restCantHaveInitialiser : Symbol(restCantHaveInitialiser, Decl(plainJSGrammarErrors.js, 83, 1)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 84, 33)) } function restCantHaveTrailingComma (...x,) { ->restCantHaveTrailingComma : Symbol(restCantHaveTrailingComma, Decl(plainJSGrammarErrors.js, 65, 1)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 66, 36)) +>restCantHaveTrailingComma : Symbol(restCantHaveTrailingComma, Decl(plainJSGrammarErrors.js, 85, 1)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 86, 36)) } ;({ ...{} } = {}) const doom = { e: 1, m: 1, name: "knee-deep" } ->doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5)) ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14)) ->m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20)) ->name : Symbol(name, Decl(plainJSGrammarErrors.js, 69, 26)) +>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 89, 5)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 89, 14)) +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 89, 20)) +>name : Symbol(name, Decl(plainJSGrammarErrors.js, 89, 26)) const { ...rest, e: episode, m: mission } = doom ->rest : Symbol(rest, Decl(plainJSGrammarErrors.js, 70, 7)) ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14)) ->episode : Symbol(episode, Decl(plainJSGrammarErrors.js, 70, 16)) ->m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20)) ->mission : Symbol(mission, Decl(plainJSGrammarErrors.js, 70, 28)) ->doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5)) +>rest : Symbol(rest, Decl(plainJSGrammarErrors.js, 90, 7)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 89, 14)) +>episode : Symbol(episode, Decl(plainJSGrammarErrors.js, 90, 16)) +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 89, 20)) +>mission : Symbol(mission, Decl(plainJSGrammarErrors.js, 90, 28)) +>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 89, 5)) const { e: eep, m: em, ...rest: noRestAllowed } = doom ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14)) ->eep : Symbol(eep, Decl(plainJSGrammarErrors.js, 71, 7)) ->m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20)) ->em : Symbol(em, Decl(plainJSGrammarErrors.js, 71, 15)) ->noRestAllowed : Symbol(noRestAllowed, Decl(plainJSGrammarErrors.js, 71, 22)) ->doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 89, 14)) +>eep : Symbol(eep, Decl(plainJSGrammarErrors.js, 91, 7)) +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 89, 20)) +>em : Symbol(em, Decl(plainJSGrammarErrors.js, 91, 15)) +>noRestAllowed : Symbol(noRestAllowed, Decl(plainJSGrammarErrors.js, 91, 22)) +>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 89, 5)) const { e: erp, m: erm, ...noInitialiser = true } = doom ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 69, 14)) ->erp : Symbol(erp, Decl(plainJSGrammarErrors.js, 72, 7)) ->m : Symbol(m, Decl(plainJSGrammarErrors.js, 69, 20)) ->erm : Symbol(erm, Decl(plainJSGrammarErrors.js, 72, 15)) ->noInitialiser : Symbol(noInitialiser, Decl(plainJSGrammarErrors.js, 72, 23)) ->doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 69, 5)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 89, 14)) +>erp : Symbol(erp, Decl(plainJSGrammarErrors.js, 92, 7)) +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 89, 20)) +>erm : Symbol(erm, Decl(plainJSGrammarErrors.js, 92, 15)) +>noInitialiser : Symbol(noInitialiser, Decl(plainJSGrammarErrors.js, 92, 23)) +>doom : Symbol(doom, Decl(plainJSGrammarErrors.js, 89, 5)) // left-over parsing var; var x = 1 || 2 ?? 3 ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 96, 3), Decl(plainJSGrammarErrors.js, 97, 3)) var x = 2 ?? 3 || 4 ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 96, 3), Decl(plainJSGrammarErrors.js, 97, 3)) const arr = x ->arr : Symbol(arr, Decl(plainJSGrammarErrors.js, 78, 5)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 78, 11)) +>arr : Symbol(arr, Decl(plainJSGrammarErrors.js, 98, 5)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 98, 11)) => x + 1 ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 78, 11)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 98, 11)) var a = [1,2] ->a : Symbol(a, Decl(plainJSGrammarErrors.js, 80, 3)) +>a : Symbol(a, Decl(plainJSGrammarErrors.js, 100, 3)) a?.`length`; ->a : Symbol(a, Decl(plainJSGrammarErrors.js, 80, 3)) +>a : Symbol(a, Decl(plainJSGrammarErrors.js, 100, 3)) const o = { ->o : Symbol(o, Decl(plainJSGrammarErrors.js, 82, 5)) +>o : Symbol(o, Decl(plainJSGrammarErrors.js, 102, 5)) [console.log('oh no'),2]: 'hi', ->[console.log('oh no'),2] : Symbol([console.log('oh no'),2], Decl(plainJSGrammarErrors.js, 82, 11)) +>[console.log('oh no'),2] : Symbol([console.log('oh no'),2], Decl(plainJSGrammarErrors.js, 102, 11)) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) #noPrivate: 3, ->#noPrivate : Symbol(#noPrivate, Decl(plainJSGrammarErrors.js, 83, 35)) +>#noPrivate : Symbol(#noPrivate, Decl(plainJSGrammarErrors.js, 103, 35)) export cantExportProperties: 4, ->cantExportProperties : Symbol(cantExportProperties, Decl(plainJSGrammarErrors.js, 84, 18)) +>cantExportProperties : Symbol(cantExportProperties, Decl(plainJSGrammarErrors.js, 104, 18)) // TODO: See what the existing JS error is like for these cantHaveQuestionMark?: 1, ->cantHaveQuestionMark : Symbol(cantHaveQuestionMark, Decl(plainJSGrammarErrors.js, 85, 35)) +>cantHaveQuestionMark : Symbol(cantHaveQuestionMark, Decl(plainJSGrammarErrors.js, 105, 35)) m?() { return 12 }, ->m : Symbol(m, Decl(plainJSGrammarErrors.js, 87, 29)) +>m : Symbol(m, Decl(plainJSGrammarErrors.js, 107, 29)) definitely!, ->definitely : Symbol(definitely, Decl(plainJSGrammarErrors.js, 88, 23)) +>definitely : Symbol(definitely, Decl(plainJSGrammarErrors.js, 108, 23)) definiteMethod!() { return 13 }, ->definiteMethod : Symbol(definiteMethod, Decl(plainJSGrammarErrors.js, 89, 16)) +>definiteMethod : Symbol(definiteMethod, Decl(plainJSGrammarErrors.js, 109, 16)) } const noAssignment = { ->noAssignment : Symbol(noAssignment, Decl(plainJSGrammarErrors.js, 92, 5)) +>noAssignment : Symbol(noAssignment, Decl(plainJSGrammarErrors.js, 112, 5)) assignment = 1, ->assignment : Symbol(assignment, Decl(plainJSGrammarErrors.js, 92, 22)) +>assignment : Symbol(assignment, Decl(plainJSGrammarErrors.js, 112, 22)) } var noTrailingComma = 1,; ->noTrailingComma : Symbol(noTrailingComma, Decl(plainJSGrammarErrors.js, 95, 3)) +>noTrailingComma : Symbol(noTrailingComma, Decl(plainJSGrammarErrors.js, 115, 3)) class MissingExtends extends { } ->MissingExtends : Symbol(MissingExtends, Decl(plainJSGrammarErrors.js, 95, 25)) +>MissingExtends : Symbol(MissingExtends, Decl(plainJSGrammarErrors.js, 115, 25)) // let/const mistakes const { e: ee }; >e : Symbol(e) ->ee : Symbol(ee, Decl(plainJSGrammarErrors.js, 99, 7)) +>ee : Symbol(ee, Decl(plainJSGrammarErrors.js, 119, 7)) const noInit; ->noInit : Symbol(noInit, Decl(plainJSGrammarErrors.js, 100, 5)) +>noInit : Symbol(noInit, Decl(plainJSGrammarErrors.js, 120, 5)) let let = 15; ->let : Symbol(let, Decl(plainJSGrammarErrors.js, 101, 3)) +>let : Symbol(let, Decl(plainJSGrammarErrors.js, 121, 3)) if (true) let onlyBlockLet = 17; ->onlyBlockLet : Symbol(onlyBlockLet, Decl(plainJSGrammarErrors.js, 103, 7)) +>onlyBlockLet : Symbol(onlyBlockLet, Decl(plainJSGrammarErrors.js, 123, 7)) if (true) const onlyBlockConst = 18; ->onlyBlockConst : Symbol(onlyBlockConst, Decl(plainJSGrammarErrors.js, 105, 9)) +>onlyBlockConst : Symbol(onlyBlockConst, Decl(plainJSGrammarErrors.js, 125, 9)) // loop mistakes let async ->async : Symbol(async, Decl(plainJSGrammarErrors.js, 108, 3)) +>async : Symbol(async, Decl(plainJSGrammarErrors.js, 128, 3)) export const l = [1,2,3] ->l : Symbol(l, Decl(plainJSGrammarErrors.js, 109, 12)) +>l : Symbol(l, Decl(plainJSGrammarErrors.js, 129, 12)) for (async of l) { ->async : Symbol(async, Decl(plainJSGrammarErrors.js, 108, 3)) ->l : Symbol(l, Decl(plainJSGrammarErrors.js, 109, 12)) +>async : Symbol(async, Decl(plainJSGrammarErrors.js, 128, 3)) +>l : Symbol(l, Decl(plainJSGrammarErrors.js, 129, 12)) console.log(x) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 76, 3), Decl(plainJSGrammarErrors.js, 77, 3)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 96, 3), Decl(plainJSGrammarErrors.js, 97, 3)) } for (const cantHaveInit = 1 of [1,2,3]) { ->cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 113, 10)) +>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 133, 10)) console.log(cantHaveInit) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 113, 10)) +>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 133, 10)) } for (const cantHaveInit = 1 in [1,2,3]) { ->cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 116, 10)) +>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 136, 10)) console.log(cantHaveInit) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 116, 10)) +>cantHaveInit : Symbol(cantHaveInit, Decl(plainJSGrammarErrors.js, 136, 10)) } for (let y, x of [1,2,3]) { ->y : Symbol(y, Decl(plainJSGrammarErrors.js, 119, 8)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 119, 11)) +>y : Symbol(y, Decl(plainJSGrammarErrors.js, 139, 8)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 139, 11)) console.log(x) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 119, 11)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 139, 11)) } for (let y, x in [1,2,3]) { ->y : Symbol(y, Decl(plainJSGrammarErrors.js, 122, 8)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 122, 11)) +>y : Symbol(y, Decl(plainJSGrammarErrors.js, 142, 8)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 142, 11)) console.log(x) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 122, 11)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 142, 11)) } // duplication mistakes var b ->b : Symbol(b, Decl(plainJSGrammarErrors.js, 127, 3)) +>b : Symbol(b, Decl(plainJSGrammarErrors.js, 147, 3)) switch (b) { ->b : Symbol(b, Decl(plainJSGrammarErrors.js, 127, 3)) +>b : Symbol(b, Decl(plainJSGrammarErrors.js, 147, 3)) case false: console.log('no') @@ -340,22 +383,28 @@ try { throw 2 } catch (e) { ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 139, 7)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 159, 7)) const e = 1 ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 140, 9)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 160, 9)) console.log(e) >console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) ->e : Symbol(e, Decl(plainJSGrammarErrors.js, 140, 9)) +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 160, 9)) +} +try { + throw 20 +} +catch (e = 0) { +>e : Symbol(e, Decl(plainJSGrammarErrors.js, 166, 7)) } label: for (const x in [1,2,3]) { ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 143, 17)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 168, 17)) label: for (const y in [1,2,3]) { ->y : Symbol(y, Decl(plainJSGrammarErrors.js, 144, 21)) +>y : Symbol(y, Decl(plainJSGrammarErrors.js, 169, 21)) break label; } @@ -363,32 +412,32 @@ label: for (const x in [1,2,3]) { // labels function crossFunctionBoundary() { ->crossFunctionBoundary : Symbol(crossFunctionBoundary, Decl(plainJSGrammarErrors.js, 147, 1)) +>crossFunctionBoundary : Symbol(crossFunctionBoundary, Decl(plainJSGrammarErrors.js, 172, 1)) outer: for(;;) { function test() { ->test : Symbol(test, Decl(plainJSGrammarErrors.js, 151, 20)) +>test : Symbol(test, Decl(plainJSGrammarErrors.js, 176, 20)) break outer } test() ->test : Symbol(test, Decl(plainJSGrammarErrors.js, 151, 20)) +>test : Symbol(test, Decl(plainJSGrammarErrors.js, 176, 20)) } } function continueIterationOnly(x) { ->continueIterationOnly : Symbol(continueIterationOnly, Decl(plainJSGrammarErrors.js, 157, 1)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 158, 31)) +>continueIterationOnly : Symbol(continueIterationOnly, Decl(plainJSGrammarErrors.js, 182, 1)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 183, 31)) outer: switch (x) { ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 158, 31)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 183, 31)) case 1: continue outer } } function jumpToLabelOnly(x) { ->jumpToLabelOnly : Symbol(jumpToLabelOnly, Decl(plainJSGrammarErrors.js, 163, 1)) ->x : Symbol(x, Decl(plainJSGrammarErrors.js, 164, 25)) +>jumpToLabelOnly : Symbol(jumpToLabelOnly, Decl(plainJSGrammarErrors.js, 188, 1)) +>x : Symbol(x, Decl(plainJSGrammarErrors.js, 189, 25)) break jumpToLabelOnly } @@ -401,19 +450,21 @@ continue // other weirdness export let noMeta = import.metal ->noMeta : Symbol(noMeta, Decl(plainJSGrammarErrors.js, 175, 10)) +>noMeta : Symbol(noMeta, Decl(plainJSGrammarErrors.js, 200, 10)) function foo() { new.targe } ->foo : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32)) ->new.targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32)) ->targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 175, 32)) +>foo : Symbol(foo, Decl(plainJSGrammarErrors.js, 200, 32)) +>new.targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 200, 32)) +>targe : Symbol(foo, Decl(plainJSGrammarErrors.js, 200, 32)) const nullaryDynamicImport = import() ->nullaryDynamicImport : Symbol(nullaryDynamicImport, Decl(plainJSGrammarErrors.js, 177, 5)) +>nullaryDynamicImport : Symbol(nullaryDynamicImport, Decl(plainJSGrammarErrors.js, 202, 5)) const trinaryDynamicImport = import('1', '2', '3') ->trinaryDynamicImport : Symbol(trinaryDynamicImport, Decl(plainJSGrammarErrors.js, 178, 5)) +>trinaryDynamicImport : Symbol(trinaryDynamicImport, Decl(plainJSGrammarErrors.js, 203, 5)) const spreadDynamicImport = import(...[]) ->spreadDynamicImport : Symbol(spreadDynamicImport, Decl(plainJSGrammarErrors.js, 179, 5)) +>spreadDynamicImport : Symbol(spreadDynamicImport, Decl(plainJSGrammarErrors.js, 204, 5)) + +return diff --git a/tests/baselines/reference/plainJSGrammarErrors.types b/tests/baselines/reference/plainJSGrammarErrors.types index f279390bbb83a..0d9a941af369b 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.types +++ b/tests/baselines/reference/plainJSGrammarErrors.types @@ -41,6 +41,8 @@ class C { >log : (...data: any[]) => void >x : number } + return null +>null : null } // modifier mistakes static constructor() { } @@ -95,6 +97,22 @@ class C { >"constructor" : number >16 : 16 } +class { + missingName = true +>missingName : boolean +>true : true +} +class Doubler extends C extends C { } +>Doubler : Doubler +>C : C +>C : C + +class Trebler extends C,C,C { } +>Trebler : Trebler +>C : C +>C : C +>C : C + // #private mistakes #unrelated junk.#m @@ -157,6 +175,34 @@ async import 'assert' async export { CantAsyncClass } >CantAsyncClass : typeof CantAsyncClass +export import 'fs' +export export { C } +>C : typeof C + +function nestedExports() { +>nestedExports : () => void + + export { staticParam } +>staticParam : any + + import 'fs' + export default 12 +} +function outerStaticFunction() { +>outerStaticFunction : () => void + + static function staticFunction() { } +>staticFunction : () => void +} +const noStaticLiteralMethods = { +>noStaticLiteralMethods : { m(): void; } +>{ static m() { }} : { m(): void; } + + static m() { +>m : () => void + } +} + // rest parameters function restMustBeLast(...x, y) { >restMustBeLast : (...x: any[], y: any) => void @@ -471,6 +517,14 @@ catch (e) { >log : (...data: any[]) => void >e : 1 } +try { + throw 20 +>20 : 20 +} +catch (e = 0) { +>e : any +>0 : 0 +} label: for (const x in [1,2,3]) { >label : any >x : string @@ -570,3 +624,5 @@ const spreadDynamicImport = import(...[]) >...[] : undefined >[] : undefined[] +return + diff --git a/tests/cases/conformance/salsa/plainJSGrammarErrors.ts b/tests/cases/conformance/salsa/plainJSGrammarErrors.ts index f25ee65efca7b..9697e9f8ac386 100644 --- a/tests/cases/conformance/salsa/plainJSGrammarErrors.ts +++ b/tests/cases/conformance/salsa/plainJSGrammarErrors.ts @@ -19,6 +19,7 @@ class C { for await (const x of [1,2,3]) { console.log(x) } + return null } // modifier mistakes static constructor() { } @@ -44,6 +45,11 @@ class C { // other "constructor" = 16 } +class { + missingName = true +} +class Doubler extends C extends C { } +class Trebler extends C,C,C { } // #private mistakes #unrelated junk.#m @@ -63,6 +69,20 @@ async class CantAsyncClass { async const cantAsyncConst = 2 async import 'assert' async export { CantAsyncClass } +export import 'fs' +export export { C } +function nestedExports() { + export { staticParam } + import 'fs' + export default 12 +} +function outerStaticFunction() { + static function staticFunction() { } +} +const noStaticLiteralMethods = { + static m() { + } +} // rest parameters function restMustBeLast(...x, y) { @@ -146,6 +166,11 @@ catch (e) { const e = 1 console.log(e) } +try { + throw 20 +} +catch (e = 0) { +} label: for (const x in [1,2,3]) { label: for (const y in [1,2,3]) { break label; @@ -183,3 +208,5 @@ function foo() { new.targe } const nullaryDynamicImport = import() const trinaryDynamicImport = import('1', '2', '3') const spreadDynamicImport = import(...[]) + +return