ts-proto
ts-proto copied to clipboard
Support for FieldOptions.JSType
Reference: https://protobuf.dev/reference/java/api-docs/com/google/protobuf/DescriptorProtos.FieldOptions.JSType
Hi!
In my proto file I have:
int64 foobar = 3 [jstype = JS_STRING];
In my generated ts file I get:
foobar: number;
Using the arguments:
--ts_proto_opt=onlyTypes=true
It should be this?
foobar: string;
Is there a configuration setting I am missing?
The closest configuration setting I can find is forceLong=string
, which isn't exactly the same thing.
Hi @beyers-luno , you're right, we don't currently support jstype
--this is the first I'm seeing it.
Happy to have you work on a PR if you'd like to add support for it, although I'm a little worried it might be complicated, like I'm not sure the matrix of "proto type <-> different jstype". I assume that's documented somewhere, but just might be tedious to handle all of the cases.
Would be great if you want to take a look though; thanks!
I'd be willing to take a stab at this
@dasco144 sounds good!
I think the toTypeName
in types.ts
is probably the best slice-point to say "this field should actually be type xyz".
Unfortunately that's just the type, and the encoding/decoding of that type is probably scattered around the encode/decode/toJSON/fromJSON methods. Like getEncodeWriteSnippet
and getDecodeReadSnippet
.
@stephenh I've got an PR ready for review 🙏
:tada: This issue has been resolved in version 1.173.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket: