Skip to content

Commit 902a77d

Browse files
committed
feat(lib/es2015): Add typed overloads to Reflect
1 parent 822962e commit 902a77d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Diff for: src/lib/es2015.reflect.d.ts

+25-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ declare namespace Reflect {
66
* @param thisArgument The object to be used as the this object.
77
* @param argumentsList An array of argument values to be passed to the function.
88
*/
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;
914
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
1015

1116
/**
@@ -15,6 +20,11 @@ declare namespace Reflect {
1520
* @param argumentsList An array of argument values to be passed to the constructor.
1621
* @param newTarget The constructor to be used as the `new.target` object.
1722
*/
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;
1828
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: Function): any;
1929

2030
/**
@@ -41,15 +51,22 @@ declare namespace Reflect {
4151
* @param receiver The reference to use as the `this` value in the getter function,
4252
* if `target[propertyKey]` is an accessor property.
4353
*/
44-
function get(target: object, propertyKey: PropertyKey, receiver?: any): any;
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;
4559

4660
/**
4761
* Gets the own property descriptor of the specified object.
4862
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
4963
* @param target Object that contains the property.
5064
* @param propertyKey The property name.
5165
*/
52-
function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined;
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;
5370

5471
/**
5572
* Returns the prototype of an object.
@@ -91,6 +108,12 @@ declare namespace Reflect {
91108
* @param receiver The reference to use as the `this` value in the setter function,
92109
* if `target[propertyKey]` is an accessor property.
93110
*/
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;
94117
function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
95118

96119
/**

0 commit comments

Comments
 (0)