Given a union of:
type Status =
| "Loading"
| "Success"
| "Error"
I was expecting this to work:
type Success = Status extends "Success" ? Status : never;
const s: Success = "Success";
However, the above results in
Type 'string' is not assignable to type 'never'.
Whereas, if I use what I thought was an equivalent:
type E<T, U> = T extends U ? T : never;
type Success = E<Status, "Success">;
const s: Success = "Success";
It compiles without a problem. Now, I know that the E type I've created is pretty much how Extract works. I'd just like to understand, what makes it behave differently in the above two cases.