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 functions combining a conditional type and an intersection are not assignable to themselves #51399
Type '<T>() => (T extends true ? true : false) & boolean' is not assignable to
type '<T>() => (T extends true ? true : false) & boolean'.
Two different types with this name exist, but they are unrelated.
Type 'false' is not assignable to type '(T extends true ? true : false) & boolean'.
Also, the following unexpectedly removes the error message:
Removing & boolean
Replacing T extends true ? true : false by true
Replacing T extends true ? true : false by T extends true ? true : true
Replacing b's type by typeof a
🙂 Expected behavior
Since the two types are identical, a and b should be assignable to each other.
Sorry for a bit unrelated comment (it's too long to search for similar issues and I'm too lazy to create a new one), but similar thing happening here when I try to return 1 and 2. It throws error saying Type '1' is not assignable to type 'Options["enabled"] extends true ? 1 : 2'.ts(2322).
Activity
ahejlsberg commentedon Nov 4, 2022
Hmm, yeah, this looks like an issue in type inference between similar intersections.
ehmicky commentedon Nov 5, 2022
Thanks a lot Anders Hejlsberg (@ahejlsberg) for the quick fix! 🚀
FrameMuse commentedon Jan 12, 2023
Sorry for a bit unrelated comment (it's too long to search for similar issues and I'm too lazy to create a new one), but similar thing happening here when I try to return
1and2. It throws error sayingType '1' is not assignable to type 'Options["enabled"] extends true ? 1 : 2'.ts(2322).RyanCavanaugh commentedon Jan 12, 2023
Valery Zinchenko (@FrameMuse) see #33912