Skip to content

String enum computed values not allowed #20440

Closed
@michaelgeorgeattard

Description

@michaelgeorgeattard

TypeScript Version: 2.7.0-dev.201xxxxx

Code

As mentioned earlier by @MadaraUchiha and others, why can we do the following?

const Foo = 0;

enum MyEnum {
    FooValue = Foo,
}

But not:

const Foo = "0";

enum MyEnum {
    FooValue = Foo,
}

It should be either both are valid, or none, this looks like an inconsistency in Typescript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions