Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I haveread the FAQ and my problem is not listed.
Repro
// the code you're trying to parseclassFoo{readonlybar(){}declarebaz(){}}
// the code you're using to do the parse of the aforementioned codeimport{parse}from'@typescript-eslint/typescript-estree';constcode=`class Foo { readonly bar() {} declare baz() {}}`;constast=parse(code);
Expected Result
Expect thatMethodDefinition
nodes havereadonly
anddeclare
property.
AST
{ "type": "ClassDeclaration", "id": { "type": "Identifier", "name": "Foo" }, "body": { "type": "ClassBody", "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", "name": "bar" }, "value": { "type": "FunctionExpression", "id": null, "generator": false, "expression": false, "async": false, "body": { "type": "BlockStatement", "body": [] }, "params": [] }, "computed": false, "static": false, "kind": "method",+ "readonly": true }, { "type": "MethodDefinition", "key": { "type": "Identifier", "name": "baz" }, "value": { "type": "FunctionExpression", "id": null, "generator": false, "expression": false, "async": false, "body": { "type": "BlockStatement", "body": [] }, "params": [] }, "computed": false, "static": false, "kind": "method",+ "declare": true } ] }, "superClass": null}
Actual Result
AST
{"type":"ClassDeclaration","id": {"type":"Identifier","name":"Foo" },"body": {"type":"ClassBody","body": [ {"type":"MethodDefinition","key": {"type":"Identifier","name":"bar" },"value": {"type":"FunctionExpression","id":null,"generator":false,"expression":false,"async":false,"body": {"type":"BlockStatement","body": [] },"params": [] },"computed":false,"static":false,"kind":"method" }, {"type":"MethodDefinition","key": {"type":"Identifier","name":"baz" },"value": {"type":"FunctionExpression","id":null,"generator":false,"expression":false,"async":false,"body": {"type":"BlockStatement","body": [] },"params": [] },"computed":false,"static":false,"kind":"method" } ] },"superClass":null}
Additional Info
I know the above code is invalid as TypeScript program (TS Playground). But I think code formatters should correctly treat those cases. What do you think about?
If the request is accepted, I can work on this.
Versions
package | version |
---|---|
@typescript-eslint/typescript-estree | master |
TypeScript | 4.1.2 |
node | v14.8.0 |