To my understanding typescript should just try to check if NestedGeneric<'A'> is assignable to constraint NestedGeneric<Variable>
While doing it, it should check if type parameter T in NestedType is invariant or covariant (correct me if I am messing up the terminology). If the NestedType is a distributive conditional type over T, the T is covariant, otherwise, by default, it is invariant. If it is invariant, and the given type (of T) is not exactly the same as the constraint, ts throws an error.
Otherwise, it goes deeper.
Therefore
type NestedGenericHandlerA = NestedGenericHandler<NestedGeneric<'A'>>;
raises TS error, and the "expected solution" works
type NestedGenericDistributive<T extends Variable> = T extends any
? { generic: Generic<T> }
: null;
this is covariant case and everything is ok.
So, the first question is - is the above explanation correct?
Now, if it is correct, then what is going on in the code that goes below the "expected solution"?