thesayyn / protoc-gen-ts

Compile protocol buffer messages to TypeScript.
MIT License
362 stars 75 forks source link

Proto with oneof and other field is generated as union instead of intersect #235

Open neko-para opened 1 year ago

neko-para commented 1 year ago
message ControllerSetOptionRequest {
  optional string handle = 1;
  oneof option {
    int32 long_side = 101;
    int32 short_side = 102;
    string def_package_entry = 103;
    string def_package = 104;
  }
}
export class ControllerSetOptionRequest extends pb_1.Message {
    #one_of_decls: number[][] = [[101, 102, 103, 104], [1]];
    constructor(data?: any[] | ({} & (({
        long_side?: number;
        short_side?: never;
        def_package_entry?: never;
        def_package?: never;
    } | {
        long_side?: never;
        short_side?: number;
        def_package_entry?: never;
        def_package?: never;
    } | {
        long_side?: never;
        short_side?: never;
        def_package_entry?: string;
        def_package?: never;
    } | {
        long_side?: never;
        short_side?: never;
        def_package_entry?: never;
        def_package?: string;
    }) | ({    // <------------ Here should be &, but | is generated
        handle?: string;
    })))) {
        super();