-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.d.ts
37 lines (36 loc) · 915 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Create a set of methods that will be executed on the UI,
* regarless of where they are called from.
*/
export function createUIAPI<
T extends { [method: string]: (...args: any[]) => any | Promise<any> }
>(
methods: T,
options?: { timeout?: number }
): Readonly<
{
[K in keyof T]: (
...args: Parameters<T[K]>
) => ReturnType<T[K]> extends Promise<infer U>
? ReturnType<T[K]>
: Promise<ReturnType<T[K]>>;
}
>;
/**
* Create a set of methods that will be executed on the plugin,
* regarless of where they are called from.
*/
export function createPluginAPI<
T extends { [method: string]: (...args: any[]) => any | Promise<any> }
>(
methods: T,
options?: { timeout?: number }
): Readonly<
{
[K in keyof T]: (
...args: Parameters<T[K]>
) => ReturnType<T[K]> extends Promise<infer U>
? ReturnType<T[K]>
: Promise<ReturnType<T[K]>>;
}
>;