Skip to content

Commit

Permalink
Made constructor arguments credentials and options optional
Browse files Browse the repository at this point in the history
Currently the TypeScript generated clients require that `null` be passed to `credentials` and `options` if they're not being used.  It's easier to simply make those arguments optional.  I've left the `null` portion of the type though to maintain backwards compatibility.
  • Loading branch information
jonahbron authored and stanley-cheung committed Mar 26, 2019
1 parent 9117705 commit aadfb92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions javascript/net/grpc/web/grpc_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ void PrintTypescriptFile(Printer* printer, const FileDescriptor* file,
"credentials_: null | { [index: string]: string; };\n"
"options_: null | { [index: string]: string; };\n\n"
"constructor (hostname: string,\n"
" credentials: null | { [index: string]: string; },\n"
" options: null | { [index: string]: string; }) {\n");
" credentials?: null | { [index: string]: string; },\n"
" options?: null | { [index: string]: string; }) {\n");
printer->Indent();
printer->Print("if (!options) options = {};\n");
if (vars["mode"] == GetModeVar(Mode::GRPCWEB)) {
Expand Down Expand Up @@ -734,8 +734,8 @@ void PrintGrpcWebDtsClientClass(Printer* printer, const FileDescriptor* file,
printer->Indent();
printer->Print(
"constructor (hostname: string,\n"
" credentials: null | { [index: string]: string; },\n"
" options: null | { [index: string]: string; });\n\n");
" credentials?: null | { [index: string]: string; },\n"
" options?: null | { [index: string]: string; });\n\n");
for (int method_index = 0; method_index < service->method_count();
++method_index) {
const MethodDescriptor* method = service->method(method_index);
Expand Down

0 comments on commit aadfb92

Please sign in to comment.