-
-
Notifications
You must be signed in to change notification settings - Fork 648
Closed
Labels
Description
Parser 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.
// should work
enum Foo { ['baz'] } // ❌ currently fails
enum Foo { [`baz`] } // ❌ currently fails
enum Foo { ['baz'] = 2 } // ❌ currently fails
enum Foo { [`baz`] = 2 } // ❌ currently fails
enum Foo { 'baz' } // 👍 work fine
enum Foo { baz } // 👍 work fine
enum Foo { 'baz' = 2 } // 👍 work fine
enum Foo { baz = 2 } // 👍 work fine
// should fail
enum Foo { [foo] } // Computed property names are not allowed in enums
enum Foo { [1] } // An enum member cannot have a numeric name.
enum Foo { [`test${foo}`] } // Computed property names are not allowed in enums.
enum Foo { `baz` = 2 } // Enum member expected.
enum Foo { ['baz' + 'baz'] } // Computed property names are not allowed in enums.