Closed
Description
Bug Report
π Search Terms
2367 types overlap generic constraint
π Version & Regression Information
This changed between versions 4.7.4 and 4.8.2.
β― Playground Link
Playground link with relevant code
π» Code
class C<T> {
constructor(readonly x: T) {}
good<U extends T>(y: U) {
if (y === this.x) {}
}
bad<U extends T | string>(y: U) {
if (y === this.x) {} // <- OK in 4.7.4, error in 4.8.2
}
}
π Actual behavior
The code type-checks OK in 4.7.4.
In 4.8.2 error 2367 (types 'U' and 'T' have no overlap
) is thrown on the if
guard in bad()
.
π Expected behavior
T | string
includes T
, so there is overlap between the two sides of the comparison, therefore the diagnostic seems to be incorrect.