Skip to content

Commit

Permalink
Used Awaited to extract a type from a promise.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhop committed Sep 15, 2024
1 parent 2ecfc2e commit 39e8f6b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/defs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export declare function getFunctionList<T extends (...args: readonly any[]) => u

// generic utilities: unpacking types

export type UnpackReturnType<F extends (...args: readonly any[]) => unknown> = ReturnType<F> extends Promise<infer O>
? O
export type UnpackReturnType<F extends (...args: readonly any[]) => unknown> = ReturnType<F> extends Promise<unknown>
? Awaited<ReturnType<F>>
: ReturnType<F> extends AsyncGenerator<infer O, unknown, unknown>
? O
: ReturnType<F> extends Generator<infer O, unknown, unknown>
Expand Down

0 comments on commit 39e8f6b

Please sign in to comment.