-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Object spread unsound w.r.t. width subtyping of object types #15454
Comments
"somewhere" is doing a lot of work there 😉 . Where specifically should the error be (and by what process)? |
Hah, fair! I thought the example was small enough to make it clear :) One option would be to forbid width subtyping between object types, so the error would be on line 2. This is pretty limiting, so not a great option. Another option would be to error on line 3. Because the |
Without closed types, that's effectively the same as "don't allow spreading, ever", which doesn't really seem helpful. |
Just confirming this is by design. (I agree this is a reasonable tradeoff to make, FWIW) |
Yep |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: Whatever is running on TypeScript Playground
Code
Expected behavior:
Some type error somewhere.
o3
has type{p: string, q: number}
at runtime, but we thinkq
has typestring
.Actual behavior:
No error. Potential runtime type error.
The text was updated successfully, but these errors were encountered: