Skip to content

An enum member after a string member needs an initializer - #588

Merged
ASDAlexander77 merged 1 commit into
mainfrom
enum-member-initializer-error
Oct 17, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
enum-member-initializer-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

enum E { A = "x", B } compiled with no diagnostic, and B quietly took the count of the members before it.

Fix: a member without an initializer after a string member is an error at the member (TypeScript's TS1061). A member after a number member, including a float one (A = 1.5, B), still counts on.

Repro (diagnostic-location/enum_member_initializer.ts):

enum E {
    N,
    A = "x",
    B,        // 7:5: error: Enum member 'B' must have initializer
}

ctest -C Release -j 8 --timeout 300: 100% passed, 0 failed (4092 tests on this branch).

🤖 Generated with Claude Code

`enum E { A = "x", B }` compiled with no diagnostic, and B quietly
took the count of the members before it. TypeScript requires an
initializer there (a string has no next value); so does tslang now,
at the member. A member after a number member, a float one included,
still counts on from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit ed14d8b into main Oct 17, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the enum-member-initializer-error branch October 17, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant