Open mkfsn opened 2 years ago
Hi folks, when started using grpc-web, I found that some types are always required in AsObject, but I'm wondering shouldn't they be optional?
AsObject
Here's the repo I created to explain the problem I have: https://github.com/mkfsn/protoc-gen-grpc-web-oneof
I first define the message like this:
message Echo { string id = 1; int64 type = 2; oneof element { string text = 16; double numeric = 17; } }
(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/d0df6d0a3c526491373d5ab24a539c2ac2c7efc7/echo.proto#L7-L10)
And then I run the command to generate the typescript file:
protoc -I=. echo.proto \ --grpc-web_out=import_style=typescript,mode=grpcwebtext:.
(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/main/Makefile#L2-L3)
After that I'm getting the following results in the _pb.d.ts file:
_pb.d.ts
export namespace Echo { export type AsObject = { id: string, type: number, text: string, numeric: number, } export enum ElementCase { ELEMENT_NOT_SET = 0, TEXT = 16, NUMERIC = 17, } }
(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/d0df6d0a3c526491373d5ab24a539c2ac2c7efc7/echo_pb.d.ts#L32-L33)
I'm wondering shouldn't text and numeric be optional like:
text
numeric
text?: string, numeric?: number,
I'm using version grpc-web 1.2.1 and using macos.
1.2.1
I'm not sure if this is intended or not, can anyone confirm this with me? Sorry if I'm wrong.
FYI - not sure if exactly related but we're updating how "?" is generated in https://github.com/grpc/grpc-web/pull/1445. Maybe it's relevant :)
Hi folks, when started using grpc-web, I found that some types are always required in
AsObject
, but I'm wondering shouldn't they be optional?Problem
Here's the repo I created to explain the problem I have: https://github.com/mkfsn/protoc-gen-grpc-web-oneof
I first define the message like this:
(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/d0df6d0a3c526491373d5ab24a539c2ac2c7efc7/echo.proto#L7-L10)
And then I run the command to generate the typescript file:
(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/main/Makefile#L2-L3)
After that I'm getting the following results in the
_pb.d.ts
file:(See also: https://github.com/mkfsn/protoc-gen-grpc-web-oneof/blob/d0df6d0a3c526491373d5ab24a539c2ac2c7efc7/echo_pb.d.ts#L32-L33)
I'm wondering shouldn't
text
andnumeric
be optional like:I'm using version grpc-web
1.2.1
and using macos.I'm not sure if this is intended or not, can anyone confirm this with me? Sorry if I'm wrong.