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

Created on 16 Mar 2020  ·  1Comment  ·  Source: microsoft/TypeScript


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.

Duplicate

Most helpful comment

Duplicate of #27976. Search terms used: enum computed

>All comments

Duplicate of #27976. Search terms used: enum computed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanzer picture seanzer  ·  3Comments

kyasbal-1994 picture kyasbal-1994  ·  3Comments

dlaberge picture dlaberge  ·  3Comments

Roam-Cooper picture Roam-Cooper  ·  3Comments

fwanicka picture fwanicka  ·  3Comments