-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Generated Typescript types for bound vectors return any
from the get
method
#20859
Comments
That would be a better return type. Unfortunately, there's not a way to express that right now with how |
I don't think I understand. Why can't you just change |
@Mike-Bell I think because of the way the C++ and the bindings work, it's difficult to express something as being possibly undefined on the JS side - unless its wrapped in |
Yea, I spent a few minutes looking at the ts-generation code and it made some sense to me as well - the return of vector access has to be an
If I had my way, I don't think I'd want to change the way vector access actually works to be more cumbersome on my JS - I think the way it currently behaves is fine, and I don't want to have to unwrap an optional every time I do vector access. I'd love to just see the |
Hm, looking at this, looks like they're giving us what I want. I don't think I really understand the way |
I changed my approach for |
Hello everyone.
this code generate typescript like
I need optional in order to generated typescript like but when I
is there a way to strict JS developer to check the return value before using it ? |
@mikayelvertex What does your binding code look like at the moment? When you bind your function, there is a 3rd argument you can pass policies to, something like this
|
yes |
Using pointers with optional will work with #21769. For future reference, it's better to file a new issue so the comments aren't missed. |
Generated TypeScript types for bound vectors look similar to:
However the
any
returned fromget
harms type safety quite a bit - taking the example above, wouldn'tThing | undefined
be a more preferable return type?The text was updated successfully, but these errors were encountered: