Incorrect casing for oneof types
masterkidan opened this issue · comments
Hey folks,
I am noticing a minor bug in the type definitions when I have a oneof
with a camel case name. Consider the following example
protoc
message FooResponse {
oneof fooType {
AType a = 5;
BType b = 6;
}
}
ts output
enum FooTypeCase {
}
js output
proto.api.FooResponse.FootypeCase = {
}
Notice the casing difference of the letter T
between js and ts. This leads to runtime breakages.
Ok, let me have a look.
Thanks @agreatfool !. Can you lmk if you are able to repro it with the above example? Our team is trying to upgrade to the latest namely-docker (which iternally uses grpc_tools_node_protoc_ts) and I noticed this bug.
The tools version the protoc plugin uses are: grpc_tools_node_protoc_ts@5.1.3 and grpc-tools@1.11.1
@masterkidan Yeah, I can reproduce it. I will check the js generator source codes here https://github.com/protocolbuffers/protobuf/blob/v3.17.3/src/google/protobuf/compiler/js/js_generator.cc#L535-L537, then have a fix later.
Thanks,
A quick note: Rather than surfacing these up as enums, can you instead use a typed object (or a constant type)? https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums
Given that these are just poco objects which dont have the ability to do reverse look up etc, it may make more sense to type them as objects (which is more accurate for how the type is structured().
@masterkidan OK, I'm considering to make it in the later breaking change release.
As this is not a backwards compatible change, I'd prefer to put several similar breaking changes together to one release, to reduce the impact.
Thanks! A quick question, regarding the current issue itself (around casing), can you provide some timeline for the fix?
16th Aug, next monday should be good.
Done. New version v5.3.2
released.
Ping me or reopen this directly if you still have some issues.