Skip to content

Commit 33ab6fd

Browse files
lib Fix Part 5/6 – Function.{apply, bind} (#50453)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
1 parent 0023505 commit 33ab6fd

6 files changed

+154
-193
lines changed

src/lib/es5.d.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,14 @@ interface CallableFunction extends Function {
314314
/**
315315
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
316316
* @param thisArg The object to be used as the this object.
317-
* @param args An array of argument values to be passed to the function.
318317
*/
319318
apply<T, R>(this: (this: T) => R, thisArg: T): R;
319+
320+
/**
321+
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
322+
* @param thisArg The object to be used as the this object.
323+
* @param args An array of argument values to be passed to the function.
324+
*/
320325
apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
321326

322327
/**
@@ -330,23 +335,29 @@ interface CallableFunction extends Function {
330335
* For a given function, creates a bound function that has the same body as the original function.
331336
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
332337
* @param thisArg The object to be used as the this object.
333-
* @param args Arguments to bind to the parameters of the function.
334338
*/
335339
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
336-
bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
337-
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;
338-
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;
339-
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;
340-
bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
340+
341+
/**
342+
* For a given function, creates a bound function that has the same body as the original function.
343+
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
344+
* @param thisArg The object to be used as the this object.
345+
* @param args Arguments to bind to the parameters of the function.
346+
*/
347+
bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
341348
}
342349

343350
interface NewableFunction extends Function {
344351
/**
345352
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
346353
* @param thisArg The object to be used as the this object.
347-
* @param args An array of argument values to be passed to the function.
348354
*/
349355
apply<T>(this: new () => T, thisArg: T): void;
356+
/**
357+
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
358+
* @param thisArg The object to be used as the this object.
359+
* @param args An array of argument values to be passed to the function.
360+
*/
350361
apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;
351362

352363
/**
@@ -360,14 +371,16 @@ interface NewableFunction extends Function {
360371
* For a given function, creates a bound function that has the same body as the original function.
361372
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
362373
* @param thisArg The object to be used as the this object.
363-
* @param args Arguments to bind to the parameters of the function.
364374
*/
365375
bind<T>(this: T, thisArg: any): T;
366-
bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
367-
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;
368-
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;
369-
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;
370-
bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
376+
377+
/**
378+
* For a given function, creates a bound function that has the same body as the original function.
379+
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
380+
* @param thisArg The object to be used as the this object.
381+
* @param args Arguments to bind to the parameters of the function.
382+
*/
383+
bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
371384
}
372385

373386
interface IArguments {

0 commit comments

Comments
 (0)