/** * Promise or maybe not */ export type Awaitable = T | PromiseLike; /** * Array or maybe not */ export type Arrayable = T | Array; /** * A function that may return a promise. */ export type AwaitableFn = Fn, Args>; /** * Null or whatever */ export type Nullable = T | null | undefined; /** * Function. I personally prefer this syntax over the native `Function` type. */ export type Fn = (...args: Args) => Result; /** * Constructor type. */ export type Constructor = new (...args: Arguments) => T; /** * A class type. */ export type Class = { prototype: Pick; new (...args: Arguments): T; }; /** * Prettify a type. * * See https://www.totaltypescript.com/concepts/the-prettify-helper */ export type Prettify = { [K in keyof T]: T[K]; } & {}; /** * Return type of a function. Can be more concise than the native ReturnType since it support * promises. */ export type ReturnType unknown) | undefined | null | false | ''> = T extends (...args: any[]) => infer R ? (R extends PromiseLike ? J : R) : never;