Skip to content

Commit

Permalink
feat(types): type ToAsyncFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jun 25, 2024
1 parent d1f63a2 commit 036f4ba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/types/src/lib/func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ export type AsyncMethodType<
TThis = any,
> = (this: TThis, ...input: ArgsType) => Promise<ResultType>


/**
* Convert a function type to an async function type
*/
export type ToAsyncFunction<T extends (...args: any) => any> = T extends (...args: infer A) => infer R
? (...args: A) => Promise<R>
: never

0 comments on commit 036f4ba

Please sign in to comment.