Skip to content

Commit

Permalink
fix evanw#2070: ignore export as namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Mar 2, 2022
1 parent 2b644d6 commit 990b96c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/js_parser/js_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions internal/js_parser/ts_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<stdin>: ERROR: Expected \";\" but found \".\"\n")
expectParseErrorTS(t, "export as namespace ns function foo() {}", "<stdin>: ERROR: Expected \";\" but found \"function\"\n")

expectPrintedTS(t, `
namespace A {
export namespace B {
Expand Down

0 comments on commit 990b96c

Please sign in to comment.