I have a bunch of proto files that I compiled to Typescript with the following script:
yarn proto-loader-gen-types \
--grpcLib=@grpc/grpc-js \
--outDir=${OUT_DIR} \
${IN_DIR}/*.proto
One of the messages defined is Bool
:
message Bool {
bool state = 1;
}
When I look at the compiled Typescript files, ALL of the object properties are defined as optional.
export interface Bool {
'state'?: (boolean);
}
export interface Bool__Output {
'state'?: (boolean);
}
I've been writing tests and when I expect true
I seem to be getting the expected object { state: true }
but when I'm expecting false
, I get an empty object {}
instead of the object shape that I expect { state: false }
.
How do I compile my proto files to Typescript and make sure that non-optional properties are actually defined as such?