2 Returns the type that is wrapped inside a `Promise` type.
3 If the type is not a `Promise`, the type itself is returned.
7 import {PromiseValue} from 'type-fest';
9 type AsyncData = Promise<string>;
10 let asyncData: PromiseValue<AsyncData> = Promise.resolve('ABC');
12 type Data = PromiseValue<AsyncData>;
13 let data: Data = await asyncData;
15 // Here's an example that shows how this type reacts to non-Promise types.
16 type SyncData = PromiseValue<string>;
17 let syncData: SyncData = getSyncData();
20 export type PromiseValue<PromiseType, Otherwise = PromiseType> = PromiseType extends Promise<infer Value> ? Value : Otherwise;