-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
protoc-gen-grpc-gateway-ts plugin for generating Typescript types #1182
Comments
Hey Jamie, thanks for the issue! Are these types generated straight from the proto? We usually see users generate typescript types and functions using the generated swagger file as an intermediate. Maybe that would work for your use case too? As you surmise I'm not sure we want to take on this in the main repo, especially since it can just live as a third party plugin. |
Yeah, these are generated straight from the proto :) |
Jamie, I would be happy to add a link to your repo in the README. WDYT? |
Oh yeah, you're welcome to. It's a gist, because I don't want to give anyone the impression it's fully supported. Understand if that changes your decision. 😂 https://gist.github.com/majelbstoat/5f73f58a057123c8d46db66ebbaae987 |
Ah, my mistake. I think we should only promote it if it has its own repo with issue tracking. |
just my 2 cents - we had the same issue.
need negative lookup since there are ObjectList vars in the generated code which should remain that way. |
grpc-gateway to JSON using the standard JSON marshaller. Unfortunately, the JS implementation of protobuf appends
List
to the field names ofrepeated
fields (see protocolbuffers/protobuf-javascript#42). This means that typescript definitions from those protos don't work. e.g.In addition, it treats int64s as numbers, instead of strings.
The result of this is that we can't strongly type responses from the gateway. I think you're actually doing the right thing, so I wrote a protoc plugin to generate grpc-gateway Typescript types.
Given the same input, it will output:
Not submitted as a PR, because it's pretty ropey and I don't know if you want it in core. It works well enough for me, but YMMV. Either way, the code is here, and maybe it will be helpful for folks even if it doesn't get merged.
The text was updated successfully, but these errors were encountered: