fix(grpc): Fix typings

This commit is contained in:
Slavo Vojacek 2020-09-02 20:32:31 +01:00
parent 0d1d5a12fa
commit fba1ee0cc3
2 changed files with 6 additions and 6 deletions

View File

@ -146,7 +146,7 @@ export class Server {
addService<
ImplementationType extends {
readonly [index in keyof ImplementationType]: UntypedHandleCall;
[key: string]: any
}
>(
service: ServiceDefinition<ImplementationType>,
@ -165,7 +165,7 @@ export class Server {
throw new Error('addService() requires two objects as arguments');
}
const serviceKeys = Object.keys(service) as Array<keyof ImplementationType>;
const serviceKeys = Object.keys(service);
if (serviceKeys.length === 0) {
throw new Error('Cannot add an empty service to a server');
@ -193,13 +193,13 @@ export class Server {
let impl;
if (implFn === undefined && typeof attrs.originalName === 'string') {
implFn = implementation[attrs.originalName as keyof ImplementationType];
implFn = implementation[attrs.originalName];
}
if (implFn !== undefined) {
impl = implFn.bind(implementation as any);
impl = implFn.bind(implementation);
} else {
impl = getDefaultHandler(methodType, name as string);
impl = getDefaultHandler(methodType, name);
}
const success = this.register(

View File

@ -181,7 +181,7 @@ describe('Server', () => {
const server = new Server();
assert.throws(() => {
server.addService({} as any, dummyImpls);
server.addService(({} as any), dummyImpls);
}, /Cannot add an empty service to a server/);
});