Skip to content

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

Closed
@lihz6

Description

@lihz6

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions