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
The text was updated successfully, but these errors were encountered:
ChuckJonas
changed the title
Intercetion of Generics is not recognized as equivalent
Intersection of two generic to form a third is not recognized as equivalent
Jan 13, 2019
ChuckJonas
changed the title
Intersection of two generic to form a third is not recognized as equivalent
Intersection of two generic params to form a third is not recognized as equivalent
Jan 13, 2019
I believe the error is correct here. Yes R1 & R2 is assignable to the default of R, but R might be instantiated with a more specific type. Consider the following instantiation.
hmm ya that's a good point. The goal here was to eventually get to where you could just specify the return type R and get type safety that mapState2Props & mapDispatch2Props combined would result in a valid R Object.
However... I'm not sure if that is even possible... Seem like you would need to instead define R1 & R2 as some subset of R, but they are dependent on each other...
TypeScript Version: 3.3.0-dev.201xxxxx
Search Terms:
Intersection of generics
Code
Expected behavior:
I would expect that this would be valid because I have defined
R = R1&R2
in the generic signature.Actual behavior:
Get an error
Type 'R1 & R2' is not assignable to type 'R'.
on the return statement. I've also triedR extends R1&R2
and I get the same error.Playground Link:
Link
Related Issues:
#5823
The text was updated successfully, but these errors were encountered: