Skip to content

Checker does not use constant variables for implicit enum member values #3604

Closed

Description

@nickna
const source = 4;
enum E { A = source, B }
console.log(E.B);

TypeScript 6.0.3 accepts this and its JavaScript prints 5 in Node. SharpTS with --no-tsconfig --strict --noEmit reports TS1061 for B. The enum constant evaluator recognizes arithmetic and earlier enum members but does not resolve const variable initializers. This also happens with const source = 1 << 2. Found while verifying #3572.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions