-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
@babel/parser(ts): literal computed property names in enums #12683
Copy link
Copy link
Open
Description
Bug Report
- I would like to work on a fix!
Current behavior
Babel fails if computed property is provided as key of enum, this synatx should be allowed only for computed properties with string literal value or template literal without arguments.
Input Code
// should work
export enum Foo { ['baz'] }
export enum Foo { [`baz`] }
// should fail
export enum Foo { [foo] } // Computed property names are not allowed in enums
export enum Foo { [1] } // An enum member cannot have a numeric name.
export enum Foo { [`test${foo}`] } // Computed property names are not allowed in enums.Expected behavior
Babel should allow computed property or template literals
Note
In my opinion this syntax is a issue in typescript as Computed property names are not allowed in enums (1164), but as for now its parsed correctly and results in correct output
- Babel version(s): v7.12.0
- Node/npm version: 10-14
- OS: ----
- Monorepo: ----
- How you are using Babel: @babel/parser -> parse
Reactions are currently unavailable