Skip to content

[TS] Fix union switch to use enum values instead of string names (fixes #6741)#9171

Open
0xchidhu wants to merge 1 commit into
google:masterfrom
0xchidhu:fix-switch-on-type-generator
Open

[TS] Fix union switch to use enum values instead of string names (fixes #6741)#9171
0xchidhu wants to merge 1 commit into
google:masterfrom
0xchidhu:fix-switch-on-type-generator

Conversation

@0xchidhu

Copy link
Copy Markdown

Fixes #6741

The generated unionTo helpers switched on Enum[type] with string case labels, which bypasses TypeScript type checking.

This change generates a switch directly on the enum value with Enum.Member case labels, and regenerates the affected TS test files.

Testing: TestAll.sh pass locally. Code formatted with clang-format per the style guide.

@0xchidhu 0xchidhu requested a review from dbaileychess as a code owner July 13, 2026 20:12
@google-cla

google-cla Bot commented Jul 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added c++ javascript typescript codegen Involving generating code from schema labels Jul 13, 2026
@0xchidhu 0xchidhu force-pushed the fix-switch-on-type-generator branch from 6404da1 to c0c067f Compare July 13, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema javascript typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TS] In version 2, why do union helpers use string comparison?

1 participant