Skip to content

Commit

Permalink
feat: change channel options to client options in generate grpc/js (#704
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Focadecombate committed Nov 15, 2022
1 parent dd78cff commit c4ac8ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions integration/grpc-js/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import {
CallOptions,
ChannelCredentials,
ChannelOptions,
Client,
ClientDuplexStream,
ClientOptions,
ClientReadableStream,
ClientUnaryCall,
ClientWritableStream,
Expand Down Expand Up @@ -617,7 +617,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;
new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): TestClient;
service: typeof TestService;
};

Expand Down
7 changes: 3 additions & 4 deletions src/generate-grpc-js.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Code, code, def, imp, joinCode } from "ts-poet";
import { FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors";
import { camelCase } from "./case";
import { Context } from "./context";
import SourceInfo, { Fields } from "./sourceInfo";
import { messageToTypeName, wrapperTypeName } from "./types";
import { messageToTypeName } from "./types";
import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment, maybePrefixPackage } from "./utils";
import { generateDecoder, generateEncoder } from "./encode";

const CallOptions = imp("CallOptions@@grpc/grpc-js");
const ChannelCredentials = imp("ChannelCredentials@@grpc/grpc-js");
const ChannelOptions = imp("ChannelOptions@@grpc/grpc-js");
const ClientOptions = imp("ClientOptions@@grpc/grpc-js");
const Client = imp("Client@@grpc/grpc-js");
const ClientDuplexStream = imp("ClientDuplexStream@@grpc/grpc-js");
const ClientReadableStream = imp("ClientReadableStream@@grpc/grpc-js");
Expand Down Expand Up @@ -236,7 +235,7 @@ function generateClientConstructor(fileDesc: FileDescriptorProto, serviceDesc: S
new (
address: string,
credentials: ${ChannelCredentials},
options?: Partial<${ChannelOptions}>,
options?: Partial<${ClientOptions}>,
): ${serviceDesc.name}Client;
service: typeof ${serviceDesc.name}Service;
}
Expand Down

0 comments on commit c4ac8ac

Please sign in to comment.