|
I have set the following response in my proto file: message ServerResponse {
oneof response_kind {
bool available = 1;
string code = 2;
ErrorCode error = 3;
}
}The code generated by this: /**
* @generated from protobuf message smsServiceCommunicator.ServerResponse
*/
export interface ServerResponse {
/**
* @generated from protobuf oneof: response_kind
*/
responseKind: {
oneofKind: "available";
/**
* @generated from protobuf field: bool available = 1;
*/
available: boolean;
} | {
oneofKind: "code";
/**
* @generated from protobuf field: string code = 2;
*/
code: string;
} | {
oneofKind: "error";
/**
* @generated from protobuf field: smsServiceCommunicator.ErrorCode error = 3;
*/
error: ErrorCode;
} | {
oneofKind: undefined;
};
}AND: ...
internalBinaryWrite(message: ServerResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* bool available = 1; */
if (message.responseKind.oneofKind === "available")
writer.tag(1, WireType.Varint).bool(message.responseKind.available); // <-- ERROR
/* string code = 2; */
if (message.responseKind.oneofKind === "code")
writer.tag(2, WireType.LengthDelimited).string(message.responseKind.code); // <-- ERROR
/* smsServiceCommunicator.ErrorCode error = 3; */
if (message.responseKind.oneofKind === "error")
writer.tag(3, WireType.Varint).int32(message.responseKind.error); // <-- ERROR
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}When compiling I get the error: Do any of you know how should I handle this "oneof" case? |
Answered by
jcready
Nov 13, 2023
Replies: 2 comments
|
According to the manual you must have |
0 replies
Answer selected by
netayg
|
I did figure this out, I just didn't figure out how to disable this for the generated files only. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the manual you must have
strictNullChecksorstrictset totruein your tsconfig. Alternatively you can disable type-checking in the generated code with--ts_opt ts_nocheckpassed toprotoc.