rambdax
Version:
Extended version of Rambda - a lightweight, faster alternative to Ramda
19 lines (16 loc) • 395 B
text/typescript
/**
Get the instance type wrapped within a `Promise`
@param P A promise
@returns [[Any]]
@example
```ts
import {C} from 'ts-toolbelt'
const promise = new Promise<string>((res, rej) => res('x'))
type test0 = C.PromiseOf<typeof promise> // string
type test1 = C.PromiseOf<Promise<number>> // number
```
*/
export type PromiseType<P extends any> =
P extends Promise<infer A>
? A
: P