Skip to content

Checker rejects a numeric enum member used as an enum initializer #3605

Closed

Description

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

TypeScript 6.0.3 accepts this and its emitted JavaScript prints 5. SharpTS with --no-tsconfig --strict --noEmit reports TS18033 for A. The checker also rejects enum E { Initial = 4, A = E.Initial, B }. Both references should be accepted as numeric constants. This concerns checking the member reference as the entire initializer. #3595 concerns interpreting an arithmetic expression that already passes checking.

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