Consider a scenario where we have a type with a generic argument T
:
type Wrap<T> = { data: T };
If we define another type to extract the generic T
:
type Unwrap<W> = W extends Wrap<infer T> ? T : T;
Why does using T
in the else
clause result in the error: Cannot find name 'T'
?
I am aware that using never
resolves this issue, but in practice, I require something more complex involving the second T
.
Check out the Stackblitz example for further clarification: https://stackblitz.com/edit/angular-k7axek?file=src%2Fmain.ts,src%2Fform-model.ts