.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / type-fest / source / async-return-type.d.ts
1 import {PromiseValue} from './promise-value';
2
3 type AsyncFunction = (...args: any[]) => Promise<unknown>;
4
5 /**
6 Unwrap the return type of a function that returns a `Promise`.
7
8 There has been [discussion](https://github.com/microsoft/TypeScript/pull/35998) about implementing this type in TypeScript.
9
10 @example
11 ```ts
12 import {AsyncReturnType} from 'type-fest';
13 import {asyncFunction} from 'api';
14
15 // This type resolves to the unwrapped return type of `asyncFunction`.
16 type Value = AsyncReturnType<typeof asyncFunction>;
17
18 async function doSomething(value: Value) {}
19
20 asyncFunction().then(value => doSomething(value));
21 ```
22 */
23 export type AsyncReturnType<Target extends AsyncFunction> = PromiseValue<ReturnType<Target>>;