Consider this scenario with the type I
:
type I = () => () => () => "a" | "b" | "c";
How can we define a new generic type Unwrap
in such a way that Unwrap<I>
results in
"a" | "b" | "c"
?
type I = () => () => () => "a" | "b" | "c";
type Result = Unwrap<I>; // "a" | "b" | "c"
The code snippet below causes a circularity error:
type Unwrap<
T extends (...args: any[]) => any,
R = ReturnType<T>
> = R extends (...args: any[]) => any
? Unwrap<R>
: R;
Any assistance on resolving this issue would be highly appreciated. Thank you!