-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Intersection Type not merging objects in array properly #52073
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
|
Thanks for replying. That would fix this, but it is a contrived example to show the issue. I can't use that fix in the real issue I'm having. What I am wondering is if the error I am getting now is a bug introduced in TS 4.9 since that used to work. (and the issue also shows up in two other versions, and then seems to be fixed again) Looking at specs (though depricated) it looks like the intended behaviour of the intersection type would be to merge the two types to something like: |
Duplicate of #41874 |
Yes, sorry I didn't find that when searching. Will close this one then. |
by the way @jcalz, any idea why my code example seems to work on version 4.8, but not 4.9? |
Bug Report
π Search Terms
intersection type, intersection type array
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
radius field gets type error:
Object literal may only specify known properties, and 'radius' does not exist in type 'Colorful'
It looks like it is treating it as a union type where only one of the fields can exist.
π Expected behavior
I expected the merging of the types to make color and radius accessible (and required) in the
ColorfulCircle
type.The text was updated successfully, but these errors were encountered: