minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @eslint / eslintrc / node_modules / type-fest / source / promisable.d.ts
1 /**
2 Create a type that represents either the value or the value wrapped in `PromiseLike`.
3
4 Use-cases:
5 - A function accepts a callback that may either return a value synchronously or may return a promised value.
6 - This type could be the return type of `Promise#then()`, `Promise#catch()`, and `Promise#finally()` callbacks.
7
8 Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31394) if you want to have this type as a built-in in TypeScript.
9
10 @example
11 ```
12 import {Promisable} from 'type-fest';
13
14 async function logger(getLogEntry: () => Promisable<string>): Promise<void> {
15     const entry = await getLogEntry();
16     console.log(entry);
17 }
18
19 logger(() => 'foo');
20 logger(() => Promise.resolve('bar'));
21 ```
22 */
23 export type Promisable<T> = T | PromiseLike<T>;