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

Fix Protobuf .d.ts typings for .proto files without package #941

Merged
merged 1 commit into from
Sep 1, 2020
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: 3 additions & 1 deletion javascript/net/grpc/web/grpc_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,13 @@ string JSElementType(const FieldDescriptor *desc, const FileDescriptor *file) {

case FieldDescriptor::TYPE_ENUM:
if (desc->enum_type()->file() == file) {
// [for protobuf .d.ts files only] Do not add the module prefix for
// local messages.
string enum_name =
StripPrefixString(
desc->enum_type()->full_name(),
desc->enum_type()->file()->package());
return enum_name.substr(1);
return StripPrefixString(enum_name, ".");
}
return ModuleAlias(desc->enum_type()->file()->name())
+ StripPrefixString(
Expand Down
10 changes: 10 additions & 0 deletions packages/grpc-web/test/protos/test01.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@ message MessageOuter {
int32 value = 1;
}

enum EnumInner {
DEFAULT = 0;
}

repeated MessageInner someProp = 1;
EnumOuter someEnum = 2;
EnumInner anotherEnum = 3;
}

enum EnumOuter {
DEFAULT = 0;
}