-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
static js module encode issue when oneof objects. #644
Comments
I should have finished the statement. If I set someOtherContent and then try to encode the TestMessage, the above get will return "someContent" because $prototype.someContent == null which !== undefined, and then a nice stack trace will get issued when SomeContent.encode is called with a null object. Cheers |
Hmm, I'd even go a bit further and say that also everything with a default value on the prototype other than |
…th reflection and static code, see #644
This now re-uses some common runtime utility derived from reflection within static code (example output). Let me know if there are any issues! |
That is a working solution. Thanks Since my oneof block was all complex messages, it wasn't until I was driving home that I thought about how that code was going to work for primitives Cheers |
protobuf.js version: <6.5.0>
In the generated Static Module code, complex oneof components are initialized to null, but the discriminator getter function checks against undefined
The create for TestMessage shows
and when encode does a switch on message.oneOrTheOther
it triggers this
The text was updated successfully, but these errors were encountered: