diff --git a/crates/oxc_parser/src/ts/statement.rs b/crates/oxc_parser/src/ts/statement.rs index 2651b68c5f8e9..b26a0d757aa10 100644 --- a/crates/oxc_parser/src/ts/statement.rs +++ b/crates/oxc_parser/src/ts/statement.rs @@ -334,6 +334,12 @@ impl<'a> ParserImpl<'a> { self.asi(); None }; + self.verify_modifiers( + modifiers, + ModifierFlags::DECLARE, + true, + diagnostics::modifier_cannot_be_used_here, + ); self.ast.alloc_ts_module_declaration( self.end_span(span), id, @@ -393,6 +399,13 @@ impl<'a> ParserImpl<'a> { let body = self.parse_ts_module_block().unbox(); + self.verify_modifiers( + modifiers, + ModifierFlags::DECLARE, + true, + diagnostics::modifier_cannot_be_used_here, + ); + self.ast.alloc_ts_global_declaration( self.end_span(span), keyword_span, diff --git a/tasks/coverage/snapshots/parser_typescript.snap b/tasks/coverage/snapshots/parser_typescript.snap index 9d4ddf973a962..6480771ae33e7 100644 --- a/tasks/coverage/snapshots/parser_typescript.snap +++ b/tasks/coverage/snapshots/parser_typescript.snap @@ -9671,6 +9671,15 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/Va 327 │ namespace m2 { ╰──── + × 'export' modifier cannot be used here. + ╭─[typescript/tests/cases/compiler/privacyImportParseErrors.ts:326:9] + 325 │ + 326 │ declare export module "anotherParseError2" { + · ────── + 327 │ namespace m2 { + ╰──── + help: Only 'declare' modifier is allowed here. + × Unexpected token ╭─[typescript/tests/cases/compiler/privateNameJsx.tsx:4:22] 3 │ render() {