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

support TS 4.3 override syntax #1105

Merged
merged 1 commit into from
Apr 3, 2021
Merged
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 @@ -1829,7 +1829,7 @@ func (p *parser) parseProperty(kind js_ast.PropertyKind, opts propertyOpts, erro
return p.parseProperty(kind, opts, nil)
}

case "private", "protected", "public", "readonly", "abstract", "declare":
case "private", "protected", "public", "readonly", "abstract", "declare", "override":
// Skip over TypeScript keywords
if opts.isClass && p.options.ts.Parse && raw == name {
return p.parseProperty(kind, opts, nil)
Expand Down
9 changes: 9 additions & 0 deletions internal/js_parser/ts_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ func TestTSClass(t *testing.T) {
expectPrintedTS(t, "class Foo { declare foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { declare public foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public declare foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { override foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { override public foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public override foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { declare override public foo: number }", "class Foo {\n}\n")

expectPrintedTS(t, "class Foo { public static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { private static foo: number }", "class Foo {\n}\n")
Expand All @@ -358,6 +362,11 @@ func TestTSClass(t *testing.T) {
expectPrintedTS(t, "class Foo { declare public static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public declare static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public static declare foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { override static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { override public static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public override static foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { public static override foo: number }", "class Foo {\n}\n")
expectPrintedTS(t, "class Foo { declare override public static foo: number }", "class Foo {\n}\n")

expectPrintedTS(t, "class Foo { [key: string]: any\nfoo = 0 }", "class Foo {\n constructor() {\n this.foo = 0;\n }\n}\n")
expectPrintedTS(t, "class Foo { [key: string]: any; foo = 0 }", "class Foo {\n constructor() {\n this.foo = 0;\n }\n}\n")
Expand Down