Skip to content

Commit

Permalink
Merge pull request #1556 from slavovojacek/master
Browse files Browse the repository at this point in the history
fix(grpc-js): Add support for impl type to server.addService
  • Loading branch information
murgatroid99 committed Sep 2, 2020
2 parents 1178d55 + fba1ee0 commit e21f337
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ export class Server {
throw new Error('Not implemented. Use addService() instead');
}

addService(
service: ServiceDefinition,
implementation: UntypedServiceImplementation
addService<
ImplementationType extends {
[key: string]: any
}
>(
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 e21f337

Please sign in to comment.