Skip to content

Commit

Permalink
Update ES6 .d.ts imports with comment about corresponding proto impor…
Browse files Browse the repository at this point in the history
…t path. (#1330)

#1313 updated the code generator to print a
`proto import: "foo/bar.proto"` suffix for each import statement for the
generated gRPC-web client code. This commit updates ensures the .d.ts file
output by grpc-web contains the same type of comments.
  • Loading branch information
gonzojive authored Oct 5, 2023
1 parent 9cb8524 commit 3cd7e0d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions javascript/net/grpc/web/generator/grpc_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,12 @@ void PrintProtoDtsFile(Printer* printer, const FileDescriptor* file) {
printer->Print("import * as jspb from 'google-protobuf'\n\n");

for (int i = 0; i < file->dependency_count(); i++) {
const string& name = file->dependency(i)->name();
const string& proto_filename = file->dependency(i)->name();
// We need to give each cross-file import an alias.
printer->Print("import * as $alias$ from '$dep_filename$_pb';\n", "alias",
ModuleAlias(name), "dep_filename",
GetRootPath(file->name(), name) + StripProto(name));
printer->Print("import * as $alias$ from '$dep_filename$_pb'; // proto import: \"$proto_filename$\"\n",
"alias", ModuleAlias(proto_filename),
"dep_filename", GetRootPath(file->name(), proto_filename) + StripProto(proto_filename),
"proto_filename", proto_filename);
}
printer->Print("\n\n");

Expand Down

0 comments on commit 3cd7e0d

Please sign in to comment.