diff --git a/internal/js_parser/js_parser.go b/internal/js_parser/js_parser.go index f43a2685ef8..36b7a224da0 100644 --- a/internal/js_parser/js_parser.go +++ b/internal/js_parser/js_parser.go @@ -5952,7 +5952,7 @@ func (p *parser) parseStmt(opts parseStmtOpts) js_ast.Stmt { return p.parseStmt(opts) } - if opts.isTypeScriptDeclare && p.lexer.IsContextualKeyword("as") { + if p.lexer.IsContextualKeyword("as") { // "export as namespace ns;" p.lexer.Next() p.lexer.ExpectContextualKeyword("namespace") diff --git a/internal/js_parser/ts_parser_test.go b/internal/js_parser/ts_parser_test.go index db524661f28..079ccbeff7d 100644 --- a/internal/js_parser/ts_parser_test.go +++ b/internal/js_parser/ts_parser_test.go @@ -721,6 +721,11 @@ async function foo() { } func TestTSNamespaceExports(t *testing.T) { + expectPrintedTS(t, "export as namespace ns", "") + expectPrintedTS(t, "export as namespace ns;", "") + expectParseErrorTS(t, "export as namespace ns.foo", ": ERROR: Expected \";\" but found \".\"\n") + expectParseErrorTS(t, "export as namespace ns function foo() {}", ": ERROR: Expected \";\" but found \"function\"\n") + expectPrintedTS(t, ` namespace A { export namespace B {