Open tatemz opened 5 years ago
Hi @tatemz,
Thank you for your information. I just knew this trend in your issue.
And I have several questions:
The official grpc-node
project provides the proto-loader
package.
https://github.com/grpc/grpc-node/tree/master/packages/proto-loader
proto-loader
uses protobuf.js
behind the scenes and there is a lot of documentation there with further details
On further investigation, it seems as if protobuf.js
supplies Typescript definitions
The
@grpc/proto-loader
package allows for on-demand loading of.proto
files in order to dynamically create a node server or client. There is a pretty good example here:https://github.com/grpc/grpc/tree/v1.17.1/examples/node/dynamic_codegen
A few things are different about the way
proto-loader
generates the method definitions. Instead of using request/response objects with getters and setters, the method definitions use plain objects. The typings generated usually include anAsObject
version of the request/response objects, however, the client definitions generated by your plugin do not match the client implementation created byproto-loader
The following example is the definitions generated by your plugin:
The following is what it should look like if one was using
proto-loader
:Also not included in my above example is the support for Promises. In general your examples probably need to be updated to match the vanilla JS ones provided in the sample link above.