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.