Sha256: 03ed68319c97cd4ce8f1c4ded110d9b40b8a283c3242b9fe934ccfa834e45572
Contents?: true
Size: 791 Bytes
Versions: 61
Compression:
Stored size: 791 Bytes
Contents
/** Create a type that represents either the value or the value wrapped in `PromiseLike`. Use-cases: - A function accepts a callback that may either return a value synchronously or may return a promised value. - This type could be the return type of `Promise#then()`, `Promise#catch()`, and `Promise#finally()` callbacks. Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31394) if you want to have this type as a built-in in TypeScript. @example ``` import type {Promisable} from 'type-fest'; async function logger(getLogEntry: () => Promisable<string>): Promise<void> { const entry = await getLogEntry(); console.log(entry); } logger(() => 'foo'); logger(() => Promise.resolve('bar')); ``` @category Async */ export type Promisable<T> = T | PromiseLike<T>;
Version data entries
61 entries across 61 versions & 3 rubygems