@@ -820,6 +820,7 @@ namespace ts {
820820
821821 /** @internal */
822822 export const plainJSErrors : Set < number > = new Set ( [
823+ // binder errors
823824 Diagnostics . Cannot_redeclare_block_scoped_variable_0 . code ,
824825 Diagnostics . A_module_cannot_have_multiple_default_exports . code ,
825826 Diagnostics . Another_export_default_is_here . code ,
@@ -835,6 +836,69 @@ namespace ts {
835836 Diagnostics . A_label_is_not_allowed_here . code ,
836837 Diagnostics . Octal_literals_are_not_allowed_in_strict_mode . code ,
837838 Diagnostics . with_statements_are_not_allowed_in_strict_mode . code ,
839+ // grammar errors
840+ Diagnostics . A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement . code ,
841+ Diagnostics . A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement . code ,
842+ Diagnostics . A_class_member_cannot_have_the_0_keyword . code ,
843+ Diagnostics . A_comma_expression_is_not_allowed_in_a_computed_property_name . code ,
844+ Diagnostics . A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement . code ,
845+ Diagnostics . A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement . code ,
846+ Diagnostics . A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement . code ,
847+ Diagnostics . A_default_clause_cannot_appear_more_than_once_in_a_switch_statement . code ,
848+ Diagnostics . A_definite_assignment_assertion_is_not_permitted_in_this_context . code ,
849+ Diagnostics . A_destructuring_declaration_must_have_an_initializer . code ,
850+ Diagnostics . A_get_accessor_cannot_have_parameters . code ,
851+ Diagnostics . A_rest_element_cannot_contain_a_binding_pattern . code ,
852+ Diagnostics . A_rest_element_cannot_have_a_property_name . code ,
853+ Diagnostics . A_rest_element_cannot_have_an_initializer . code ,
854+ Diagnostics . A_rest_element_must_be_last_in_a_destructuring_pattern . code ,
855+ Diagnostics . A_rest_parameter_cannot_have_an_initializer . code ,
856+ Diagnostics . A_rest_parameter_must_be_last_in_a_parameter_list . code ,
857+ Diagnostics . A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma . code ,
858+ Diagnostics . A_set_accessor_cannot_have_rest_parameter . code ,
859+ Diagnostics . A_set_accessor_must_have_exactly_one_parameter . code ,
860+ Diagnostics . An_object_member_cannot_be_declared_optional . code ,
861+ Diagnostics . Argument_of_dynamic_import_cannot_be_spread_element . code ,
862+ Diagnostics . Cannot_assign_to_private_method_0_Private_methods_are_not_writable . code ,
863+ Diagnostics . Cannot_redeclare_identifier_0_in_catch_clause . code ,
864+ Diagnostics . Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator . code ,
865+ Diagnostics . Classes_may_not_have_a_field_named_constructor . code ,
866+ 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 ,
867+ Diagnostics . Duplicate_label_0 . code ,
868+ Diagnostics . Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments . code ,
869+ Diagnostics . For_await_loops_cannot_be_used_inside_a_class_static_block . code ,
870+ Diagnostics . JSX_attributes_must_only_be_assigned_a_non_empty_expression . code ,
871+ Diagnostics . JSX_elements_cannot_have_multiple_attributes_with_the_same_name . code ,
872+ Diagnostics . JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array . code ,
873+ Diagnostics . JSX_property_access_expressions_cannot_include_JSX_namespace_names . code ,
874+ Diagnostics . Jump_target_cannot_cross_function_boundary . code ,
875+ Diagnostics . Line_terminator_not_permitted_before_arrow . code ,
876+ Diagnostics . Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement . code ,
877+ Diagnostics . Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement . code ,
878+ Diagnostics . Private_identifiers_are_not_allowed_outside_class_bodies . code ,
879+ Diagnostics . 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 . code ,
880+ Diagnostics . Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier . code ,
881+ Diagnostics . Tagged_template_expressions_are_not_permitted_in_an_optional_chain . code ,
882+ Diagnostics . The_left_hand_side_of_a_for_of_statement_may_not_be_async . code ,
883+ Diagnostics . The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer . code ,
884+ Diagnostics . The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer . code ,
885+ Diagnostics . Trailing_comma_not_allowed . code ,
886+ Diagnostics . Variable_declaration_list_cannot_be_empty . code ,
887+ Diagnostics . _0_and_1_operations_cannot_be_mixed_without_parentheses . code ,
888+ Diagnostics . _0_expected . code ,
889+ Diagnostics . _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2 . code ,
890+ Diagnostics . _0_list_cannot_be_empty . code ,
891+ Diagnostics . _0_modifier_already_seen . code ,
892+ Diagnostics . _0_modifier_cannot_appear_on_a_constructor_declaration . code ,
893+ Diagnostics . _0_modifier_cannot_appear_on_a_module_or_namespace_element . code ,
894+ Diagnostics . _0_modifier_cannot_appear_on_a_parameter . code ,
895+ Diagnostics . _0_modifier_cannot_appear_on_class_elements_of_this_kind . code ,
896+ Diagnostics . _0_modifier_cannot_be_used_here . code ,
897+ Diagnostics . _0_modifier_must_precede_1_modifier . code ,
898+ Diagnostics . const_declarations_can_only_be_declared_inside_a_block . code ,
899+ Diagnostics . const_declarations_must_be_initialized . code ,
900+ Diagnostics . let_declarations_can_only_be_declared_inside_a_block . code ,
901+ Diagnostics . let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations . code ,
838902 ] ) ;
839903
840904 /**
@@ -2036,9 +2100,10 @@ namespace ts {
20362100 const includeBindAndCheckDiagnostics = ! isTsNoCheck && ( sourceFile . scriptKind === ScriptKind . TS || sourceFile . scriptKind === ScriptKind . TSX
20372101 || sourceFile . scriptKind === ScriptKind . External || isPlainJs || isCheckJs || sourceFile . scriptKind === ScriptKind . Deferred ) ;
20382102 let bindDiagnostics : readonly Diagnostic [ ] = includeBindAndCheckDiagnostics ? sourceFile . bindDiagnostics : emptyArray ;
2039- const checkDiagnostics = includeBindAndCheckDiagnostics && ! isPlainJs ? typeChecker . getDiagnostics ( sourceFile , cancellationToken ) : emptyArray ;
2103+ let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker . getDiagnostics ( sourceFile , cancellationToken ) : emptyArray ;
20402104 if ( isPlainJs ) {
20412105 bindDiagnostics = filter ( bindDiagnostics , d => plainJSErrors . has ( d . code ) ) ;
2106+ checkDiagnostics = filter ( checkDiagnostics , d => plainJSErrors . has ( d . code ) ) ;
20422107 }
20432108 // skip ts-expect-error errors in plain JS files, and skip JSDoc errors except in checked JS
20442109 return getMergedBindAndCheckDiagnostics ( sourceFile , includeBindAndCheckDiagnostics && ! isPlainJs , bindDiagnostics , checkDiagnostics , isCheckJs ? sourceFile . jsDocDiagnostics : undefined ) ;
0 commit comments