Create a type that represents either the value or the value wrapped in PromiseLike.
PromiseLike
Use-cases:
Promise#then()
Promise#catch()
Promise#finally()
Please upvote this issue if you want to have this type as a built-in in TypeScript.
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')); Copy
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'));
Create a type that represents either the value or the value wrapped in
PromiseLike.Use-cases:
Promise#then(),Promise#catch(), andPromise#finally()callbacks.Please upvote this issue if you want to have this type as a built-in in TypeScript.