fix(grpc-js): Add support for impl type to server.addService

This commit is contained in:
Slavo Vojacek 2020-08-31 20:34:14 +01:00
parent 4b9da2ef7b
commit 38e988ea03
2 changed files with 9 additions and 4 deletions

View File

@ -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.");

View File

@ -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/);
});