-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Narrowing works incorrectly when destructuring #50604
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
Not if |
Well, that's the part I'd expect Typescript to figure out for me that |
The return value is guaranteed not to contain property |
Perhaps this is sufficient for your use case? function removeX<T extends Record<string, any>>({x, ...rest}: T): Omit<T, "x"> {
return rest;
} |
Thanks all for the explanations! |
Bug Report
π Search Terms
destructure, union, narrowing
π Version & Regression Information
v.4.7.4
,v4.8.0-beta
.β― Playground Link
Playground link
π» Code
π Actual behavior
It produces the following error:
π Expected behavior
There should be no error since
Omit<T & { x: X; }, "x">
is essentially equal toT
.The text was updated successfully, but these errors were encountered: