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

Feature request: allow #[ts(optional)] on any type #379

Closed
tguichaoua opened this issue Feb 20, 2025 · 2 comments
Closed

Feature request: allow #[ts(optional)] on any type #379

tguichaoua opened this issue Feb 20, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@tguichaoua
Copy link

Is your feature request related to a problem? Please describe.
I have a macro that generates a struct with ::core::option::Option<_> (due to macro hygiene), and because of that, I cannot use ts(optional) on it.
Also in a more general way, I want to being able to mark a field as optional without having to use the Option type.

Describe the solution you'd like
Being able to mark a field as optional, whatever its type.

Describe alternatives you've considered
My current workaround for the ::core::option::Option<_> problem is to use ts(optional, as = "Option<_>") which isn't perfect.

@tguichaoua tguichaoua added the enhancement New feature or request label Feb 20, 2025
@gustavo-shigueo
Copy link
Collaborator

It is by design that #[ts(optional)] only works with Option, this has been discussed at length in the past, check out #175.

However, it is a bug that it does not work with a fully specified core::option::Option, this will be solved by #366, which changes how a type is verified to be an Option

@gustavo-shigueo
Copy link
Collaborator

While your particular problem will be fixed by #366, the feature you ask for will not be implemented,

I will close this issue and open a new one pointing to the fact that Option is vulnerable to type aliasing or otherwise spelling this type as anything other than Option, like fully qualifying it.

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

No branches or pull requests

2 participants