The tldr; is - it helped me resolve two issues I couldn't figure out:
grpc.Server.addService(..) would not transpile no matter what I gave it in my typescript app - so I ignored that statement as you did
no matter what arguments I gave to "protoc" - it failed to generate the correct output (exp: it would reference the "window" global from browsers) - so I switch to grpc_tools_node_protoc as you did
grpc.Server.addService(..)
The following is just a more thorough account of my findings and why I wasn't able to resolve my issues without just doing what you did.
Something I've been banging my head against the wall is the Server addService(..) function - i.e. this:
// @ts-ignore
server.addService(SongsService, new SongsServer());
Without the ts-ignore - tsc doesn't succeed in the transpile and I can't understand why.
I've found number reports/issues related to this bit of code - but up until now I haven't been able to find a way to work-around the issue. The most relevant post I found was this:
https://github.com/grpc/grpc-node/issues/1766
But, that issue was reported over a year ago and apparently was fixed in grpc version 1.24.11.
Your demo is fantastic.
The tldr; is - it helped me resolve two issues I couldn't figure out:
grpc.Server.addService(..)
The following is just a more thorough account of my findings and why I wasn't able to resolve my issues without just doing what you did.
Something I've been banging my head against the wall is the Server addService(..) function - i.e. this:
In your code - you did the following:
Without the ts-ignore - tsc doesn't succeed in the transpile and I can't understand why.
I've found number reports/issues related to this bit of code - but up until now I haven't been able to find a way to work-around the issue. The most relevant post I found was this: https://github.com/grpc/grpc-node/issues/1766
But, that issue was reported over a year ago and apparently was fixed in grpc version 1.24.11.
I found some other issues that are related to this - exp: https://github.com/agreatfool/grpc_tools_node_protoc_ts/issues/79
But, again these posts are over a year old - so I must be missing something else.
Anyway, your sample/tutorial helped me overcome that issue - i.e. disabling the typescript check on that statement.
protoc vs grpc_tools_node_protoc
No matter what arguments I gave to protoc - it
the generated code would create a statement like the following in the code:
You can read about this issue here: https://github.com/protocolbuffers/protobuf-javascript/issues/8
I tried using a variety of different versions of various tools, plugins, etc to no avail.