You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic type is fully incompatible with conditional type #9305
functionfn<Textendsstring>(str: T): void{stras(Textendsstring ? T : T);// worksstras(Textendsnumber ? T : T);// should work but errors}
Actual behavior
Cannot cast `str` to `T extends number ? T : T` because `string` [1] is incompatible with `T extends number ? T : T` [2]. [incompatible-type]
I understand this is a very contrived example, but I was trying to come up with a minimal reproduction that demonstrates the issue clearly. We've hit this in real code, and I used something closer to a real example in the Try-Flow below.
Activity