Closed
Description
Bug Report
π Search Terms
2367 types overlap
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ
β― Playground Link
Playground link with relevant code
π» Code
interface Base { x: number }
class C<T extends Base> {
constructor(readonly x: T) {}
foo<U extends Base>(y: U) {
if (y === this.x) {} // <-- error: 'U' and 'T' have no overlap
}
}
π Actual behavior
An error is raised on the if
clause.
This comparison appears to be unintentional because the types 'U' and 'T' have no overlap.(2367)
π Expected behavior
Both U
and T
are constrained by Base
, so they conceivably could overlap, so comparing them should be OK (and as a side-effect, it'd be nice if the comparison also refined U
to T
inside the if
block).