improbable-eng / ts-protoc-gen

Protocol Buffers Compiler (protoc) plugin for TypeScript and gRPC-Web.
Apache License 2.0
1.36k stars 173 forks source link

Error of protoc compiles FieldOption when using a enum from other proto #299

Open hantien opened 2 years ago

hantien commented 2 years ago

Versions of relevant software used ts-protoc-gen: 0.15.0

What happened Encountered error when protoc compiles typescripts for FieldOption and the proto uses an enum from the other proto.

Example:

example_field_option.proto

extend google.protobuf.FieldOptions { Req req = 2000; }

This would fail if Req (enum) is from another proto (ex: my_enum.proto) Error: export const requirement: jspb.ExtensionFieldInfo<api_protos_my_enum_mask_pb.Req>; However, api_protos_my_enum_mask_pb.Req is considered as a value It should use ReqMap instead.

If the enum is in the same proto, the protoc generates the right stub without errors.

What you expected to happen

Support importing enums from other files for field_option use case.

How to reproduce it (as minimally and precisely as possible):

  1. Create a proto (a.proto) with a FieldOption
  2. Create another proto (b.proto) with an enum
  3. Import the enum from b.proto to a.proto and use in the FieldOption
  4. Run protoc to generate typescript for a.proto