Skip to content

Commit 562237d

Browse files
authored
fix(lib/es2015): Fix types of Reflect methods (#41987)
1 parent 15c54fb commit 562237d

File tree

2 files changed

+95
-7
lines changed

2 files changed

+95
-7
lines changed

src/lib/es2015.reflect.d.ts

+92-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,103 @@
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+
*/
29
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
3-
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
10+
11+
/**
12+
* Constructs the target with the elements of specified array as the arguments
13+
* and the specified constructor as the `new.target` value.
14+
* @param target The constructor to invoke.
15+
* @param argumentsList An array of argument values to be passed to the constructor.
16+
* @param newTarget The constructor to be used as the `new.target` object.
17+
*/
18+
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: Function): any;
19+
20+
/**
21+
* Adds a property to an object, or modifies attributes of an existing property.
22+
* @param target Object on which to add or modify the property. This can be a native JavaScript object
23+
* (that is, a user-defined object or a built in object) or a DOM object.
24+
* @param propertyKey The property name.
25+
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
26+
*/
427
function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
28+
29+
/**
30+
* Removes a property from an object, equivalent to `delete target[propertyKey]`,
31+
* except it won't throw if `target[propertyKey]` is non-configurable.
32+
* @param target Object from which to remove the own property.
33+
* @param propertyKey The property name.
34+
*/
535
function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
36+
37+
/**
38+
* Gets the property of target, equivalent to `target[propertyKey]` when `receiver === target`.
39+
* @param target Object that contains the property on itself or in its prototype chain.
40+
* @param propertyKey The property name.
41+
* @param receiver The reference to use as the `this` value in the getter function,
42+
* if `target[propertyKey]` is an accessor property.
43+
*/
644
function get(target: object, propertyKey: PropertyKey, receiver?: any): any;
45+
46+
/**
47+
* Gets the own property descriptor of the specified object.
48+
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
49+
* @param target Object that contains the property.
50+
* @param propertyKey The property name.
51+
*/
752
function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined;
8-
function getPrototypeOf(target: object): object;
53+
54+
/**
55+
* Returns the prototype of an object.
56+
* @param target The object that references the prototype.
57+
*/
58+
function getPrototypeOf(target: object): object | null;
59+
60+
/**
61+
* Equivalent to `propertyKey in target`.
62+
* @param target Object that contains the property on itself or in its prototype chain.
63+
* @param propertyKey Name of the property.
64+
*/
965
function has(target: object, propertyKey: PropertyKey): boolean;
66+
67+
/**
68+
* Returns a value that indicates whether new properties can be added to an object.
69+
* @param target Object to test.
70+
*/
1071
function isExtensible(target: object): boolean;
11-
function ownKeys(target: object): PropertyKey[];
72+
73+
/**
74+
* Returns the string and symbol keys of the own properties of an object. The own properties of an object
75+
* are those that are defined directly on that object, and are not inherited from the object's prototype.
76+
* @param target Object that contains the own properties.
77+
*/
78+
function ownKeys(target: object): (string | symbol)[];
79+
80+
/**
81+
* Prevents the addition of new properties to an object.
82+
* @param target Object to make non-extensible.
83+
* @return Whether the object has been made non-extensible.
84+
*/
1285
function preventExtensions(target: object): boolean;
86+
87+
/**
88+
* Sets the property of target, equivalent to `target[propertyKey] = value` when `receiver === target`.
89+
* @param target Object that contains the property on itself or in its prototype chain.
90+
* @param propertyKey Name of the property.
91+
* @param receiver The reference to use as the `this` value in the setter function,
92+
* if `target[propertyKey]` is an accessor property.
93+
*/
1394
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
14-
function setPrototypeOf(target: object, proto: any): boolean;
95+
96+
/**
97+
* Sets the prototype of a specified object o to object proto or null.
98+
* @param target The object to change its prototype.
99+
* @param proto The value of the new prototype or null.
100+
* @return Whether setting the prototype was successful.
101+
*/
102+
function setPrototypeOf(target: object, proto: object | null): boolean;
15103
}

tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ var p = new Proxy(t, {});
1616
>{} : {}
1717

1818
Reflect.ownKeys({});
19-
>Reflect.ownKeys({}) : (string | number | symbol)[]
20-
>Reflect.ownKeys : (target: object) => (string | number | symbol)[]
19+
>Reflect.ownKeys({}) : (string | symbol)[]
20+
>Reflect.ownKeys : (target: object) => (string | symbol)[]
2121
>Reflect : typeof Reflect
22-
>ownKeys : (target: object) => (string | number | symbol)[]
22+
>ownKeys : (target: object) => (string | symbol)[]
2323
>{} : {}
2424

2525
function* idGen() {

0 commit comments

Comments
 (0)