Skip to content

Commit

Permalink
ts: add test coverage for decorated private names
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Apr 1, 2022
1 parent 85f7ffa commit 4cb292c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/js_parser/ts_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,18 @@ func TestTSPrivateIdentifiers(t *testing.T) {
expectPrintedTS(t, "class Foo { static #foo() {} }", "class Foo {\n static #foo() {\n }\n}\n")
expectPrintedTS(t, "class Foo { static get #foo() {} }", "class Foo {\n static get #foo() {\n }\n}\n")
expectPrintedTS(t, "class Foo { static set #foo(x) {} }", "class Foo {\n static set #foo(x) {\n }\n}\n")

// Decorators are not valid on private members
expectParseErrorTS(t, "class Foo { @dec #foo }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec #foo = 1 }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec #foo() {} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec get #foo() {} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec set #foo() {x} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec static #foo }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec static #foo = 1 }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec static #foo() {} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec static get #foo() {} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
expectParseErrorTS(t, "class Foo { @dec static set #foo() {x} }", "<stdin>: ERROR: Expected identifier but found \"#foo\"\n")
}

func TestTSInterface(t *testing.T) {
Expand Down

0 comments on commit 4cb292c

Please sign in to comment.