Expected
As per proto3's language guide:
Message fields can be one of the following:
- singular: a well-formed message can have zero or one of this field (but not more than one). And this is the default field rule for proto3 syntax.
Hence, I would expect the TypeScript code to allow singular fields to be undefined
syntax = "proto3";
message Message {
bytes payload = 1;
}
should generate
export interface Message {
payload?: Uint8Array
}
Actual
syntax = "proto3";
message Message {
bytes payload = 1;
}
generates
export interface Message {
payload: Uint8Array
}
Note
When using the optional keyword, I can get the desired effect:
message Message {
optional bytes payload = 1;
}
export interface Message {
payload?: Uint8Array
}
However, optional is not part of the proto3 syntax.
Expected
As per
proto3's language guide:Hence, I would expect the TypeScript code to allow singular fields to be undefined
should generate
Actual
generates
Note
When using the
optionalkeyword, I can get the desired effect:However,
optionalis not part of theproto3syntax.