Closed
Description
(This issue related on prettier/prettier#6569)
What code were you trying to parse?
// Put your code here
const bar = "bar";
class Foo {
[bar]?;
}
What did you expect to happen?
{
"type": "ClassProperty",
"key": {
"type": "Identifier",
"name": "bar",
"range": [36, 39],
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 8
}
}
},
"value": null,
"computed": true,
"static": false,
"range": [35, 42],
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 11
}
},
"optional": true // This "optional" should exist
}
What actually happened?
{
"type": "ClassProperty",
"key": {
"type": "Identifier",
"name": "bar",
"range": [36, 39],
"loc": {
"start": {
"line": 4,
"column": 5
},
"end": {
"line": 4,
"column": 8
}
}
},
"value": null,
"computed": true,
"static": false,
"range": [35, 42],
"loc": {
"start": {
"line": 4,
"column": 4
},
"end": {
"line": 4,
"column": 11
}
}
}
It works fine for computed optional properties that do not use variables.
class Foo {
["bar"]?;
[1]?;
}
Versions
package | version |
---|---|
@typescript-eslint/typescript-estree |
2.3.1 |
TypeScript |
3.4.1 |
node |
12.10.0 |
npm |
6.11.3 |