You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the way we break down intersections makes it impossible to recognize the equivalence here. We compare the intersection one member at a time and see if either member on their own is assignable to the SomeType intersection. {test: string} isn't assignable - it's not guaranteed to have Base's props. Derived isn't assignable because it's missing test (keyof Base | "test" is not assignable to keyof Derived).
@ahejlsberg have we just been marking issues like this as a design limitation, or are we planning to do something about it?
TypeScript Version: Version 2.9.0-dev.20180405
Search Terms: extends generic intersection index
Code
Expected behavior:
fails0
ingeneric()
should compileActual behavior:
fails0
ingeneric()
failsPlayground Link: Link here
Intuitively, to me, it should work out fine.
Derived
has all the fields ofBase
; possibly more.test
.Derived
is assignable toBase
Derived & { test: string }
should be assignable toBase & { test: string }
The text was updated successfully, but these errors were encountered: