-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cde1fa0
commit b47d18b
Showing
1 changed file
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
interface Parameter<T extends any[], R> { | ||
fn: (...args: T) => R; | ||
// Define a generic type for functions with specific parameters and return type | ||
export type AnyFunction<P extends unknown[] = never[], R = unknown> = ( | ||
...args: P | ||
) => R; | ||
|
||
// Define a generic type for a dictionary of functions | ||
export type Functions = { | ||
[key: string]: AnyFunction; | ||
}; | ||
|
||
// Define a parameter interface to wrap the function and its result | ||
interface Parameter<P extends unknown[], R> { | ||
fn: (...args: P) => R; | ||
result?: R; | ||
} | ||
|
||
export type HookFn<T extends (...args: any[]) => any> = ( | ||
// Define the HookFn type using generics for better type safety | ||
export type HookFn<T extends AnyFunction> = ( | ||
params: Parameter<Parameters<T>, ReturnType<T>>, | ||
...args: Parameters<T> | ||
) => ReturnType<T>; | ||
|
||
export type Function = (...args: any[]) => any; | ||
export type Functions = { | ||
[key: string]: Function; | ||
}; |