-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Object destructuring loses type inference #27497
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
It does not "lose" type inference, the type inference just does not work the way you expect it. You're not checking There are numerous issues about this exact issue, that the type narrowing is not tracked across variables. |
How can I work around this and force typescript to infer the type from the assignment? Edit: seems like this should be working starting with Typescript 4.4 (#44730) Edit2: Not working, posted in that same PR about the weird issue I'm having: #44730 (comment) |
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.1.1
Search Terms:
Code
Expected behavior:
Both
checkOne
andcheckTwo
compiled without errors.Actual behavior:
Function
checkTwo
has compilation errors.Playground Link: typescriptlang.org
Related Issues: I can't find related issues, but I am sure this is already known issue.
The text was updated successfully, but these errors were encountered: