Skip to content

Commit d6eb6f8

Browse files
Spread Bind
1 parent a332a4e commit d6eb6f8

30 files changed

+182
-310
lines changed

src/lib/es5.d.ts

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -341,51 +341,13 @@ interface CallableFunction extends Function {
341341
*/
342342
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
343343

344-
/**
345-
* For a given function, creates a bound function that has the same body as the original function.
346-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
347-
* @param thisArg The object to be used as the this object.
348-
* @param arg0 The first argument to bind to the parameters of the function.
349-
*/
350-
bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
351-
352-
/**
353-
* For a given function, creates a bound function that has the same body as the original function.
354-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
355-
* @param thisArg The object to be used as the this object.
356-
* @param arg0 The first argument to bind to the parameters of the function.
357-
* @param arg1 The second argument to bind to the parameters of the function.
358-
*/
359-
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;
360-
361-
/**
362-
* For a given function, creates a bound function that has the same body as the original function.
363-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
364-
* @param thisArg The object to be used as the this object.
365-
* @param arg0 The first argument to bind to the parameters of the function.
366-
* @param arg1 The second argument to bind to the parameters of the function.
367-
* @param arg2 The third argument to bind to the parameters of the function.
368-
*/
369-
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;
370-
371-
/**
372-
* For a given function, creates a bound function that has the same body as the original function.
373-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
374-
* @param thisArg The object to be used as the this object.
375-
* @param arg0 The first argument to bind to the parameters of the function.
376-
* @param arg1 The second argument to bind to the parameters of the function.
377-
* @param arg2 The third argument to bind to the parameters of the function.
378-
* @param arg3 The fourth to bind to the parameters of the function.
379-
*/
380-
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;
381-
382344
/**
383345
* For a given function, creates a bound function that has the same body as the original function.
384346
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
385347
* @param thisArg The object to be used as the this object.
386348
* @param args Arguments to bind to the parameters of the function.
387349
*/
388-
bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
350+
bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
389351
}
390352

391353
interface NewableFunction extends Function {
@@ -415,51 +377,13 @@ interface NewableFunction extends Function {
415377
*/
416378
bind<T>(this: T, thisArg: any): T;
417379

418-
/**
419-
* For a given function, creates a bound function that has the same body as the original function.
420-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
421-
* @param thisArg The object to be used as the this object.
422-
* @param arg0 The first argument to bind to the parameters of the function.
423-
*/
424-
bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
425-
426-
/**
427-
* For a given function, creates a bound function that has the same body as the original function.
428-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
429-
* @param thisArg The object to be used as the this object.
430-
* @param arg0 The first argument to bind to the parameters of the function.
431-
* @param arg1 The second argument to bind to the parameters of the function.
432-
*/
433-
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;
434-
435-
/**
436-
* For a given function, creates a bound function that has the same body as the original function.
437-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
438-
* @param thisArg The object to be used as the this object.
439-
* @param arg0 The first argument to bind to the parameters of the function.
440-
* @param arg1 The second argument to bind to the parameters of the function.
441-
* @param arg2 The third argument to bind to the parameters of the function.
442-
*/
443-
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;
444-
445-
/**
446-
* For a given function, creates a bound function that has the same body as the original function.
447-
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
448-
* @param thisArg The object to be used as the this object.
449-
* @param arg0 The first argument to bind to the parameters of the function.
450-
* @param arg1 The second argument to bind to the parameters of the function.
451-
* @param arg2 The third argument to bind to the parameters of the function.
452-
* @param arg3 The fourth to bind to the parameters of the function.
453-
*/
454-
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;
455-
456380
/**
457381
* For a given function, creates a bound function that has the same body as the original function.
458382
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
459383
* @param thisArg The object to be used as the this object.
460384
* @param args Arguments to bind to the parameters of the function.
461385
*/
462-
bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
386+
bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
463387
}
464388

465389
interface IArguments {

tests/baselines/reference/destructuringParameterDeclaration4.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
4141
a1(...array2); // Error parameter type is (number|string)[]
4242
~~~~~~
4343
!!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'?
44-
!!! related TS2728 /.ts/lib.es5.d.ts:1572:13: 'Array' is declared here.
44+
!!! related TS2728 /.ts/lib.es5.d.ts:1496:13: 'Array' is declared here.
4545
a5([1, 2, "string", false, true]); // Error, parameter type is [any, any, [[any]]]
4646
~~~~~~~~
4747
!!! error TS2322: Type 'string' is not assignable to type '[[any]]'.

tests/baselines/reference/destructuringTuple.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tests/cases/compiler/destructuringTuple.ts(11,60): error TS2769: No overload mat
3333
!!! error TS2769: Overload 2 of 2, '(callbackfn: (previousValue: [], currentValue: number, currentIndex: number, array: number[]) => [], initialValue: []): []', gave the following error.
3434
!!! error TS2769: Type 'never[]' is not assignable to type '[]'.
3535
!!! error TS2769: Target allows only 0 element(s) but source may have more.
36-
!!! related TS6502 /.ts/lib.es5.d.ts:1538:24: The expected type comes from the return type of this signature.
37-
!!! related TS6502 /.ts/lib.es5.d.ts:1544:27: The expected type comes from the return type of this signature.
36+
!!! related TS6502 /.ts/lib.es5.d.ts:1462:24: The expected type comes from the return type of this signature.
37+
!!! related TS6502 /.ts/lib.es5.d.ts:1468:27: The expected type comes from the return type of this signature.
3838
~~
3939
!!! error TS2769: No overload matches this call.
4040
!!! error TS2769: Overload 1 of 2, '(...items: ConcatArray<never>[]): never[]', gave the following error.

tests/baselines/reference/duplicateNumericIndexers.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ tests/cases/conformance/types/members/duplicateNumericIndexers.ts(24,5): error T
1010
tests/cases/conformance/types/members/duplicateNumericIndexers.ts(25,5): error TS2374: Duplicate index signature for type 'number'.
1111
tests/cases/conformance/types/members/duplicateNumericIndexers.ts(29,5): error TS2374: Duplicate index signature for type 'number'.
1212
tests/cases/conformance/types/members/duplicateNumericIndexers.ts(30,5): error TS2374: Duplicate index signature for type 'number'.
13-
lib.es5.d.ts(617,5): error TS2374: Duplicate index signature for type 'number'.
14-
lib.es5.d.ts(1558,5): error TS2374: Duplicate index signature for type 'number'.
13+
lib.es5.d.ts(541,5): error TS2374: Duplicate index signature for type 'number'.
14+
lib.es5.d.ts(1482,5): error TS2374: Duplicate index signature for type 'number'.
1515

1616

1717
==== tests/cases/conformance/types/members/duplicateNumericIndexers.ts (12 errors) ====

tests/baselines/reference/externModule.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ tests/cases/compiler/externModule.ts(37,3): error TS2552: Cannot find name 'XDat
6666
var d=new XDate();
6767
~~~~~
6868
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
69-
!!! related TS2728 /.ts/lib.es5.d.ts:1027:13: 'Date' is declared here.
69+
!!! related TS2728 /.ts/lib.es5.d.ts:951:13: 'Date' is declared here.
7070
d.getDay();
7171
d=new XDate(1978,2);
7272
~~~~~
7373
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
74-
!!! related TS2728 /.ts/lib.es5.d.ts:1027:13: 'Date' is declared here.
74+
!!! related TS2728 /.ts/lib.es5.d.ts:951:13: 'Date' is declared here.
7575
d.getXDate();
7676
var n=XDate.parse("3/2/2004");
7777
~~~~~
7878
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
79-
!!! related TS2728 /.ts/lib.es5.d.ts:1027:13: 'Date' is declared here.
79+
!!! related TS2728 /.ts/lib.es5.d.ts:951:13: 'Date' is declared here.
8080
n=XDate.UTC(1964,2,1);
8181
~~~~~
8282
!!! error TS2552: Cannot find name 'XDate'. Did you mean 'Date'?
83-
!!! related TS2728 /.ts/lib.es5.d.ts:1027:13: 'Date' is declared here.
83+
!!! related TS2728 /.ts/lib.es5.d.ts:951:13: 'Date' is declared here.
8484

8585

tests/baselines/reference/mappedTypeWithAsClauseAndLateBoundProperty.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ tests/cases/compiler/mappedTypeWithAsClauseAndLateBoundProperty.ts(3,1): error T
77
tgt2 = src2; // Should error
88
~~~~
99
!!! error TS2741: Property 'length' is missing in type '{ [x: number]: number; toString: () => string; toLocaleString: () => string; pop: () => number; push: (...items: number[]) => number; concat: { (...items: ConcatArray<number>[]): number[]; (...items: (number | ConcatArray<number>)[]): number[]; }; join: (separator?: string) => string; reverse: () => number[]; shift: () => number; slice: (start?: number, end?: number) => number[]; sort: (compareFn?: (a: number, b: number) => number) => number[]; splice: { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; }; unshift: (...items: number[]) => number; indexOf: (searchElement: number, fromIndex?: number) => number; lastIndexOf: (searchElement: number, fromIndex?: number) => number; every: { <S extends number>(predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): boolean; }; some: (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any) => boolean; forEach: (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void; map: <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]; filter: { <S extends number>(predicate: (value: number, index: number, array: number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: number[]) => unknown, thisArg?: any): number[]; }; reduce: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; reduceRight: { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue?: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U): U; }; find: { <S extends number>(predicate: (value: number, index: number, obj: number[]) => value is S, thisArg?: any): S; (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any): number; }; findIndex: (predicate: (value: number, index: number, obj: number[]) => unknown, thisArg?: any) => number; fill: (value: number, start?: number, end?: number) => number[]; copyWithin: (target: number, start: number, end?: number) => number[]; entries: () => IterableIterator<[number, number]>; keys: () => IterableIterator<number>; values: () => IterableIterator<number>; includes: (searchElement: number, fromIndex?: number) => boolean; flatMap: <U>(callback: (value: number, index: number, array: number[]) => U | readonly U[], thisArg?: any) => U[]; flat: <A, D extends number = 1>(this: A, depth?: D) => FlatArray<A, D>[]; [iterator]: () => IterableIterator<number>; [unscopables]: () => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }' but required in type 'number[]'.
10-
!!! related TS2728 /.ts/lib.es5.d.ts:1383:5: 'length' is declared here.
10+
!!! related TS2728 /.ts/lib.es5.d.ts:1307:5: 'length' is declared here.
1111

tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17)
2424
err.massage; // ERROR: Property 'massage' does not exist on type 'Error'
2525
~~~~~~~
2626
!!! error TS2551: Property 'massage' does not exist on type 'Error'. Did you mean 'message'?
27-
!!! related TS2728 /.ts/lib.es5.d.ts:1135:5: 'message' is declared here.
27+
!!! related TS2728 /.ts/lib.es5.d.ts:1059:5: 'message' is declared here.
2828
}
2929

3030
else {

tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS
2222
x.mesage;
2323
~~~~~~
2424
!!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'?
25-
!!! related TS2728 /.ts/lib.es5.d.ts:1135:5: 'message' is declared here.
25+
!!! related TS2728 /.ts/lib.es5.d.ts:1059:5: 'message' is declared here.
2626
}
2727

2828
if (x instanceof Date) {
2929
x.getDate();
3030
x.getHuors();
3131
~~~~~~~~
3232
!!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'?
33-
!!! related TS2728 /.ts/lib.es5.d.ts:883:5: 'getHours' is declared here.
33+
!!! related TS2728 /.ts/lib.es5.d.ts:807:5: 'getHours' is declared here.
3434
}
3535

tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error
4141
x.mesage;
4242
~~~~~~
4343
!!! error TS2551: Property 'mesage' does not exist on type 'Error'. Did you mean 'message'?
44-
!!! related TS2728 /.ts/lib.es5.d.ts:1135:5: 'message' is declared here.
44+
!!! related TS2728 /.ts/lib.es5.d.ts:1059:5: 'message' is declared here.
4545
}
4646

4747
if (isDate(x)) {
4848
x.getDate();
4949
x.getHuors();
5050
~~~~~~~~
5151
!!! error TS2551: Property 'getHuors' does not exist on type 'Date'. Did you mean 'getHours'?
52-
!!! related TS2728 /.ts/lib.es5.d.ts:883:5: 'getHours' is declared here.
52+
!!! related TS2728 /.ts/lib.es5.d.ts:807:5: 'getHours' is declared here.
5353
}
5454

tests/baselines/reference/parserMemberAccessAfterPostfixExpression1.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ tests/cases/conformance/parser/ecmascript5/Expressions/parserMemberAccessAfterPo
1111
!!! error TS1005: ';' expected.
1212
~~~~~~~~
1313
!!! error TS2552: Cannot find name 'toString'. Did you mean 'String'?
14-
!!! related TS2728 /.ts/lib.es5.d.ts:630:13: 'String' is declared here.
14+
!!! related TS2728 /.ts/lib.es5.d.ts:554:13: 'String' is declared here.

tests/baselines/reference/parserRegularExpressionDivideAmbiguity1.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre
77
/notregexp/a.foo();
88
~~~~~~~~~
99
!!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'?
10-
!!! related TS2728 /.ts/lib.es5.d.ts:1131:13: 'RegExp' is declared here.
10+
!!! related TS2728 /.ts/lib.es5.d.ts:1055:13: 'RegExp' is declared here.
1111
~
1212
!!! error TS2304: Cannot find name 'a'.

tests/baselines/reference/parserRegularExpressionDivideAmbiguity2.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ tests/cases/conformance/parser/ecmascript5/RegularExpressions/parserRegularExpre
66
(1) /notregexp/a.foo();
77
~~~~~~~~~
88
!!! error TS2552: Cannot find name 'notregexp'. Did you mean 'RegExp'?
9-
!!! related TS2728 /.ts/lib.es5.d.ts:1131:13: 'RegExp' is declared here.
9+
!!! related TS2728 /.ts/lib.es5.d.ts:1055:13: 'RegExp' is declared here.
1010
~
1111
!!! error TS2304: Cannot find name 'a'.

tests/baselines/reference/parserS7.2_A1.5_T2.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS
1919
$ERROR('#1: eval("\\u00A0var x\\u00A0= 1\\u00A0"); x === 1. Actual: ' + (x));
2020
~~~~~~
2121
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
22-
!!! related TS2728 /.ts/lib.es5.d.ts:1145:13: 'Error' is declared here.
22+
!!! related TS2728 /.ts/lib.es5.d.ts:1069:13: 'Error' is declared here.
2323
}
2424

2525
//CHECK#2
@@ -28,7 +28,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts(20,3): error TS
2828
$ERROR('#2:  var x = 1 ; x === 1. Actual: ' + (x));
2929
~~~~~~
3030
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
31-
!!! related TS2728 /.ts/lib.es5.d.ts:1145:13: 'Error' is declared here.
31+
!!! related TS2728 /.ts/lib.es5.d.ts:1069:13: 'Error' is declared here.
3232
}
3333

3434

tests/baselines/reference/parserS7.3_A1.1_T2.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript5/parserS7.3_A1.1_T2.ts(17,3): error TS
2121
$ERROR('#1: var\\nx\\n=\\n1\\n; x === 1. Actual: ' + (x));
2222
~~~~~~
2323
!!! error TS2552: Cannot find name '$ERROR'. Did you mean 'Error'?
24-
!!! related TS2728 /.ts/lib.es5.d.ts:1145:13: 'Error' is declared here.
24+
!!! related TS2728 /.ts/lib.es5.d.ts:1069:13: 'Error' is declared here.
2525
}
2626

2727

0 commit comments

Comments
 (0)