-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
any type in callback parameter #1584
Comments
Yes; parentheses "turns off" contextual typing. It is definitely something we're aware tends to be a problem for many, and #920 moves to give you the behavior you expect. |
The problem is that I have code like this: f((function(d){ I do need parentheses here and then I lose type safety:( |
@nn there is nothing we can do in that case. Contextual typing wouldn't apply anyways as the expression being passed to 'f' is the '.bind' call, not the function expression. |
I see but in the function itself I expect parameter "d" to be a number and get an appropriate code completion. Also there is a workaround specifying type explicitly : x((function (d:number){ I really would like to make the compiler inferring the type instead of writing by myself. Thanks . |
I see - so you want contextual typing to apply simply for the sake of editing prior to the call to |
It is pretty annoying but I don't know how to solve it . |
As a note, compiling with the |
Thanks. In any case I would like to see some solution for this. |
See #212 |
Additionally, we have contextual typing on parenthesized expressions in |
Is it intended behavior ?
Adding parentheses around the function makes 'd' to be any type:
The text was updated successfully, but these errors were encountered: