Closed oloftus closed 3 months ago
this is normal TS behaviour - B is a subtype of A (any B is assignable to A), so TS simplifies to the widest type.
Thanks for the swift response. You're quite right. I hadn't even considered it might be coming from TS and that it is normal behaviour.
First off, thanks for the reduxjs project!
Here is a description of what I think is a bug.
See this repro for a reproduction. Reproduced with reselect@5.1.1.
NOK
When a selector returns a type
A | B | undefined
, and typesA
andB
have a key in common, the return type of the selector isA | undefined
instead ofA | B or undefined
.OK
When types
A
andB
do not have a key in common, the return type is correct, i.e.A | B | undefined
.OK
When types
A
andB
have a key in common, but the return union type does not includeundefined
, the return type is correct, i.e.A | B
.