Skip to content

Commit

Permalink
fix(grpc): Fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
slavovojacek committed Sep 2, 2020
1 parent 0d1d5a1 commit fba1ee0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Server {

addService<
ImplementationType extends {
readonly [index in keyof ImplementationType]: UntypedHandleCall;
[key: string]: any
}
>(
service: ServiceDefinition<ImplementationType>,
Expand All @@ -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');
Expand Down Expand Up @@ -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(
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({} as any, dummyImpls);
server.addService(({} as any), dummyImpls);
}, /Cannot add an empty service to a server/);
});

Expand Down

0 comments on commit fba1ee0

Please sign in to comment.