Skip to content

Enum constant evaluation rejects mixed string and number concatenation #3633

Closed

Description

@nickna
const word = 'value' + 5;
enum E { A = word }
console.log(E.A);

TypeScript 6.0.3 accepts this with --ignoreConfig --strict --target ES2022 and its output prints value5. SharpTS with the string const initializer fix for #3624 still reports TS18033 with --no-tsconfig --strict --noEmit.

The constant evaluator should coerce the numeric operand to a string during concatenation and use the resulting string as a forward-only enum value. Found while verifying #3624, which covers string const variables.

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