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');
|
throw new Error('Not implemented. Use addService() instead');
|
||||||
}
|
}
|
||||||
|
|
||||||
addService(
|
addService<
|
||||||
service: ServiceDefinition,
|
ImplementationType extends Record<
|
||||||
implementation: UntypedServiceImplementation
|
string,
|
||||||
|
UntypedHandleCall
|
||||||
|
> = UntypedServiceImplementation
|
||||||
|
>(
|
||||||
|
service: ServiceDefinition<ImplementationType>,
|
||||||
|
implementation: ImplementationType
|
||||||
): void {
|
): void {
|
||||||
if (this.started === true) {
|
if (this.started === true) {
|
||||||
throw new Error("Can't add a service to a started server.");
|
throw new Error("Can't add a service to a started server.");
|
||||||
|
|
|
@ -181,7 +181,7 @@ describe('Server', () => {
|
||||||
const server = new Server();
|
const server = new Server();
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
server.addService({}, dummyImpls);
|
server.addService({} as any, dummyImpls);
|
||||||
}, /Cannot add an empty service to a server/);
|
}, /Cannot add an empty service to a server/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue