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

Incorrect typings generated by pbts

Open Rubydesic opened this issue 5 years ago • 2 comments

protobuf.js version: 6.9.0 suppose I have the following proto file

message MessageA {
    MessageB message = 1;
}
message MessageB {
    oneof inner {
         string str1 = 1;
         string str2 = 2;
    }
}

The generated typescript definition looks like this

export class MessageA implements IMessageA {
    /* omitted irrelevant stuff */
    public message?: (IMessageB|null);
}

but this is WRONG. message actually still has the toJSON method and 'inner' field, etc. so it should be typed as following, right?:

export class MessageA implements IMessageA {
    /* omitted irrelevant stuff */
    public message?: (MessageB|null);
}

Rubydesic avatar Jul 17 '20 03:07 Rubydesic

is there a way we could setup a test to demonstrate this is what happens? maybe something that creates an instance of MessageA and then checks for the presence of messageA.message.toJSON

ferm10n avatar Apr 26 '22 01:04 ferm10n

We are running into the same issue. The properties on the class instance are of type class MessageB and not of (plain) object IMessageB.

JrSchild avatar Sep 14 '22 09:09 JrSchild