Let's say we have the following type I
:
type I = () => () => () => "a" | "b" | "c";
Is there a way to create a generic type Unwrap
such that Unwrap<I>
evaluates to "a" | "b" | "c"
?
type I = () => () => () => "a" | "b" | "c";
type Result = Unwrap<I>; // "a" | "b" | "c"
The following (ofc) produces a circularity error:
type Unwrap<
T extends (...args: any[]) => any,
R = ReturnType<T>
> = R extends (...args: any[]) => any
? Unwrap<R>
: R;
Any help would be greatly appreciated. Thank you!