grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.46k stars 762 forks source link

Fix Enum with module in generated TS interface. #1278

Closed sampajano closed 1 year ago

sampajano commented 1 year ago

Verified with the example in https://github.com/grpc/grpc-web/issues/1271

// enum.proto

syntax = "proto3";

enum DocEnum {
    DOC_ENUM_PDF = 0;
    DOC_ENUM_HTML = 1;
}

// test.proto

syntax = "proto3";

import "enum.proto";

package Test;

message HelloRequest {
    DocEnum doc = 1;
}

Generate:

protoc -I=. *.proto --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=typescript,mode=grpcwebtext:.

Before

getDoc(): enum_pbDocEnum;
setDoc(value: enum_pbDocEnum): HelloRequest;

After

getDoc(): enum_pb.DocEnum;
setDoc(value: enum_pb.DocEnum): HelloRequest;

Fixes https://github.com/grpc/grpc-web/issues/1271