Skip to content
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

Issue with message struct serialization/deserialization in method return type #963

Open
ablause opened this issue Nov 16, 2023 · 1 comment

Comments

@ablause
Copy link

ablause commented Nov 16, 2023

Description:
I am encountering an issue when utilizing the google.protobuf.Struct message struct directly in the return type of a method in TypeScript generated by ts-proto. Instead of generating an object, the generated code uses the Struct class for encoding or decoding.

Steps to Reproduce:

  1. Define an RPC method as follows:
rpc Hello(HelloRequest) returns (google.protobuf.Struct);
  1. The corresponding TypeScript method looks like this:
Hello(request: HelloRequest): Observable<Struct>;
  1. When using this method, the generated code does not produce an { [key: string]: any } but relies on the Struct class.

Expected Behavior:
I expect the generated TypeScript code to produce an object for the return type instead of using the Struct class directly.

Actual Behavior:
The generated code uses the Struct class directly in the return type of the method.

Additional Information:

  • Version of ts-proto used: 1.147.2
  • TypeScript version: 5.2.2
  • Arguments: --ts_proto_opt=nestJs=true
@stephenh
Copy link
Owner

Hi @ablause ; this sounds somewhat similar to the issue that was recently fixed in:

#951

But that was for Value and this is for Structs...

I'm kinda guessing there, but if you could dig into that PR, and see if you could crib its approach (or at least it should get you to the right area of the code), and submit a PR for this, that'd be great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants