Skip to content

Commit a15bf40

Browse files
committed
feat(lib/es2015): Improve definition of ProxyHandler function methods
1 parent 81aee5e commit a15bf40

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/lib/es2015.proxy.d.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,34 @@ interface ProxyHandler<T extends object> {
1010
deleteProperty? (target: T, p: string | symbol): boolean;
1111
defineProperty? (target: T, p: string | symbol, attributes: PropertyDescriptor): boolean;
1212
ownKeys? (target: T): ArrayLike<string | symbol>;
13-
apply? (target: T & ((...args: any[]) => any), thisArg: any, argArray: any[]): any;
14-
construct? (target: T & (new (...args: any[]) => object), argArray: any[], newTarget?: any): object;
13+
14+
/**
15+
* Called only when target is a callable function.
16+
*
17+
* The default implementation is equivalent to `Reflect.apply(target, thisArg, argArray)`
18+
*
19+
* @param target The function wrapped by this proxy
20+
* @param thisArg The `this` parameter type
21+
* @param argArray The arguments passed to the function
22+
*/
23+
apply?(
24+
target: T extends (...args: any[]) => any ? T : never,
25+
thisArg: T extends (this: infer U, ...args: any[]) => any ? U : any,
26+
argArray: T extends (...args: infer A) => any ? A : any[]
27+
): any;
28+
29+
/**
30+
* Called only when `target` is a newable function.
31+
*
32+
* @param target The function wrapped by this proxy
33+
* @param argArray The arguments passed to the constructor
34+
* @param newTarget The value of `new.target`
35+
*/
36+
construct?(
37+
target: T extends new (...args: any[]) => any ? T : never,
38+
argArray: T extends new (...args: infer A) => any ? A : any[],
39+
newTarget?: any
40+
): object;
1541
}
1642

1743
interface ProxyConstructor {

0 commit comments

Comments
 (0)