CanAssign<number | string, number> // boolean
We are checking can A assign to B.
Since A is number | string,
A can assign to B when A is number(true), andAcannot assign toBwhenA is string (false).
So the result is true | false = boolean.
If you want to make sure all branches are assignable,
use StrictCanAssign<A, B>.
Can
Aassign toBNote that when union is involved, the assignability is measured distributively. Meaning the result can be
Then | Else(i.e.booleanby default), instead of distinctiveThen(true) orElse(false).This is the correct behavior.