Skip to content

Commit

Permalink
chore(Typings): Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
slavovojacek committed Sep 2, 2020
1 parent 38e988e commit 0d1d5a1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ export class Server {
}

addService<
ImplementationType extends Record<
string,
UntypedHandleCall
> = UntypedServiceImplementation
ImplementationType extends {
readonly [index in keyof ImplementationType]: UntypedHandleCall;
}
>(
service: ServiceDefinition<ImplementationType>,
implementation: ImplementationType
Expand All @@ -166,7 +165,7 @@ export class Server {
throw new Error('addService() requires two objects as arguments');
}

const serviceKeys = Object.keys(service);
const serviceKeys = Object.keys(service) as Array<keyof ImplementationType>;

if (serviceKeys.length === 0) {
throw new Error('Cannot add an empty service to a server');
Expand Down Expand Up @@ -194,13 +193,13 @@ export class Server {
let impl;

if (implFn === undefined && typeof attrs.originalName === 'string') {
implFn = implementation[attrs.originalName];
implFn = implementation[attrs.originalName as keyof ImplementationType];
}

if (implFn !== undefined) {
impl = implFn.bind(implementation);
impl = implFn.bind(implementation as any);
} else {
impl = getDefaultHandler(methodType, name);
impl = getDefaultHandler(methodType, name as string);
}

const success = this.register(
Expand Down

0 comments on commit 0d1d5a1

Please sign in to comment.