Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change channel options to client options in generate grpc/js #704

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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