Awaited
#
introductionIf 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?
View on GitHubThis question is ported from the original article by @maciejsikora
#
start pointtsTry
/* _____________ Your Code Here _____________ */typeAwaited <T > = any;Â/* _____________ Test Cases _____________ */typeX =Promise <string>;typeY =Promise <{field : number }>;Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Awaited <X >, string>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Awaited <Y >, {field : number }>>];
take the challengetsTry
/* _____________ Your Code Here _____________ */typeAwaited <T > = any;Â/* _____________ Test Cases _____________ */typeX =Promise <string>;typeY =Promise <{field : number }>;Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Awaited <X >, string>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <Awaited <Y >, {field : number }>>];