Skip to content

Commit 0c7b2da

Browse files
committed
fix: restore Reflect typing and fix tests
1 parent a2a8134 commit 0c7b2da

File tree

5 files changed

+295
-115
lines changed

5 files changed

+295
-115
lines changed

docs/diff/es2015.reflect.d.ts.md

Lines changed: 82 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,51 @@ Index: es2015.reflect.d.ts
55
===================================================================
66
--- es2015.reflect.d.ts
77
+++ es2015.reflect.d.ts
8-
@@ -1,143 +1,14 @@
9-
declare namespace Reflect {
10-
/**
11-
- * Calls the function with the specified object as the this value
12-
- * and the elements of specified array as the arguments.
13-
- * @param target The function to call.
14-
- * @param thisArgument The object to be used as the this object.
15-
- * @param argumentsList An array of argument values to be passed to the function.
16-
- */
17-
- function apply<T, A extends readonly any[], R>(
18-
- target: (this: T, ...args: A) => R,
19-
- thisArgument: T,
20-
- argumentsList: Readonly<A>
21-
- ): R;
8+
@@ -10,14 +10,8 @@
9+
target: (this: T, ...args: A) => R,
10+
thisArgument: T,
11+
argumentsList: Readonly<A>
12+
): R;
2213
- function apply(
2314
- target: Function,
2415
- thisArgument: any,
2516
- argumentsList: ArrayLike<any>
2617
- ): any;
2718
-
28-
- /**
29-
- * Constructs the target with the elements of specified array as the arguments
30-
- * and the specified constructor as the `new.target` value.
31-
- * @param target The constructor to invoke.
32-
- * @param argumentsList An array of argument values to be passed to the constructor.
33-
- * @param newTarget The constructor to be used as the `new.target` object.
34-
- */
35-
- function construct<A extends readonly any[], R>(
36-
- target: new (...args: A) => R,
37-
- argumentsList: Readonly<A>,
38-
- newTarget?: new (...args: any) => any
39-
- ): R;
19+
/**
20+
* Constructs the target with the elements of specified array as the arguments
21+
* and the specified constructor as the `new.target` value.
22+
* @param target The constructor to invoke.
23+
@@ -28,14 +22,8 @@
24+
target: new (...args: A) => R,
25+
argumentsList: Readonly<A>,
26+
newTarget?: new (...args: any) => any
27+
): R;
4028
- function construct(
4129
- target: Function,
4230
- argumentsList: ArrayLike<any>,
4331
- newTarget?: Function
4432
- ): any;
4533
-
46-
- /**
47-
- * Adds a property to an object, or modifies attributes of an existing property.
48-
- * @param target Object on which to add or modify the property. This can be a native JavaScript object
49-
- * (that is, a user-defined object or a built in object) or a DOM object.
50-
- * @param propertyKey The property name.
51-
- * @param attributes Descriptor for the property. It can be for a data property or an accessor property.
52-
- */
53-
- function defineProperty(
54-
- target: object,
55-
- propertyKey: PropertyKey,
56-
- attributes: PropertyDescriptor & ThisType<any>
57-
- ): boolean;
34+
/**
35+
* Adds a property to an object, or modifies attributes of an existing property.
36+
* @param target Object on which to add or modify the property. This can be a native JavaScript object
37+
* (that is, a user-defined object or a built in object) or a DOM object.
38+
@@ -46,30 +34,27 @@
39+
target: object,
40+
propertyKey: PropertyKey,
41+
attributes: PropertyDescriptor & ThisType<any>
42+
): boolean;
5843
-
59-
- /**
60-
- * Removes a property from an object, equivalent to `delete target[propertyKey]`,
61-
- * except it won't throw if `target[propertyKey]` is non-configurable.
62-
- * @param target Object from which to remove the own property.
63-
- * @param propertyKey The property name.
64-
- */
65-
- function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
44+
/**
45+
* Removes a property from an object, equivalent to `delete target[propertyKey]`,
46+
* except it won't throw if `target[propertyKey]` is non-configurable.
47+
* @param target Object from which to remove the own property.
48+
* @param propertyKey The property name.
49+
*/
50+
function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
6651
-
67-
- /**
52+
/**
6853
* Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`.
6954
* @param target Object that contains the property on itself or in its prototype chain.
7055
* @param propertyKey The property name.
@@ -78,78 +63,63 @@ Index: es2015.reflect.d.ts
7863
receiver?: unknown
7964
- ): P extends keyof T ? T[P] : any;
8065
-
81-
- /**
82-
- * Gets the own property descriptor of the specified object.
83-
- * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
84-
- * @param target Object that contains the property.
85-
- * @param propertyKey The property name.
86-
- */
87-
- function getOwnPropertyDescriptor<T extends object, P extends PropertyKey>(
88-
- target: T,
89-
- propertyKey: P
90-
- ): TypedPropertyDescriptor<P extends keyof T ? T[P] : any> | undefined;
66+
+ ): P extends keyof T ? T[P] : unknown;
67+
/**
68+
* Gets the own property descriptor of the specified object.
69+
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
70+
* @param target Object that contains the property.
71+
@@ -78,42 +63,36 @@
72+
function getOwnPropertyDescriptor<T extends object, P extends PropertyKey>(
73+
target: T,
74+
propertyKey: P
75+
): TypedPropertyDescriptor<P extends keyof T ? T[P] : any> | undefined;
9176
-
92-
- /**
93-
- * Returns the prototype of an object.
94-
- * @param target The object that references the prototype.
95-
- */
96-
- function getPrototypeOf(target: object): object | null;
77+
/**
78+
* Returns the prototype of an object.
79+
* @param target The object that references the prototype.
80+
*/
81+
function getPrototypeOf(target: object): object | null;
9782
-
98-
- /**
99-
- * Equivalent to `propertyKey in target`.
100-
- * @param target Object that contains the property on itself or in its prototype chain.
101-
- * @param propertyKey Name of the property.
102-
- */
103-
- function has(target: object, propertyKey: PropertyKey): boolean;
83+
/**
84+
* Equivalent to `propertyKey in target`.
85+
* @param target Object that contains the property on itself or in its prototype chain.
86+
* @param propertyKey Name of the property.
87+
*/
88+
function has(target: object, propertyKey: PropertyKey): boolean;
10489
-
105-
- /**
106-
- * Returns a value that indicates whether new properties can be added to an object.
107-
- * @param target Object to test.
108-
- */
109-
- function isExtensible(target: object): boolean;
90+
/**
91+
* Returns a value that indicates whether new properties can be added to an object.
92+
* @param target Object to test.
93+
*/
94+
function isExtensible(target: object): boolean;
11095
-
111-
- /**
112-
- * Returns the string and symbol keys of the own properties of an object. The own properties of an object
113-
- * are those that are defined directly on that object, and are not inherited from the object's prototype.
114-
- * @param target Object that contains the own properties.
115-
- */
116-
- function ownKeys(target: object): (string | symbol)[];
96+
/**
97+
* Returns the string and symbol keys of the own properties of an object. The own properties of an object
98+
* are those that are defined directly on that object, and are not inherited from the object's prototype.
99+
* @param target Object that contains the own properties.
100+
*/
101+
function ownKeys(target: object): (string | symbol)[];
117102
-
118-
- /**
119-
- * Prevents the addition of new properties to an object.
120-
- * @param target Object to make non-extensible.
121-
- * @return Whether the object has been made non-extensible.
122-
- */
123-
- function preventExtensions(target: object): boolean;
103+
/**
104+
* Prevents the addition of new properties to an object.
105+
* @param target Object to make non-extensible.
106+
* @return Whether the object has been made non-extensible.
107+
*/
108+
function preventExtensions(target: object): boolean;
124109
-
125-
- /**
126-
- * Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`.
127-
- * @param target Object that contains the property on itself or in its prototype chain.
128-
- * @param propertyKey Name of the property.
129-
- * @param receiver The reference to use as the `this` value in the setter function,
130-
- * if `target[propertyKey]` is an accessor property.
131-
- */
132-
- function set<T extends object, P extends PropertyKey>(
133-
- target: T,
134-
- propertyKey: P,
135-
- value: P extends keyof T ? T[P] : any,
136-
- receiver?: any
137-
- ): boolean;
138-
- function set(
139-
- target: object,
140-
- propertyKey: PropertyKey,
141-
- value: any,
142-
- receiver?: any
143-
- ): boolean;
110+
/**
111+
* Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`.
112+
* @param target Object that contains the property on itself or in its prototype chain.
113+
* @param propertyKey Name of the property.
114+
@@ -131,9 +110,8 @@
115+
propertyKey: PropertyKey,
116+
value: any,
117+
receiver?: any
118+
): boolean;
144119
-
145-
- /**
146-
- * Sets the prototype of a specified object o to object proto or null.
147-
- * @param target The object to change its prototype.
148-
- * @param proto The value of the new prototype or null.
149-
- * @return Whether setting the prototype was successful.
150-
- */
151-
- function setPrototypeOf(target: object, proto: object | null): boolean;
152-
+ ): P extends keyof T ? T[P] : unknown;
153-
}
120+
/**
121+
* Sets the prototype of a specified object o to object proto or null.
122+
* @param target The object to change its prototype.
123+
* @param proto The value of the new prototype or null.
154124

155125
```

generated/lib.es2015.reflect.d.ts

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

0 commit comments

Comments
 (0)