mirror of https://github.com/grpc/grpc-node.git
fix(grpc-js): Add support for impl type to server.addService
This commit is contained in:
parent
4b9da2ef7b
commit
38e988ea03
|
@ -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.");
|
||||
|
|
|
@ -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/);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue