1interface ProxyHandler<T extends object> { 2 /** 3 * A trap method for a function call. 4 * @param target The original callable object which is being proxied. 5 */ 6 apply?(target: T, thisArg: any, argArray: any[]): any; 7 8 /** 9 * A trap for the `new` operator. 10 * @param target The original object which is being proxied. 11 * @param newTarget The constructor that was originally called. 12 */ 13 construct?(target: T, argArray: any[], newTarget: Function): object; 14 15 /** 16 * A trap for `Object.defineProperty()`. 17 * @param target The original object which is being proxied. 18 * @returns A `Boolean` indicating whether or not the property has been defined. 19 */ 20 defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean; 21 22 /** 23 * A trap for the `delete` operator. 24 * @param target The original object which is being proxied. 25 * @param p The name or `Symbol` of the property to delete. 26 * @returns A `Boolean` indicating whether or not the property was deleted. 27 */ 28 deleteProperty?(target: T, p: string | symbol): boolean; 29 30 /** 31 * A trap for getting a property value. 32 * @param target The original object which is being proxied. 33 * @param p The name or `Symbol` of the property to get. 34 * @param receiver The proxy or an object that inherits from the proxy. 35 */ 36 get?(target: T, p: string | symbol, receiver: any): any; 37 38 /** 39 * A trap for `Object.getOwnPropertyDescriptor()`. 40 * @param target The original object which is being proxied. 41 * @param p The name of the property whose description should be retrieved. 42 */ 43 getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined; 44 45 /** 46 * A trap for the `[[GetPrototypeOf]]` internal method. 47 * @param target The original object which is being proxied. 48 */ 49 getPrototypeOf?(target: T): object | null; 50 51 /** 52 * A trap for the `in` operator. 53 * @param target The original object which is being proxied. 54 * @param p The name or `Symbol` of the property to check for existence. 55 */ 56 has?(target: T, p: string | symbol): boolean; 57 58 /** 59 * A trap for `Object.isExtensible()`. 60 * @param target The original object which is being proxied. 61 */ 62 isExtensible?(target: T): boolean; 63 64 /** 65 * A trap for `Reflect.ownKeys()`. 66 * @param target The original object which is being proxied. 67 */ 68 ownKeys?(target: T): ArrayLike<string | symbol>; 69 70 /** 71 * A trap for `Object.preventExtensions()`. 72 * @param target The original object which is being proxied. 73 */ 74 preventExtensions?(target: T): boolean; 75 76 /** 77 * A trap for setting a property value. 78 * @param target The original object which is being proxied. 79 * @param p The name or `Symbol` of the property to set. 80 * @param receiver The object to which the assignment was originally directed. 81 * @returns A `Boolean` indicating whether or not the property was set. 82 */ 83 set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean; 84 85 /** 86 * A trap for `Object.setPrototypeOf()`. 87 * @param target The original object which is being proxied. 88 * @param newPrototype The object's new prototype or `null`. 89 */ 90 setPrototypeOf?(target: T, v: object | null): boolean; 91} 92 93interface ProxyConstructor { 94 /** 95 * Creates a revocable Proxy object. 96 * @param target A target object to wrap with Proxy. 97 * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. 98 */ 99 revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; }; 100 101 /** 102 * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the 103 * original object, but which may redefine fundamental Object operations like getting, setting, and defining 104 * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs. 105 * @param target A target object to wrap with Proxy. 106 * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. 107 */ 108 new <T extends object>(target: T, handler: ProxyHandler<T>): T; 109} 110declare var Proxy: ProxyConstructor; 111