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

oneof produces type with required fields #280

Open ron23 opened 3 years ago

ron23 commented 3 years ago

proto3: when using oneof I expect to get a union of the various options. Right now all the fields are required.

// proto
message ABC {
  oneof something {
    string a = 1;
    string b = 2;
  }
// generated
export namespace ABC {
  export type AsObject = {
    a: string,
    b: string,
  }

I expected to get something like:

export namespace ABC {
    type A = {  a: string };
    type B = {  b: string };

    export type AsObject = A | B
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.