Skip to content

Commit

Permalink
feat: add helper types
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jun 21, 2023
1 parent af010cb commit 1cd390c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
* file that was distributed with this source code.
*/

import type { Runner } from './runner.js'

/**
* Exporting hooks runner as a type
*/
export { Runner }

/**
* Shape of the cleanup handler
*/
Expand All @@ -19,6 +26,13 @@ export type HookHandler<Args extends any[], CleanUpArgs extends any[]> = (
...args: Args
) => void | CleanupHandler<CleanUpArgs> | Promise<void> | Promise<CleanupHandler<CleanUpArgs>>

/**
* Extracts args from a hook handler type
*/
export type ExtractHookHandlerArgs<Handler> = Handler extends HookHandler<infer A, infer B>
? [A, B]
: never

/**
* Hook represented as an object with handle method
*/
Expand Down

0 comments on commit 1cd390c

Please sign in to comment.