-
Notifications
You must be signed in to change notification settings - Fork 117
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
Feature request: Easier way to output typescript optionals, IE ?: Thing
for rust Option
types, rather than Thing | null
#364
Comments
skip_serializing_none
skip_serializing_none
for Option
types.
skip_serializing_none
for Option
types.skip_serializing_none
for Option
types, or output proper typescript optionals.
skip_serializing_none
for Option
types, or output proper typescript optionals.skip_serializing_none
for Option
types, or output proper typescript optionals by default.
Hey, thanks for opening the issue. Right now, there's no convenient alternative to |
That's reasonable. I can start to add those One other question: is there a reason why |
We chose this representation since it better matches what |
Ah so its matching serde. Gotcha, thx! |
@dessalines Can you reopen this issue? Maybe in the future there can be a better solution, because right now its extremely verbose (see LemmyNet/lemmy#5163). |
Sure, maybe the maintainers here could think of a good solution, ideally one that could be applied at the struct level. |
skip_serializing_none
for Option
types, or output proper typescript optionals by default.?: Thing
for rust Option
types, rather than Thing | null
I suppose we could make |
Is your feature request related to a problem? Please describe.
We're upgradiing our
ts-rs
from7.1.1
->10.0.0
, but unfortunately this upgrade broke all of ourOption
types.Beforehand, we could do this on a struct:
And this would generate:
With the upgrade, the above now generates:
admin: Person | null
This must be because ts-rs is now ignoring serde's
skip_serializing_none
directive.Describe the solution you'd like
Have ts-rs follow the above directive.
Describe alternatives you've considered
ts(optional)
to every single field, but this would be tedious and verbose.?
) , rather than outputtingthing | null
, which isn't the preferred way typescript deals with optionals.You don't need to get to into it if you don't want, but what's the short version for why ts-rs outputs
thing | null
rather than proper typescript optionals?The text was updated successfully, but these errors were encountered: