-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
satisfies
should work when an object is spread into another
#51569
Comments
Just FWIW, you probably shouldn't rely on this check to prevent runtime errors due to excess properties. It's a fairly limited lint check primarily designed to catch typos in object literals; it's still very easy to end up with extra properties: const faves = {
"red": "yes",
"green": false,
"blue": "kinda",
"platypus": false
};
const favoriteColors = faves satisfies Record<Colors, unknown>; // no error |
Spreads aren't subject to excess property checks and it's not clear to me that they ever could be in an ergonomic way. |
@RyanCavanaugh If this is Working As Intended, shouldn't #39998 be closed then? 😉 |
Awaiting More Feedback isn't the same as closed? 🙃 |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Suggestion
It looks like
satisfies
doesn't work when you spread an object into anotherTypeScript errors as expected
TypeScript does not error, but I think it should
I would expect the latter to also have a TypeScript error, to prevent
favoriteColors
from having undesired extra properties.Why? Well, because sometimes passing extra properties can break stuff.
🔍 Search Terms
satisfies, spread
The text was updated successfully, but these errors were encountered: