• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1declare namespace Reflect {
2    /**
3     * Calls the function with the specified object as the this value
4     * and the elements of specified array as the arguments.
5     * @param target The function to call.
6     * @param thisArgument The object to be used as the this object.
7     * @param argumentsList An array of argument values to be passed to the function.
8     */
9    function apply<T, A extends readonly any[], R>(
10        target: (this: T, ...args: A) => R,
11        thisArgument: T,
12        argumentsList: Readonly<A>,
13    ): R;
14    function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
15
16    /**
17     * Constructs the target with the elements of specified array as the arguments
18     * and the specified constructor as the `new.target` value.
19     * @param target The constructor to invoke.
20     * @param argumentsList An array of argument values to be passed to the constructor.
21     * @param newTarget The constructor to be used as the `new.target` object.
22     */
23    function construct<A extends readonly any[], R>(
24        target: new (...args: A) => R,
25        argumentsList: Readonly<A>,
26        newTarget?: new (...args: any) => any,
27    ): R;
28    function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: Function): any;
29
30    /**
31     * Adds a property to an object, or modifies attributes of an existing property.
32     * @param target Object on which to add or modify the property. This can be a native JavaScript object
33     *        (that is, a user-defined object or a built in object) or a DOM object.
34     * @param propertyKey The property name.
35     * @param attributes Descriptor for the property. It can be for a data property or an accessor property.
36     */
37    function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): boolean;
38
39    /**
40     * Removes a property from an object, equivalent to `delete target[propertyKey]`,
41     * except it won't throw if `target[propertyKey]` is non-configurable.
42     * @param target Object from which to remove the own property.
43     * @param propertyKey The property name.
44     */
45    function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
46
47    /**
48     * Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`.
49     * @param target Object that contains the property on itself or in its prototype chain.
50     * @param propertyKey The property name.
51     * @param receiver The reference to use as the `this` value in the getter function,
52     *        if `target[propertyKey]` is an accessor property.
53     */
54    function get<T extends object, P extends PropertyKey>(
55        target: T,
56        propertyKey: P,
57        receiver?: unknown,
58    ): P extends keyof T ? T[P] : any;
59
60    /**
61     * Gets the own property descriptor of the specified object.
62     * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
63     * @param target Object that contains the property.
64     * @param propertyKey The property name.
65     */
66    function getOwnPropertyDescriptor<T extends object, P extends PropertyKey>(
67        target: T,
68        propertyKey: P,
69    ): TypedPropertyDescriptor<P extends keyof T ? T[P] : any> | undefined;
70
71    /**
72     * Returns the prototype of an object.
73     * @param target The object that references the prototype.
74     */
75    function getPrototypeOf(target: object): object | null;
76
77    /**
78     * Equivalent to `propertyKey in target`.
79     * @param target Object that contains the property on itself or in its prototype chain.
80     * @param propertyKey Name of the property.
81     */
82    function has(target: object, propertyKey: PropertyKey): boolean;
83
84    /**
85     * Returns a value that indicates whether new properties can be added to an object.
86     * @param target Object to test.
87     */
88    function isExtensible(target: object): boolean;
89
90    /**
91     * Returns the string and symbol keys of the own properties of an object. The own properties of an object
92     * are those that are defined directly on that object, and are not inherited from the object's prototype.
93     * @param target Object that contains the own properties.
94     */
95    function ownKeys(target: object): (string | symbol)[];
96
97    /**
98     * Prevents the addition of new properties to an object.
99     * @param target Object to make non-extensible.
100     * @return Whether the object has been made non-extensible.
101     */
102    function preventExtensions(target: object): boolean;
103
104    /**
105     * Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`.
106     * @param target Object that contains the property on itself or in its prototype chain.
107     * @param propertyKey Name of the property.
108     * @param receiver The reference to use as the `this` value in the setter function,
109     *        if `target[propertyKey]` is an accessor property.
110     */
111    function set<T extends object, P extends PropertyKey>(
112        target: T,
113        propertyKey: P,
114        value: P extends keyof T ? T[P] : any,
115        receiver?: any,
116    ): boolean;
117    function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
118
119    /**
120     * Sets the prototype of a specified object o to object proto or null.
121     * @param target The object to change its prototype.
122     * @param proto The value of the new prototype or null.
123     * @return Whether setting the prototype was successful.
124     */
125    function setPrototypeOf(target: object, proto: object | null): boolean;
126}
127