Skip to content

Commit

Permalink
support TS 4.3 override syntax (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane authored Apr 3, 2021
1 parent a25f09b commit 5364a90
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -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

0 comments on commit 5364a90

Please sign in to comment.