-
Notifications
You must be signed in to change notification settings - Fork 12.8k
No type inferrence of callback arguments inside a tuple union type #55632
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
Comments
I think this is one of the issues that prevents #42987 from working. (discriminated unions of tuples don't seem to get contextual typing the way discriminated unions of non-tuple objects do) |
I had this for a while on my wishlist already - might give it a try soon-ish. The problem stems from the fact that This particular case maybe would just work if we'd call |
Thank you for the explanation |
I think I have a fix for this issue: fwolff@9eecc30. It works with the code snippet given by @nenikitov, the type of the parameter The change is minimal and inspired by what @Andarist suggested in his comment. Before going further, I'd like to get some feedback from @jcalz (I have been discussing tuple issues with him here and on stackoverflow) or anybody having worked on similar topics. |
See my PR: #60434. |
…d of .map/.filter, add new test cases)
🔎 Search Terms
🕗 Version & Regression Information
tsserver 3.3.2
⏯ Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgdgMwgJwILIOZQLwCgpQA+UA2gIwA0UAFAIYBcUcArgLYBGKAlDgHxQA3APYBLACYBdfEVIAmKtXaMAzsGQi4GHtn7DxEgNy4AxkLiqotTI3hI0mHKUo1a2-gG8oAX0O4gA
💻 Code
🙁 Actual behavior
I get a compilation error:
🙂 Expected behavior
a
should be inferred to be anumber
because I already passed1
as the first tuple element. Type inference should be identical to this code:Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: