Made interfaces for delegates

Because built-in `Function` is not flexible
This commit is contained in:
Kir_Antipov 2022-12-04 18:37:59 +00:00
parent d263c15393
commit 63bbe0f72b
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,16 @@
/**
* Represents an async function that takes any number of arguments of type `P` and returns a value of type `R`.
*
* @template P - An array of parameter types.
* @template R - The return type of the function.
*/
export interface AsyncFunc<P extends unknown[] = unknown[], R = unknown> {
/**
* Calls the function with the specified arguments.
*
* @param args The arguments to pass to the function.
*
* @returns A promise resolving to the result of calling the function.
*/
(...args: P): Promise<R>;
}

View file

@ -0,0 +1,16 @@
/**
* Represents a function that takes any number of arguments of type `P` and returns a value of type `R`.
*
* @template P - An array of parameter types.
* @template R - The return type of the function.
*/
export interface Func<P extends unknown[] = unknown[], R = unknown> {
/**
* Calls the function with the specified arguments.
*
* @param args The arguments to pass to the function.
*
* @returns The result of calling the function.
*/
(...args: P): R;
}