source: trip-planner-front/node_modules/type-fest/source/async-return-type.d.ts@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 715 bytes
Line 
1import {PromiseValue} from './promise-value';
2
3type AsyncFunction = (...args: any[]) => Promise<unknown>;
4
5/**
6Unwrap the return type of a function that returns a `Promise`.
7
8There has been [discussion](https://github.com/microsoft/TypeScript/pull/35998) about implementing this type in TypeScript.
9
10@example
11```ts
12import {AsyncReturnType} from 'type-fest';
13import {asyncFunction} from 'api';
14
15// This type resolves to the unwrapped return type of `asyncFunction`.
16type Value = AsyncReturnType<typeof asyncFunction>;
17
18async function doSomething(value: Value) {}
19
20asyncFunction().then(value => doSomething(value));
21```
22*/
23export type AsyncReturnType<Target extends AsyncFunction> = PromiseValue<ReturnType<Target>>;
Note: See TracBrowser for help on using the repository browser.