-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: oneof=unions-value to use the same field name for oneof cases #1062
Conversation
@@ -752,7 +752,7 @@ ts-protoc --ts_proto_out=./output -I=./protos ./protoc/*.proto | |||
# Todo | |||
|
|||
- Support the string-based encoding of duration in `fromJSON`/`toJSON` | |||
- Make `oneof=unions` the default behavior in 2.0 | |||
- Make `oneof=unions-value` the default behavior in 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice! I definitely agree this value
field is better and should be the default.
We're in luck that a 2.x release is likely going to happen in the next ~month or so, via #1058, so we should plan on flipping this default over, and honestly probably just removing the option/old behavior all together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great, feel free to ping me if you want help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'll ping you once Timo's PR lands as an 2.0.0 alpha and would be great to get this flipped over.
This is great, thank you @bhollis ! |
🎉 This PR is included in version 1.180.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #1060.
This adds a new
oneof=unions-value
option that changes how union oneof code is generated. Instead of each case having a field named the same as the$case
, each of them has the same field, calledvalue
. This should simplify writing generic code that can handle multiple cases at once.I chose to make it another option for
oneof=
instead of a separate option since it's just another way of handling oneofs. I also updated the README but it may be a bit much, I'm happy to remove some stuff. I also presumptively suggest that this be the new recommended oneof option.