Skip to content

Commit

Permalink
fix: Add service to the client constructor. (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh committed Dec 23, 2021
1 parent 246aca8 commit 8c32104
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
14 changes: 8 additions & 6 deletions integration/grpc-js/grpc-js-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ describe('grpc-js-test', () => {
},
struct(
call: ServerUnaryCall<{ [key: string]: any } | undefined, { [key: string]: any }>,
callback: sendUnaryData<{ [key: string]: any } | undefined>){
callback: sendUnaryData<{ [key: string]: any } | undefined>
) {
callback(null, call.request);
},
value(
call: ServerUnaryCall<any | undefined, any | undefined>,
callback: sendUnaryData<any | undefined>) {
value(call: ServerUnaryCall<any | undefined, any | undefined>, callback: sendUnaryData<any | undefined>) {
callback(null, call.request);
},
listValue(
call: ServerUnaryCall<Array<any> | undefined, Array<any> | undefined>,
callback: sendUnaryData<Array<any> | undefined>) {
callback: sendUnaryData<Array<any> | undefined>
) {
callback(null, call.request);
},
serverStreaming(call) {
Expand Down Expand Up @@ -147,7 +147,9 @@ describe('grpc-js-test', () => {

const client = new TestClient(`localhost:${port}`, ChannelCredentials.createInsecure());

expect.assertions(25);
expect.assertions(26);

expect(TestClient.service).toEqual(TestService);

client.unary({}, (err, res) => {
expect(res).toEqual({});
Expand Down
1 change: 1 addition & 0 deletions integration/grpc-js/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ export interface TestClient extends Client {

export const TestClient = (makeGenericClientConstructor(TestService, 'simple.Test') as unknown) as {
new (address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): TestClient;
service: typeof TestService;
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
Expand Down
1 change: 1 addition & 0 deletions src/generate-grpc-js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ function generateClientConstructor(fileDesc: FileDescriptorProto, serviceDesc: S
credentials: ${ChannelCredentials},
options?: Partial<${ChannelOptions}>,
): ${serviceDesc.name}Client;
service: typeof ${serviceDesc.name}Service;
}
`;
}

0 comments on commit 8c32104

Please sign in to comment.