Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to disable detection of wrappers type? #756

Open
raymondsze opened this issue Jan 6, 2023 · 3 comments
Open

Any way to disable detection of wrappers type? #756

raymondsze opened this issue Jan 6, 2023 · 3 comments

Comments

@raymondsze
Copy link

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.

@stephenh
Copy link
Owner

stephenh commented Jan 6, 2023

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!

@raymondsze
Copy link
Author

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....

@stephenh
Copy link
Owner

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 Timestamps 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants