protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Enumeration of OneOf field

Open Lee-Ft opened this issue 2 years ago • 0 comments

protobuf.js version: <6.11.2>

When I use `OneOf` keyword in our proto, google's protoc plugin will generate an enumration in .cc and .h file. But when I use protobufjs to convert the same proto into ts and js, the only thing I got is an class with optional members. I want to know how to add the same enumeration in JS?

For example, I make the following proto:

message Msg {
  oneof MsgBody {
    TypeOne MsgOne = 1;
    TypeTwo MsgTwo = 2;
  }
}

The generated .h file will be like:

public enum MsgBodyOneofCase
{
  MsgOneOne = 1;
  MsgOneTwo = 2;
}

There are some similar issues in other projects, such as enum and property for oneof: protobuf.net

Thanks!

Lee-Ft avatar Nov 22 '23 04:11 Lee-Ft