Skip to content

Commit

Permalink
JLHwung review
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Aug 3, 2021
1 parent 55f5868 commit 54732e9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/babel-parser/src/plugins/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.raise(
this.state.start,
TSErrors.AbstractPropertyHasInitializer,
!node.computed
key.type === "Identifier" && !node.computed
? key.name
: `[${this.input.slice(key.start, key.end)}]`,
);
Expand Down Expand Up @@ -3213,7 +3213,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.raise(
method.start,
TSErrors.AbstractMethodHasImplementation,
!method.computed
key.type === "Identifier" && !method.computed
? key.name
: `[${this.input.slice(key.start, key.end)}]`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ abstract class Foo {
abstract prop = 1
abstract [Bar.foo] = 2
abstract [Bar] = 3
abstract 2 = 4
abstract "c" = 5
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"type": "File",
"start":0,"end":88,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
"errors": [
"SyntaxError: Property 'prop' cannot have a initializer because it is marked abstract. (2:16)",
"SyntaxError: Property '[Bar.foo]' cannot have a initializer because it is marked abstract. (3:21)",
"SyntaxError: Property '[Bar]' cannot have a initializer because it is marked abstract. (4:17)"
"SyntaxError: Property '[Bar]' cannot have a initializer because it is marked abstract. (4:17)",
"SyntaxError: Property '[2]' cannot have a initializer because it is marked abstract. (5:13)",
"SyntaxError: Property '[\"c\"]' cannot have a initializer because it is marked abstract. (6:15)"
],
"program": {
"type": "Program",
"start":0,"end":88,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ClassDeclaration",
"start":0,"end":88,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":1}},
"start":0,"end":124,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
"abstract": true,
"id": {
"type": "Identifier",
Expand All @@ -24,7 +26,7 @@
"superClass": null,
"body": {
"type": "ClassBody",
"start":19,"end":88,"loc":{"start":{"line":1,"column":19},"end":{"line":5,"column":1}},
"start":19,"end":124,"loc":{"start":{"line":1,"column":19},"end":{"line":7,"column":1}},
"body": [
{
"type": "ClassProperty",
Expand Down Expand Up @@ -98,6 +100,56 @@
},
"value": 3
}
},
{
"type": "ClassProperty",
"start":89,"end":103,"loc":{"start":{"line":5,"column":2},"end":{"line":5,"column":16}},
"abstract": true,
"static": false,
"key": {
"type": "NumericLiteral",
"start":98,"end":99,"loc":{"start":{"line":5,"column":11},"end":{"line":5,"column":12}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"computed": false,
"value": {
"type": "NumericLiteral",
"start":102,"end":103,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":16}},
"extra": {
"rawValue": 4,
"raw": "4"
},
"value": 4
}
},
{
"type": "ClassProperty",
"start":106,"end":122,"loc":{"start":{"line":6,"column":2},"end":{"line":6,"column":18}},
"abstract": true,
"static": false,
"key": {
"type": "StringLiteral",
"start":115,"end":118,"loc":{"start":{"line":6,"column":11},"end":{"line":6,"column":14}},
"extra": {
"rawValue": "c",
"raw": "\"c\""
},
"value": "c"
},
"computed": false,
"value": {
"type": "NumericLiteral",
"start":121,"end":122,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":18}},
"extra": {
"rawValue": 5,
"raw": "5"
},
"value": 5
}
}
]
}
Expand Down

0 comments on commit 54732e9

Please sign in to comment.