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
interfaceBase{x: number}classC<TextendsBase>{constructor(readonlyx: T){}foo<UextendsBase>(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).
maybe related: #50893 (PR: #50978)
Bug Report
π Search Terms
2367 types overlap
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
An error is raised on the
ifclause.π Expected behavior
Both
UandTare constrained byBase, so they conceivably could overlap, so comparing them should be OK (and as a side-effect, it'd be nice if the comparison also refinedUtoTinside theifblock).maybe related: #50893 (PR: #50978)