Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses const types for
requestStream
andresponseStream
, eithertrue
or
false
types instead of genericboolean
TS types allowing advancedcall type inference from the service definition.
Higher abstraction framework libraries, such as
https://github.com/malijs/mali could leverage advanced type inference to
hint/check specific type handlers if this information would be part of
the type rpc service type definition.
At this point, the only way to determine thy type of RPC is using
I{{{serviceName}}}Server
interface, which must be linked manually toI{{{serviceName}}}Service
methods. For registring handlers at runtime,only e.g.
GreeterService
and corresponding implementation is required,manually adding
IGreeterServer
is possible, but troublesome. Thiswould not be required if rpc type could be inferred using the const
booleans to define the type.
This change does is not a breaking change and the const boolean types
are working correctly since the oldest available version on TS
playground 2.4.1. See playground link in the trailers.
There are no obvoius disadvantages to using const booleans and change
could potentially give node grpc frameworks more power for sophisticated
type inference.
There are no tests in the project, but so at least I tried it manually
with
npm link
on a custom project and it behaves as expected.See: https://www.typescriptlang.org/play/?ts=2.4.1#code/MYewdgzgLgBAhsYBTADlAKgJwK5JgXhgAoA3OAGwC4YockBKAgPhjPIChRJYFk0AxChDyFSFagDMhDZqwrt2vVBjpEp5YfUWJlgjUjXStStFlxFauYzoHSLdekA