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

Could we support friendlier object-literal syntax for service methods? #288

Open
githorse opened this issue Sep 8, 2021 · 1 comment
Open
Labels

Comments

@githorse
Copy link

githorse commented Sep 8, 2021

In grpc-js, at least according to the GRPC.io docs, I can do things like this:

client.sayGoodNight({name: 'Gracie'}, ... );

But with the Typescript version that doesn't seem to be possible; instead, I need to create a HelloRequest object explicitly and set the name:

const request = new GoodNightRequest()
request.setName('Gracie')
client.sayGoodNight(request, ... )

Personally I'm irked by both the mutable state and the boilerplate of the setter syntax and strongly prefer the object-literal {name: 'Gracie'} version. (For me that's most of the fun of writing Javascript!) Does, or could, this library support that streamlined syntax? I see that GoodNightRequest.AsObject in good_night_pb.d.ts actually does define the necessary interface, but it doesn't look like sayGoodNight will accept anything but an instance of the GoodNightRequest class.

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant