-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Narrowing with a typeguard fails after object spread #55876
Comments
More accurately, duplicate of #42384 (there’s no discriminated union here). |
From #42384:
Not sure it's my case, I already declare new type ( |
It’s the same thing. Your type check narrows |
Just additionally pointing out that the |
@MartinJohns you right, it's mistake in example |
🔎 Search Terms
typeguard narrowing, object spread
🕗 Version & Regression Information
This is the behavior in every version I tried, and I recheck handbook about:
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/JYOwLgpgTgZghgYwgAgCIBUDyyDeAoZZGAe2IC5kBnMKUAcwG4DkAjOKAfgutpEbwC+ePKEixEKDJgDqwMAAsAQu2QQAHpBAATSmiy5mbKNxr0mQvAmIhqqmwFcoEZVACSlAMoQwyALzIACi0wcj1MAEo-AD5kAEJY4OIAOiMmPAB6dOQPAAcnOC1kBHzIXThWezo8GHsQBDBga2QAWzhQALUKKXCurFkFFwNCYBhA2LUU9kj8QkIJoz9kAHItCHh7ABswJaZCC0IIBycXdy8wDvC0wisbHwBPRfn2BmRM5AfgXR56WOZmJzAjhAQ1mSTBamYQgsb368mI9h8lDyEAKyAA7sQoABrMq6dQ5CD1CBaaq1eqNYEsBEdXoRWmwwYzZAjMZPKDTZhzSZQRYrNZwTbbXbIfZ2SiOZzsU7eC5XIrWWwPfxsl6vLIfL6mPi-Qj-bxAkGEEihCbGgA0nNY7AobMhgmEQA
💻 Code
🙁 Actual behavior
Typescript ignore type guard if spread used
🙂 Expected behavior
Typescript respect type guard even after spread
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: