Awaited
If we have a type which is wrapped type like Promise. How we can get a type which is inside the wrapped type?
For example: if we have Promise<ExampleType> how to get ExampleType?
tstypeExampleType =Promise <string>typeCannot find name 'MyAwaited'. Did you mean 'Awaited'?2552Cannot find name 'MyAwaited'. Did you mean 'Awaited'?Result =< MyAwaited ExampleType > // string
tstypeExampleType =Promise <string>typeCannot find name 'MyAwaited'. Did you mean 'Awaited'?2552Cannot find name 'MyAwaited'. Did you mean 'Awaited'?Result => // string MyAwaited <ExampleType
Solution ✅
tstypeExampleType =Promise <string>typeAnotherType =Promise <Promise <string>>typeMyAwaited <T > =T extendsPromise <inferInner > ?MyAwaited <Inner > : nevertypeResult =Awaited <ExampleType > // stringtypeNewResult =Awaited <AnotherType > // string
tstypeExampleType =Promise <string>typeAnotherType =Promise <Promise <string>>typeMyAwaited <T > =T extendsPromise <inferInner > ?MyAwaited <Inner > : nevertypeResult =Awaited <ExampleType > // stringtypeNewResult =Awaited <AnotherType > // string