Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix syntax error for getter and setter with ts and estree plugin (#12333
- Loading branch information
1 parent
3227914
commit ad8a4d6
Showing
3 changed files
with
209 additions
and
1 deletion.
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
packages/babel-parser/test/fixtures/estree/typescript/getter-setter/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,4 @@ | ||
({ set x(foo) {} }); | ||
({ get x() { return 1 } }); | ||
({ set x() {} }); | ||
({ get x(x) {} }); |
203 changes: 203 additions & 0 deletions
203
packages/babel-parser/test/fixtures/estree/typescript/getter-setter/output.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,203 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":85,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":18}}, | ||
"errors": [ | ||
"SyntaxError: setter must have exactly one formal parameter (3:3)", | ||
"SyntaxError: getter must not have any formal parameters (4:3)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":85,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":18}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}}, | ||
"expression": { | ||
"type": "ObjectExpression", | ||
"start":1,"end":18,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":18}}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":3,"end":16,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":16}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"computed": false, | ||
"kind": "set", | ||
"value": { | ||
"type": "FunctionExpression", | ||
"start":8,"end":16,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":16}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"expression": false, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12},"identifierName":"foo"}, | ||
"name": "foo" | ||
} | ||
], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":14,"end":16,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":16}}, | ||
"body": [] | ||
} | ||
}, | ||
"shorthand": false | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":21,"end":48,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":27}}, | ||
"expression": { | ||
"type": "ObjectExpression", | ||
"start":22,"end":46,"loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":25}}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 21 | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":24,"end":44,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":23}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":28,"end":29,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":8},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"computed": false, | ||
"kind": "get", | ||
"value": { | ||
"type": "FunctionExpression", | ||
"start":29,"end":44,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":23}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"expression": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":32,"end":44,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":23}}, | ||
"body": [ | ||
{ | ||
"type": "ReturnStatement", | ||
"start":34,"end":42,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":21}}, | ||
"argument": { | ||
"type": "Literal", | ||
"start":41,"end":42,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}}, | ||
"value": 1, | ||
"raw": "1" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"shorthand": false | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":49,"end":66,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":17}}, | ||
"expression": { | ||
"type": "ObjectExpression", | ||
"start":50,"end":64,"loc":{"start":{"line":3,"column":1},"end":{"line":3,"column":15}}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 49 | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":52,"end":62,"loc":{"start":{"line":3,"column":3},"end":{"line":3,"column":13}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":56,"end":57,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":8},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"computed": false, | ||
"kind": "set", | ||
"value": { | ||
"type": "FunctionExpression", | ||
"start":57,"end":62,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":13}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"expression": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":60,"end":62,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":13}}, | ||
"body": [] | ||
} | ||
}, | ||
"shorthand": false | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "ExpressionStatement", | ||
"start":67,"end":85,"loc":{"start":{"line":4,"column":0},"end":{"line":4,"column":18}}, | ||
"expression": { | ||
"type": "ObjectExpression", | ||
"start":68,"end":83,"loc":{"start":{"line":4,"column":1},"end":{"line":4,"column":16}}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 67 | ||
}, | ||
"properties": [ | ||
{ | ||
"type": "Property", | ||
"start":70,"end":81,"loc":{"start":{"line":4,"column":3},"end":{"line":4,"column":14}}, | ||
"method": false, | ||
"key": { | ||
"type": "Identifier", | ||
"start":74,"end":75,"loc":{"start":{"line":4,"column":7},"end":{"line":4,"column":8},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"computed": false, | ||
"kind": "get", | ||
"value": { | ||
"type": "FunctionExpression", | ||
"start":75,"end":81,"loc":{"start":{"line":4,"column":8},"end":{"line":4,"column":14}}, | ||
"id": null, | ||
"generator": false, | ||
"async": false, | ||
"expression": false, | ||
"params": [ | ||
{ | ||
"type": "Identifier", | ||
"start":76,"end":77,"loc":{"start":{"line":4,"column":9},"end":{"line":4,"column":10},"identifierName":"x"}, | ||
"name": "x" | ||
} | ||
], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":79,"end":81,"loc":{"start":{"line":4,"column":12},"end":{"line":4,"column":14}}, | ||
"body": [] | ||
} | ||
}, | ||
"shorthand": false | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} |