main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
399 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | /**
|
---|
| 2 | * Get the result type of a `Promise`
|
---|
| 3 | * @param P A promise
|
---|
| 4 | * @returns [[Any]]
|
---|
| 5 | * @example
|
---|
| 6 | * ```ts
|
---|
| 7 | * import {C} from 'ts-toolbelt'
|
---|
| 8 | *
|
---|
| 9 | * const promise = new Promise<string>((res, rej) => res('x'))
|
---|
| 10 | *
|
---|
| 11 | * type test0 = C.Await<typeof promise> // string
|
---|
| 12 | * type test1 = C.Await<Promise<number>> // number
|
---|
| 13 | * ```
|
---|
| 14 | */
|
---|
| 15 | export declare type Await<P extends any> = P extends Promise<infer A> ? A : P;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.