Skip to content

Commit 465e9c8

Browse files
committed
Revert Function.bind/apply/call this-overloads
1 parent 078d6da commit 465e9c8

22 files changed

Lines changed: 286 additions & 69 deletions

src/lib/es5.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,13 @@ interface Function {
215215
* @param thisArg The object to be used as the this object.
216216
* @param argArray A set of arguments to be passed to the function.
217217
*/
218-
apply<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U;
219218
apply(this: Function, thisArg: any, argArray?: any): any;
220219

221220
/**
222221
* Calls a method of an object, substituting another object for the current object.
223222
* @param thisArg The object to be used as the current object.
224223
* @param argArray A list of arguments to be passed to the method.
225224
*/
226-
call<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U;
227225
call(this: Function, thisArg: any, ...argArray: any[]): any;
228226

229227
/**
@@ -232,7 +230,6 @@ interface Function {
232230
* @param thisArg An object to which the this keyword can refer inside the new function.
233231
* @param argArray A list of arguments to be passed to the new function.
234232
*/
235-
bind<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (this: void, ...argArray: any[]) => U;
236233
bind(this: Function, thisArg: any, ...argArray: any[]): any;
237234

238235
prototype: any;

tests/baselines/reference/assignmentToObjectAndFunction.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(8,5): error TS2322: Type '
55
Property 'apply' is missing in type '{}'.
66
tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
77
Types of property 'apply' are incompatible.
8-
Type 'number' is not assignable to type '{ <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'.
8+
Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'.
99

1010

1111
==== tests/cases/compiler/assignmentToObjectAndFunction.ts (3 errors) ====
@@ -48,4 +48,4 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type
4848
~~~~~~~~~~
4949
!!! error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
5050
!!! error TS2322: Types of property 'apply' are incompatible.
51-
!!! error TS2322: Type 'number' is not assignable to type '{ <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'.
51+
!!! error TS2322: Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'.

tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class C {
1010

1111
var fn = async () => await other.apply(this, arguments);
1212
>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9))
13-
>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
13+
>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
1414
>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13))
15-
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
15+
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
1616
>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0))
1717
>arguments : Symbol(arguments)
1818
}

tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ class C {
99
>other : () => void
1010

1111
var fn = async () => await other.apply(this, arguments);
12-
>fn : () => Promise<void>
13-
>async () => await other.apply(this, arguments) : () => Promise<void>
14-
>await other.apply(this, arguments) : void
15-
>other.apply(this, arguments) : void
16-
>other.apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
12+
>fn : () => Promise<any>
13+
>async () => await other.apply(this, arguments) : () => Promise<any>
14+
>await other.apply(this, arguments) : any
15+
>other.apply(this, arguments) : any
16+
>other.apply : (this: Function, thisArg: any, argArray?: any) => any
1717
>other : () => void
18-
>apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
18+
>apply : (this: Function, thisArg: any, argArray?: any) => any
1919
>this : this
2020
>arguments : IArguments
2121
}

tests/baselines/reference/declarationEmitPromise.symbols

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ export async function runSampleWorks<A, B, C, D, E>(
6868
>T : Symbol(T, Decl(declarationEmitPromise.ts, 8, 16))
6969

7070
f.apply(this, result);
71-
>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
71+
>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
7272
>f : Symbol(f, Decl(declarationEmitPromise.ts, 8, 19))
73-
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
73+
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
7474
>result : Symbol(result, Decl(declarationEmitPromise.ts, 7, 7))
7575

7676
let rfunc: typeof func & {} = func as any; // <- This is the only difference
@@ -140,9 +140,9 @@ export async function runSampleBreaks<A, B, C, D, E>(
140140
>T : Symbol(T, Decl(declarationEmitPromise.ts, 17, 16))
141141

142142
f.apply(this, result);
143-
>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
143+
>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
144144
>f : Symbol(f, Decl(declarationEmitPromise.ts, 17, 19))
145-
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
145+
>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --))
146146
>result : Symbol(result, Decl(declarationEmitPromise.ts, 16, 7))
147147

148148
let rfunc: typeof func = func as any; // <- This is the only difference

tests/baselines/reference/declarationEmitPromise.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export async function runSampleWorks<A, B, C, D, E>(
7878
>T : T
7979

8080
f.apply(this, result);
81-
>f.apply(this, result) : T
82-
>f.apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
81+
>f.apply(this, result) : any
82+
>f.apply : (this: Function, thisArg: any, argArray?: any) => any
8383
>f : (a: A, b?: B, c?: C, d?: D, e?: E) => T
84-
>apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
84+
>apply : (this: Function, thisArg: any, argArray?: any) => any
8585
>this : any
8686
>result : any
8787

@@ -163,10 +163,10 @@ export async function runSampleBreaks<A, B, C, D, E>(
163163
>T : T
164164

165165
f.apply(this, result);
166-
>f.apply(this, result) : T
167-
>f.apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
166+
>f.apply(this, result) : any
167+
>f.apply : (this: Function, thisArg: any, argArray?: any) => any
168168
>f : (a: A, b?: B, c?: C, d?: D, e?: E) => T
169-
>apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
169+
>apply : (this: Function, thisArg: any, argArray?: any) => any
170170
>this : any
171171
>result : any
172172

tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function fn(x = () => this, y = x()) {
1212
}
1313

1414
fn.call(4); // Should be 4
15-
>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
15+
>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --))
1616
>fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0))
17-
>call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
17+
>call : Symbol(Function.call, Decl(lib.d.ts, --, --))
1818

tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function fn(x = () => this, y = x()) {
1616

1717
fn.call(4); // Should be 4
1818
>fn.call(4) : any
19-
>fn.call : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; }
19+
>fn.call : (this: Function, thisArg: any, ...argArray: any[]) => any
2020
>fn : (x?: () => any, y?: any) => any
21-
>call : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; }
21+
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
2222
>4 : number
2323

tests/baselines/reference/functionType.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ function salt() {}
33
>salt : Symbol(salt, Decl(functionType.ts, 0, 0))
44

55
salt.apply("hello", []);
6-
>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
6+
>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
77
>salt : Symbol(salt, Decl(functionType.ts, 0, 0))
8-
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
8+
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
99

1010
(new Function("return 5"))();
1111
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))

tests/baselines/reference/functionType.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ function salt() {}
33
>salt : () => void
44

55
salt.apply("hello", []);
6-
>salt.apply("hello", []) : void
7-
>salt.apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
6+
>salt.apply("hello", []) : any
7+
>salt.apply : (this: Function, thisArg: any, argArray?: any) => any
88
>salt : () => void
9-
>apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
9+
>apply : (this: Function, thisArg: any, argArray?: any) => any
1010
>"hello" : string
1111
>[] : undefined[]
1212

0 commit comments

Comments
 (0)