-
Notifications
You must be signed in to change notification settings - Fork 58
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
Handling (de)serialization modes for 64-bit integer types #10
Comments
Thank you for your issue. This surely is the issue shall be fixed. |
Thanks for making this nice tool. Yeah, protobuf.js seems to be used by grpc-node when dynamically generating the code at runtime. It does handle serialization into Long.js which is very nice. Since we want TypeScript support: having the code statically generated with typedefs makes sense. I don't have a clear recipe for combining protobuf.js with statically generated client stubs/messages but would be interested to know if you have accomplished that. |
I just found in the doc of version 6.8.4, protobuf.js provided the functionality to generate static code files. Please check here: Command Line > pbjs for JavaScript
And also: Command Line > pbts for TypeScript
I just made some test yesterday, seems it works very good. Maybe you can have a try. The tool grpc-tools used to generate javascript code from protobuf provided by google official, just, how to say, "javascript version too old". Which just not following the latest javascript grammar & javascript development trends. So I think maybe protobuf.js is a better choice for the users who want static code generation, just like you and me. |
One more issue have to be fixed before using protobuf.js as a grpc static code generator. Since protobuf.js is a tool See Examples > Using services and examples/streaming-rpc.js. And I searched around, seems no official or 3rd tutorial how to combine protobuf.js with gRPC. It may cost a lot of time to solve this issue. |
Good to resonate on that clarity. Even if protobuf.js does not handle the grpc service implementation it may be worthwhile. Later, perhaps there could be some way to decouple the grpc service generation from this project. |
This adds `jstype = JS_STRING` annotations on the channel ids in the lnd proto definition so that they use `string` types instead of numbers. Javascript does not natively support 64 bit numbers and precision can be lost, and the channel ids are known to cause issues because of this. This also adds a new package to generate type definitions from the `.proto` files. This is because of a known bug in the previously used plugin, agreatfool/grpc_tools_node_protoc_ts#10, which does not update the generated type definition when `jstype = JS_STRING` is used. Fixes #745.
This adds `jstype = JS_STRING` annotations on the channel ids in the lnd proto definition so that they use `string` types instead of numbers. Javascript does not natively support 64 bit numbers and precision can be lost, and the channel ids are known to cause issues because of this. This also adds a new package to generate type definitions from the `.proto` files. This is because of a known bug in the previously used plugin, agreatfool/grpc_tools_node_protoc_ts#10, which does not update the generated type definition when `jstype = JS_STRING` is used. Fixes #745.
This adds `jstype = JS_STRING` annotations on the channel ids in the lnd proto definition so that they use `string` types instead of numbers. Javascript does not natively support 64 bit numbers and precision can be lost, and the channel ids are known to cause issues because of this. This also adds a new package to generate type definitions from the `.proto` files. This is because of a known bug in the previously used plugin, agreatfool/grpc_tools_node_protoc_ts#10, which does not update the generated type definition when `jstype = JS_STRING` is used. Fixes #745.
If I add the
[jstype=JS_STRING]
option to a message then the generated stubs will return a string for the 64-bit integer value. The generated typescript definition does not handle this. I'll let you know if I attempt a pull request to add this functionality but for now I am overriding the typescript guards in my code for now.Example
Note that the generated code has a
readInt64String()
invocation that works as expected. The value of the message is of typestring
instead ofnumber
.Background
protocolbuffers/protobuf#3666
When taking the static stub generation google/protobuf has an obscure configuration that will (de)serialize 64-bit integers into strings. I am satisfied with parsing this with some other module that can manipulate the long number at this point.
The text was updated successfully, but these errors were encountered: