Skip to content

Inconsistency: Computed values are not permitted in an enum with string values members #37411

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

Closed
lihz6 opened this issue Mar 16, 2020 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@lihz6
Copy link

lihz6 commented Mar 16, 2020

TypeScript Version: 3.8.3

Search Terms: enum member

Code

enum Reply {
    YES = 'YES',
    NO = 1 + 2
}
enum Reply_ {
    YES = 'Y' + 'E' + 'S',
    NO = 1 + 2
}

Expected behavior:
Two snippets both compile okay, at least stay consistency.

Actual behavior:
The first snippet compiles error, the second snippet compiles okay.

Playground Link:
https://www.typescriptlang.org/en/play?#code/KYOwrgtgBASsAOAbAnlA3gKCtqBNAogMpQC8UA5AYeQDRY4ByA8qVAIxQDUUATBgL4YMoSLAQoA+unrYqrSuS4V8i7uWp0cUZqw7c+-IA

Related Issues:
Not Found.

@MartinJohns
Copy link
Contributor

Duplicate of #27976. Search terms used: enum computed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants