Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #2070: ignore export as namespace #2073

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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