-
Notifications
You must be signed in to change notification settings - Fork 769
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
Question: Why message types are treated as optional property? (TypeScript) #715
Comments
same here. why only message type is build as optional |
Hi! Thanks for reaching out! I think the reason could probably be explained by this following page: Where in Proto3, Primitive types only has This would probably also translated to how |
FYI - I'm guessing the following PR is related :) |
I'm closing this issue for now since we'd be moving to Please feel free to re-open if further confusion remains. Thanks! |
It's really nice to hear fixing. When are you going to release this fix? |
@Hyodori04 Hi :) I'm actually not 100% sure it'll be fixed.. It's just that we're updating how the "?" check is done so i'm supposing that this could be impacted (hopefully in a positive way).. :) I'm hopefully cutting a new release soon. But in the meantime let me create a test binary so if you could help test it out it would be nice to know if it's actually fixed or not 😃 |
FYI I've tried making some new test binaries but i think our workflow file is outdated :) https://github.com/grpc/grpc-web/actions Will need to look into this later (after july 4th). sorry for the delay :) |
@sampajano Hi, I can test it for you when the test binary is ready. Please leave a comment when it's updated, and I'll check it out. |
@Hyodori04 Thank you very much!! Will do after July 4th vacation! (There's various random build failures right now i probably cannot fix them all before i goes on vacation now.. 😅) |
I wonder why message type objects are treated as optional. The generator provides the type of
AsObject
as below:https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpc_generator.cc#L952-L970
On line 962, it checks if a field type is
TYPE_MESSAGE
and ifTYPE_MESSAGE
its fields are considered to be optional. As a result, the following type definition is generated:But default values will be set automatically if the message does not contain any data.
ref. https://developers.google.com/protocol-buffers/docs/proto3#default
So I think it seems to be tedious treating as optional properties and rather it should be as a normal object type (not optional).
This generation method was implemented in #448. But I cannot find any spec or definition so I asked. I apologize for not being a contribution
The text was updated successfully, but these errors were encountered: