-
Notifications
You must be signed in to change notification settings - Fork 173
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: Use of Object Literals #235
Comments
I found someone asking basically the same question over on the grpc-node project, where they were told this behavior is determined by the protobuf project, not by any of the protoc plugins. Does that sound right? |
Cross posted this to Google Groups forum for Protobuf |
I have the same issue. Seems like this project is being forked in some cases and isn't currently active? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It seems that the tutorial uses the "optimal" JS api but if you compile the proto files, then you need to use the getters/setters: E.g. see https://github.com/grpc/grpc/tree/v1.33.1/examples/node/dynamic_codegen (using normal objects) versus https://github.com/grpc/grpc/tree/v1.33.1/examples/node/static_codegen (using getters / setters) |
If you want to use the former, you can use grpc/grpc-node#1474 to get TS definitions |
@entropitor i generated the TS definition with grpc/grpc-node#1474 . |
You can follow the examples on the grpc website. But when using typescript you can e.g. type your functions/services using one of the types that is generated (just add a manually type annotation) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The generated types for messages are classes with a no-args constructor, and settings/getters for each property. In many cases (especially unary request/response operations) this feels really superfluous and adds a lot of cruft to code that could otherwise be inlined. As a new user of GRPC it's not clear to me whether this is an artifact of ts-protoc-gen or it's just representative of the underlying types created in JS.
This can be partially addressed using toObject() but that's only available one way. Am I missing something meant to make this easier?
The text was updated successfully, but these errors were encountered: