-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/codegen): Emit
override
keyword (#8449)
**Description:** Emits the `override` keyword.
- Loading branch information
Showing
12 changed files
with
176 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_codegen/tests/fixture/typescript/class_method/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class MyClass extends Base { | ||
public override method(param: number): string { | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_codegen/tests/fixture/typescript/class_method/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class MyClass extends Base { | ||
public override method(param: number): string {} | ||
} |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_codegen/tests/fixture/typescript/class_method/output.min.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class MyClass extends Base{public override method(param:number):string{}} |
4 changes: 3 additions & 1 deletion
4
crates/swc_ecma_codegen/tests/fixture/typescript/class_prop/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
class MyClass { | ||
class MyClass extends Base { | ||
prop1?: string; | ||
prop2!: string; | ||
#prop3?: string; | ||
#prop4?: string = "test"; | ||
static readonly prop5!: string; | ||
readonly #prop6 = "asdf"; | ||
public override readonly prop7 = 5; | ||
override readonly #prop8 = 5; | ||
} |
4 changes: 3 additions & 1 deletion
4
crates/swc_ecma_codegen/tests/fixture/typescript/class_prop/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
class MyClass { | ||
class MyClass extends Base { | ||
prop1?: string; | ||
prop2!: string; | ||
#prop3?: string; | ||
#prop4?: string = "test"; | ||
static readonly prop5!: string; | ||
readonly #prop6 = "asdf"; | ||
public override readonly prop7 = 5; | ||
override readonly #prop8 = 5; | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/swc_ecma_codegen/tests/fixture/typescript/class_prop/output.min.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
class MyClass{prop1?: string;prop2!: string;#prop3?: string;#prop4?: string="test";static readonly prop5!: string;readonly #prop6="asdf"} | ||
class MyClass extends Base{prop1?: string;prop2!: string;#prop3?: string;#prop4?: string="test";static readonly prop5!: string;readonly #prop6="asdf";public override readonly prop7=5;override readonly #prop8=5} |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_parser/tests/typescript/class/override/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class C extends B { | ||
override prop = 5; | ||
override method() { | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
crates/swc_ecma_parser/tests/typescript/class/override/input.ts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
{ | ||
"type": "Script", | ||
"span": { | ||
"start": 1, | ||
"end": 69, | ||
"ctxt": 0 | ||
}, | ||
"body": [ | ||
{ | ||
"type": "ClassDeclaration", | ||
"identifier": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 7, | ||
"end": 8, | ||
"ctxt": 0 | ||
}, | ||
"value": "C", | ||
"optional": false | ||
}, | ||
"declare": false, | ||
"span": { | ||
"start": 1, | ||
"end": 69, | ||
"ctxt": 0 | ||
}, | ||
"decorators": [], | ||
"body": [ | ||
{ | ||
"type": "ClassProperty", | ||
"span": { | ||
"start": 23, | ||
"end": 41, | ||
"ctxt": 0 | ||
}, | ||
"key": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 32, | ||
"end": 36, | ||
"ctxt": 0 | ||
}, | ||
"value": "prop", | ||
"optional": false | ||
}, | ||
"value": { | ||
"type": "NumericLiteral", | ||
"span": { | ||
"start": 39, | ||
"end": 40, | ||
"ctxt": 0 | ||
}, | ||
"value": 5.0, | ||
"raw": "5" | ||
}, | ||
"typeAnnotation": null, | ||
"isStatic": false, | ||
"decorators": [], | ||
"accessibility": null, | ||
"isAbstract": false, | ||
"isOptional": false, | ||
"isOverride": true, | ||
"readonly": false, | ||
"declare": false, | ||
"definite": false | ||
}, | ||
{ | ||
"type": "ClassMethod", | ||
"span": { | ||
"start": 44, | ||
"end": 67, | ||
"ctxt": 0 | ||
}, | ||
"key": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 53, | ||
"end": 59, | ||
"ctxt": 0 | ||
}, | ||
"value": "method", | ||
"optional": false | ||
}, | ||
"function": { | ||
"params": [], | ||
"decorators": [], | ||
"span": { | ||
"start": 44, | ||
"end": 67, | ||
"ctxt": 0 | ||
}, | ||
"body": { | ||
"type": "BlockStatement", | ||
"span": { | ||
"start": 62, | ||
"end": 67, | ||
"ctxt": 0 | ||
}, | ||
"stmts": [] | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"typeParameters": null, | ||
"returnType": null | ||
}, | ||
"kind": "method", | ||
"isStatic": false, | ||
"accessibility": null, | ||
"isAbstract": false, | ||
"isOptional": false, | ||
"isOverride": true | ||
} | ||
], | ||
"superClass": { | ||
"type": "Identifier", | ||
"span": { | ||
"start": 17, | ||
"end": 18, | ||
"ctxt": 0 | ||
}, | ||
"value": "B", | ||
"optional": false | ||
}, | ||
"isAbstract": false, | ||
"typeParams": null, | ||
"superTypeParams": null, | ||
"implements": [] | ||
} | ||
], | ||
"interpreter": null | ||
} |
12 changes: 6 additions & 6 deletions
12
crates/swc_ecma_transforms/tests/fixture/legacy-only/issues/862/1/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/swc_ecma_transforms/tests/fixture/legacy-only/issues/862/2/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters