While experimenting for a type isStrictlyAny
per the question here, I arrived at an expression:
type IsStrictlyAny<T> = (T extends never ? true : false) extends false ? false : true;
which when used then produces:
type t1 = IsStrictlyAny<any>; // true
type t2 = IsStrictlyAny<unknown>; // false
type t3 = IsStrictlyAny<string>; // false
type t4 = IsStrictlyAny<never>; // false!
This makes sense mostly. But for the last case I noted that "manually" expanding it like so:
type t5 = (never extends never ? true : false) extends false ? false : true; // true!!!
is true
, contradicting the above.
Why is this?