mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Add overloads for Function.apply/call/bind
The new overloads use this types to specify the return type of these functions as well as the type of `thisArg`.
This commit is contained in:
9
src/lib/core.d.ts
vendored
9
src/lib/core.d.ts
vendored
@@ -215,14 +215,16 @@ interface Function {
|
||||
* @param thisArg The object to be used as the this object.
|
||||
* @param argArray A set of arguments to be passed to the function.
|
||||
*/
|
||||
apply(thisArg: any, argArray?: any): any;
|
||||
apply<T,U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U;
|
||||
apply(this: Function, thisArg: any, argArray?: any): any;
|
||||
|
||||
/**
|
||||
* Calls a method of an object, substituting another object for the current object.
|
||||
* @param thisArg The object to be used as the current object.
|
||||
* @param argArray A list of arguments to be passed to the method.
|
||||
*/
|
||||
call(thisArg: any, ...argArray: any[]): any;
|
||||
call<T,U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U;
|
||||
call(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
/**
|
||||
* For a given function, creates a bound function that has the same body as the original function.
|
||||
@@ -230,7 +232,8 @@ interface Function {
|
||||
* @param thisArg An object to which the this keyword can refer inside the new function.
|
||||
* @param argArray A list of arguments to be passed to the new function.
|
||||
*/
|
||||
bind(thisArg: any, ...argArray: any[]): any;
|
||||
bind<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (...argArray: any[]) => U;
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
|
||||
Reference in New Issue
Block a user