-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Generic object can be widened unsafely #45335
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
|
How about adding some new tsconfig option? |
I don’t think such an option would be feasible. const rec: Record<string, number> = {
prop: 42
}; Or for that matter, even initializing it with |
@fatcerberus it's incorrect to say that if Counterexample: |
As Ryan pointed out, the same kind of unsoundness exists for all types with optional properties, so this isn’t unique to |
Yes, and this doesn't mean that we can leave everything as it is because of it. It just means that the problem, needs to be solved, simply takes on a larger outline. |
Duplicate of #39915 |
Bug Report
🔎 Search Terms generic type object wide
🕗 Version & Regression Information 4.4.0-dev.20210805
💻 Code
🙁 Actual behavior
T extends { prop: number }
is assignable toRecord<string, number>
🙂 Expected behavior
T extends { prop: number }
is not assignable toRecord<string, number>
The text was updated successfully, but these errors were encountered: