add types for async functions

This commit is contained in:
James Brumond 2023-08-26 14:59:55 -07:00
parent eb65701595
commit 64a6cac8f5
Signed by: james
GPG Key ID: E8F2FC44BAA3357A

4
src/functions.d.ts vendored
View File

@ -1,6 +1,10 @@
export type Func<T extends any = any> = (...args: any[]) => T;
export type AsyncFunc<T extends any = any> = (...args: any[]) => PromiseLike<T>;
export type AsyncResult<T extends AsyncFunc> = Awaited<ReturnType<T>>;
export type Params<T extends Func> = T extends (...args: infer P) => any ? P : never;
export type FirstParam<T extends Func> = T extends (first: infer F, ...args: any[]) => any ? F : never;