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

Rpc is not exported by ts-proto as it previously was #1029

Closed
ws-gregm opened this issue Apr 14, 2024 · 6 comments
Closed

Rpc is not exported by ts-proto as it previously was #1029

ws-gregm opened this issue Apr 14, 2024 · 6 comments

Comments

@ws-gregm
Copy link

It appears that this export has recently broken

error TS2305: Module '"ts-proto"' has no exported member 'Rpc'.

4 import { Rpc } from 'ts-proto';
@stephenh
Copy link
Owner

@ws-gregm huh, we did just ship #1027 cc @dasco144 , but I don't think importing Rpc from ts-proto was really working on purpose, previously.

I.e. the ts-proto package is meant to be "the code generator you run at build-time" and not really the "the runtime code / dependency your app uses to encode/decode data".

I.e. we should be generating a interface Rpc into the output of ts-proto, so that when you package up the AuthorMessage / BookMessage / etc messages, the interface Rpc type should be included in that.

So, dunno, I'm curious to learn if/how this was actually working before, but I think it's intended that you import Rpc from the ts-proto-generated code and not the ts-proto dependency itself.

@ws-gregm
Copy link
Author

Hey @stephenh thanks so much for getting back so quickly. Do you have an example of what this would look like or how I would use this?

so that when you package up the AuthorMessage / BookMessage / etc messages, the interface Rpc type should be included in that

@stephenh
Copy link
Owner

Hi @ws-gregm , sorry, an example of what? For better or worse, going through ts-proto's integration/ directory and looking for usages that are most similar to what you're trying to do is the best bet.

@ws-gregm
Copy link
Author

@stephenh Digging through there - it's not clear to me how to

  1. instantiate a grpc client
  2. Specify ip and port to grpc server

@stephenh
Copy link
Owner

@ws-gregm if you're using grpc-js, this example is probably a good one to copy/paste from:

https://github.com/stephenh/ts-proto/blob/main/integration/grpc-js/grpc-js-test.ts#L152

I'm going to close this issue out b/c I don't think it's related to a breaking change in the exports. If you'd like to submit any PRs to improve the docs for ^, that'd be great, thanks!

@ws-gregm
Copy link
Author

Hey @stephenh, maybe it's best if I open a discussion but responding here for context. I experimented with TestClient. It appears that TestClient doesn't include methods that return promises. Meanwhile, the benefit of the generated *ClientImpl classes is that they return promises.. To use the *ClientImpl, I would need to craft this mystical rpc object. There doesn't appear to be any obvious guidance on this matter in the tests. From my POV, the general aim is to drive generated client methods that return promises. What's the typical way to do this? Also, I eventually need to expose methods that return a stream. I tried combing through existing projects that use ts-proto and I'm not find clear guidance there either.

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