ts-proto
ts-proto copied to clipboard
Any way to disable detection of wrappers type?
As title. Is it possible to let ts-proto treat all google.protobuf.wrappers type as normal message field?
for example, instead of returning boolean, we return { value: boolean }.
I see the basicType function, the options.keepValue is hardcoded as false
.
Huh, I'm kinda surprised, but yeah I guess we don't have an option for that.
If you'd like to work on a PR for useWrapperTypes=true/false
, that'd be great. Thanks!
Actually it also includes all the Timestamp, Structs and Duration field.
I'm working a NestJs project and would like to generate the type definition.
I found this library but this library automatically convert all the google wrappers type to primitive type. And Nestjs use protobufjs behind, which by default won't convert these fields to corresponding primitive.
protobufjs contains pbts that can convert the protobuf file to typescript definition file, and of course, no NestJs interface.
The encode/decode method generated here is not compatible to protobufjs one as well.
Finally I choose to use pbts with manually typed interface for NestJs to solve my issue....
Ah yeah, another ts-proto user found this fix, using the protobufjs wrappers
to teach it about ts-protos custom types:
https://github.com/stephenh/ts-proto/pull/567/files#diff-03dbad58cc98518642d755fb4f33bafe8498ed71b1b17e9880e7b1a4c15a3598R30
So if you have nestJs=true
on, then Timestamp
s should have been working...
No one has contributed support for the other fields like Structs, Duration, etc.
It'd be great if you wanted to help flush out NestJS support for the other wrapper types, but also definitely np if you want to just keep using raw protobufjs/pbts.