Skip to content

Commit

Permalink
fix(grpc-js): Add support for impl type to server.addService
Browse files Browse the repository at this point in the history
  • Loading branch information
slavovojacek committed Aug 31, 2020
1 parent 4b9da2e commit 38e988e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,14 @@ export class Server {
throw new Error('Not implemented. Use addService() instead');
}

addService(
service: ServiceDefinition,
implementation: UntypedServiceImplementation
addService<
ImplementationType extends Record<
string,
UntypedHandleCall
> = UntypedServiceImplementation
>(
service: ServiceDefinition<ImplementationType>,
implementation: ImplementationType
): void {
if (this.started === true) {
throw new Error("Can't add a service to a started server.");
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/test/test-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('Server', () => {
const server = new Server();

assert.throws(() => {
server.addService({}, dummyImpls);
server.addService({} as any, dummyImpls);
}, /Cannot add an empty service to a server/);
});

Expand Down

0 comments on commit 38e988e

Please sign in to comment.