Skip to content

Commit 55b6513

Browse files
committed
New CallableFunction and NewableFunction types in es5.d.ts
1 parent 22a384d commit 55b6513

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/lib/es5.d.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,64 @@ interface FunctionConstructor {
295295

296296
declare const Function: FunctionConstructor;
297297

298+
interface CallableFunction extends Function {
299+
/**
300+
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
301+
* @param thisArg The object to be used as the this object.
302+
* @param argArray A set of arguments to be passed to the function.
303+
*/
304+
apply<T, R>(this: (this: T) => R, thisArg: T): R;
305+
apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
306+
307+
/**
308+
* Calls a method of an object, substituting another object for the current object.
309+
* @param thisArg The object to be used as the current object.
310+
* @param argArray A list of arguments to be passed to the method.
311+
*/
312+
call<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R;
313+
314+
/**
315+
* For a given function, creates a bound function that has the same body as the original function.
316+
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
317+
* @param thisArg An object to which the this keyword can refer inside the new function.
318+
* @param argArray A list of arguments to be passed to the new function.
319+
*/
320+
bind<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T): (...args: A) => R;
321+
bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
322+
bind<T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R;
323+
bind<T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R;
324+
bind<T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R;
325+
}
326+
327+
interface NewableFunction extends Function {
328+
/**
329+
* Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
330+
* @param thisArg The object to be used as the this object.
331+
* @param argArray A set of arguments to be passed to the function.
332+
*/
333+
apply<R>(this: new () => R, thisArg: any): R;
334+
apply<A extends any[], R>(this: new (...args: A) => R, thisArg: any, args: A): R;
335+
336+
/**
337+
* Calls a method of an object, substituting another object for the current object.
338+
* @param thisArg The object to be used as the current object.
339+
* @param argArray A list of arguments to be passed to the method.
340+
*/
341+
call<A extends any[], R>(this: new (...args: A) => R, thisArg: any, ...args: A): R;
342+
343+
/**
344+
* For a given function, creates a bound function that has the same body as the original function.
345+
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
346+
* @param thisArg An object to which the this keyword can refer inside the new function.
347+
* @param argArray A list of arguments to be passed to the new function.
348+
*/
349+
bind<A extends any[], R>(this: new (...args: A) => R, thisArg: any): new (...args: A) => R;
350+
bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
351+
bind<A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R;
352+
bind<A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R;
353+
bind<A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R;
354+
}
355+
298356
interface IArguments {
299357
[index: number]: any;
300358
length: number;

0 commit comments

Comments
 (0)