Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(parser): missing/unsupported enum syntax in typescript #4449

Closed
armano2 opened this issue Jul 24, 2024 · 1 comment · Fixed by #4543
Closed

bug(parser): missing/unsupported enum syntax in typescript #4449

armano2 opened this issue Jul 24, 2024 · 1 comment · Fixed by #4543
Assignees
Labels
A-parser Area - Parser C-bug Category - Bug

Comments

@armano2
Copy link

armano2 commented Jul 24, 2024

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.

ref microsoft/TypeScript#42468

@armano2 armano2 added the C-bug Category - Bug label Jul 24, 2024
@armano2 armano2 changed the title Missing/unsupported enum syntax bug(typescript): missing/unsupported enum syntax Jul 24, 2024
@armano2 armano2 changed the title bug(typescript): missing/unsupported enum syntax bug(parser): missing/unsupported enum syntax in typescript Jul 24, 2024
@DonIsaac DonIsaac added the A-parser Area - Parser label Jul 24, 2024
@DonIsaac DonIsaac self-assigned this Jul 24, 2024
Boshen pushed a commit that referenced this issue Jul 30, 2024
@overlookmotel
Copy link
Contributor

Fixed in #4543.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants