Bug Report
๐ Search Terms
variance, conditional, subtype, limit
๐ Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about variance and conditionals.
โฏ Playground Link
Playground link with relevant code
๐ป Code
interface Base {
base: unknown;
}
interface Sub extends Base {
sub: unknown;
}
function transform<T extends Base>(t: T): T extends Sub ? Sub : T {
return t;
}
๐ Actual behavior
"Type 'T' is not assignable to type 'T extends Sub ? Sub : T'."
๐ Expected behavior
No errors. Either T extends Sub, and so is assignable to it, or it doesn't, and so is assignable to itself.
Bug Report
๐ Search Terms
variance, conditional, subtype, limit
๐ Version & Regression Information
โฏ Playground Link
Playground link with relevant code
๐ป Code
๐ Actual behavior
"Type 'T' is not assignable to type 'T extends Sub ? Sub : T'."
๐ Expected behavior
No errors. Either T extends Sub, and so is assignable to it, or it doesn't, and so is assignable to itself.