From 465e9c82fffb98a71857a70cbad798a65bb5119f Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 28 Apr 2016 08:48:08 -0700 Subject: [PATCH 1/2] Revert Function.bind/apply/call this-overloads --- src/lib/es5.d.ts | 3 - .../assignmentToObjectAndFunction.errors.txt | 4 +- ...ArrowFunctionCapturesArguments_es6.symbols | 4 +- ...ncArrowFunctionCapturesArguments_es6.types | 12 +-- .../reference/declarationEmitPromise.symbols | 8 +- .../reference/declarationEmitPromise.types | 12 +-- ...nctionsInFunctionParameterDefaults.symbols | 4 +- ...functionsInFunctionParameterDefaults.types | 4 +- .../baselines/reference/functionType.symbols | 4 +- tests/baselines/reference/functionType.types | 6 +- .../genericTypeParameterEquivalence2.symbols | 4 +- .../genericTypeParameterEquivalence2.types | 6 +- ...eCompilationRestParamJsDocFunction.symbols | 20 ++--- ...ileCompilationRestParamJsDocFunction.types | 20 ++--- ...llSignatureAppearsToBeFunctionType.symbols | 8 +- ...CallSignatureAppearsToBeFunctionType.types | 8 +- .../returnTypeParameterWithModules.symbols | 4 +- .../returnTypeParameterWithModules.types | 4 +- .../reference/thisTypeInFunctions2.js | 51 +++++++++++ .../reference/thisTypeInFunctions2.symbols | 56 ++++++++++++ .../reference/thisTypeInFunctions2.types | 87 +++++++++++++++++++ .../types/thisType/thisTypeInFunctions2.ts | 26 ++++++ 22 files changed, 286 insertions(+), 69 deletions(-) create mode 100644 tests/baselines/reference/thisTypeInFunctions2.js create mode 100644 tests/baselines/reference/thisTypeInFunctions2.symbols create mode 100644 tests/baselines/reference/thisTypeInFunctions2.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 17916d5548e..967aeb42aaf 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -215,7 +215,6 @@ 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(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; apply(this: Function, thisArg: any, argArray?: any): any; /** @@ -223,7 +222,6 @@ interface Function { * @param thisArg The object to be used as the current object. * @param argArray A list of arguments to be passed to the method. */ - call(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; call(this: Function, thisArg: any, ...argArray: any[]): any; /** @@ -232,7 +230,6 @@ 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(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (this: void, ...argArray: any[]) => U; bind(this: Function, thisArg: any, ...argArray: any[]): any; prototype: any; diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt index 454ac41b5b8..204135cd004 100644 --- a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt +++ b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(8,5): error TS2322: Type ' Property 'apply' is missing in type '{}'. tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'. Types of property 'apply' are incompatible. - Type 'number' is not assignable to type '{ (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'. + Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'. ==== tests/cases/compiler/assignmentToObjectAndFunction.ts (3 errors) ==== @@ -48,4 +48,4 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type ~~~~~~~~~~ !!! error TS2322: Type 'typeof bad' is not assignable to type 'Function'. !!! error TS2322: Types of property 'apply' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '{ (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 06999513192..4b312fd4646 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols @@ -10,9 +10,9 @@ class C { var fn = async () => await other.apply(this, arguments); >fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9)) ->other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types index 18a08ffface..bb9df9af139 100644 --- a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.types @@ -9,13 +9,13 @@ class C { >other : () => void var fn = async () => await other.apply(this, arguments); ->fn : () => Promise ->async () => await other.apply(this, arguments) : () => Promise ->await other.apply(this, arguments) : void ->other.apply(this, arguments) : void ->other.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any >other : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : this >arguments : IArguments } diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index 894a20e03a6..2c37e1dfa78 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -68,9 +68,9 @@ export async function runSampleWorks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 8, 16)) f.apply(this, result); ->f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 8, 19)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 7, 7)) let rfunc: typeof func & {} = func as any; // <- This is the only difference @@ -140,9 +140,9 @@ export async function runSampleBreaks( >T : Symbol(T, Decl(declarationEmitPromise.ts, 17, 16)) f.apply(this, result); ->f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>f.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >f : Symbol(f, Decl(declarationEmitPromise.ts, 17, 19)) ->apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(declarationEmitPromise.ts, 16, 7)) let rfunc: typeof func = func as any; // <- This is the only difference diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 0306c72762b..4edaa444326 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -78,10 +78,10 @@ export async function runSampleWorks( >T : T f.apply(this, result); ->f.apply(this, result) : T ->f.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>f.apply(this, result) : any +>f.apply : (this: Function, thisArg: any, argArray?: any) => any >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : any >result : any @@ -163,10 +163,10 @@ export async function runSampleBreaks( >T : T f.apply(this, result); ->f.apply(this, result) : T ->f.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>f.apply(this, result) : any +>f.apply : (this: Function, thisArg: any, argArray?: any) => any >f : (a: A, b?: B, c?: C, d?: D, e?: E) => T ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >this : any >result : any diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols index b836bc88573..ea0ed9a605c 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols +++ b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols @@ -12,7 +12,7 @@ function fn(x = () => this, y = x()) { } fn.call(4); // Should be 4 ->fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types index 58c576bf24e..39cd994dcc1 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types @@ -16,8 +16,8 @@ function fn(x = () => this, y = x()) { fn.call(4); // Should be 4 >fn.call(4) : any ->fn.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>fn.call : (this: Function, thisArg: any, ...argArray: any[]) => any >fn : (x?: () => any, y?: any) => any ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >4 : number diff --git a/tests/baselines/reference/functionType.symbols b/tests/baselines/reference/functionType.symbols index 65347d39b5a..30a5a7cc447 100644 --- a/tests/baselines/reference/functionType.symbols +++ b/tests/baselines/reference/functionType.symbols @@ -3,9 +3,9 @@ function salt() {} >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) salt.apply("hello", []); ->salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) (new Function("return 5"))(); >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/functionType.types b/tests/baselines/reference/functionType.types index 9183ec4a13e..ac3d5c9944d 100644 --- a/tests/baselines/reference/functionType.types +++ b/tests/baselines/reference/functionType.types @@ -3,10 +3,10 @@ function salt() {} >salt : () => void salt.apply("hello", []); ->salt.apply("hello", []) : void ->salt.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>salt.apply("hello", []) : any +>salt.apply : (this: Function, thisArg: any, argArray?: any) => any >salt : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >"hello" : string >[] : undefined[] diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.symbols b/tests/baselines/reference/genericTypeParameterEquivalence2.symbols index 1aa22b1e994..cd558fdd10a 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.symbols +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.symbols @@ -24,9 +24,9 @@ function compose(f: (b: B) => C, g: (a:A) => B): (a:A) => C { return f(g.apply(null, a)); >f : Symbol(f, Decl(genericTypeParameterEquivalence2.ts, 1, 26)) ->g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(genericTypeParameterEquivalence2.ts, 2, 21)) }; diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 9fdb03b0fbe..44e495088bc 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -26,10 +26,10 @@ function compose(f: (b: B) => C, g: (a:A) => B): (a:A) => C { return f(g.apply(null, a)); >f(g.apply(null, a)) : C >f : (b: B) => C ->g.apply(null, a) : B ->g.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>g.apply(null, a) : any +>g.apply : (this: Function, thisArg: any, argArray?: any) => any >g : (a: A) => B ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >null : null >a : A diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols index 62e47c8a3c4..f21653d475b 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols @@ -26,39 +26,39 @@ function apply(func, thisArg, args) { >length : Symbol(length, Decl(_apply.js, 12, 7)) case 0: return func.call(thisArg); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) case 1: return func.call(thisArg, args[0]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) case 2: return func.call(thisArg, args[0], args[1]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) case 3: return func.call(thisArg, args[0], args[1], args[2]); ->func.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) >args : Symbol(args, Decl(_apply.js, 11, 29)) } return func.apply(thisArg, args); ->func.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>func.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >func : Symbol(func, Decl(_apply.js, 11, 15)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >thisArg : Symbol(thisArg, Decl(_apply.js, 11, 20)) >args : Symbol(args, Decl(_apply.js, 11, 29)) } diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index 78d0fd1392b..fbfe9d3edae 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -28,17 +28,17 @@ function apply(func, thisArg, args) { case 0: return func.call(thisArg); >0 : number >func.call(thisArg) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any case 1: return func.call(thisArg, args[0]); >1 : number >func.call(thisArg, args[0]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -47,9 +47,9 @@ function apply(func, thisArg, args) { case 2: return func.call(thisArg, args[0], args[1]); >2 : number >func.call(thisArg, args[0], args[1]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -61,9 +61,9 @@ function apply(func, thisArg, args) { case 3: return func.call(thisArg, args[0], args[1], args[2]); >3 : number >func.call(thisArg, args[0], args[1], args[2]) : any ->func.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any >func : Function ->call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } +>call : (this: Function, thisArg: any, ...argArray: any[]) => any >thisArg : any >args[0] : any >args : any[] @@ -77,9 +77,9 @@ function apply(func, thisArg, args) { } return func.apply(thisArg, args); >func.apply(thisArg, args) : any ->func.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>func.apply : (this: Function, thisArg: any, argArray?: any) => any >func : Function ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >thisArg : any >args : any[] } diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols index 08d3d75e9dc..60b7b08397a 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols @@ -20,9 +20,9 @@ var r2b: (x: any, y?: any) => any = i.apply; >r2b : Symbol(r2b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 9, 17)) ->i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 7, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) var b: { >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) @@ -38,7 +38,7 @@ var rb4: (x: any, y?: any) => any = b.apply; >rb4 : Symbol(rb4, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 3)) >x : Symbol(x, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 10)) >y : Symbol(y, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 16, 17)) ->b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types index 496734c9183..80408cff962 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types +++ b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types @@ -21,9 +21,9 @@ var r2b: (x: any, y?: any) => any = i.apply; >r2b : (x: any, y?: any) => any >x : any >y : any ->i.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>i.apply : (this: Function, thisArg: any, argArray?: any) => any >i : I ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any var b: { >b : () => void @@ -40,7 +40,7 @@ var rb4: (x: any, y?: any) => any = b.apply; >rb4 : (x: any, y?: any) => any >x : any >y : any ->b.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>b.apply : (this: Function, thisArg: any, argArray?: any) => any >b : () => void ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any diff --git a/tests/baselines/reference/returnTypeParameterWithModules.symbols b/tests/baselines/reference/returnTypeParameterWithModules.symbols index e3b7c50948f..7f8fab382a3 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.symbols +++ b/tests/baselines/reference/returnTypeParameterWithModules.symbols @@ -12,13 +12,13 @@ module M1 { >A : Symbol(A, Decl(returnTypeParameterWithModules.ts, 1, 27)) return Array.prototype.reduce.apply(ar, e ? [f, e] : [f]); ->Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >Array.prototype.reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, --, --)) >reduce : Symbol(Array.reduce, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) >ar : Symbol(ar, Decl(returnTypeParameterWithModules.ts, 1, 30)) >e : Symbol(e, Decl(returnTypeParameterWithModules.ts, 1, 36)) >f : Symbol(f, Decl(returnTypeParameterWithModules.ts, 1, 33)) diff --git a/tests/baselines/reference/returnTypeParameterWithModules.types b/tests/baselines/reference/returnTypeParameterWithModules.types index ffb058daa08..584c962a170 100644 --- a/tests/baselines/reference/returnTypeParameterWithModules.types +++ b/tests/baselines/reference/returnTypeParameterWithModules.types @@ -13,13 +13,13 @@ module M1 { return Array.prototype.reduce.apply(ar, e ? [f, e] : [f]); >Array.prototype.reduce.apply(ar, e ? [f, e] : [f]) : any ->Array.prototype.reduce.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>Array.prototype.reduce.apply : (this: Function, thisArg: any, argArray?: any) => any >Array.prototype.reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } >Array.prototype : any[] >Array : ArrayConstructor >prototype : any[] >reduce : { (callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; (callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U; } ->apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } +>apply : (this: Function, thisArg: any, argArray?: any) => any >ar : any >e ? [f, e] : [f] : any[] >e : any diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js new file mode 100644 index 00000000000..7fc52877191 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.js @@ -0,0 +1,51 @@ +//// [thisTypeInFunctions2.ts] +interface Arguments { + init?: (this: void) => void; + willDestroy?: (this: any) => void; + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +} +declare function extend(arguments: Arguments): void; +class Mixin { + stuff: number; +} + +extend({ + init() { + this + }, + mine: 12, + bar() { + this.init(); + }, + foo() { + this.bar; + this.url + this.handler() + this.baz + this.willDestroy + } +}) + + +//// [thisTypeInFunctions2.js] +var Mixin = (function () { + function Mixin() { + } + return Mixin; +}()); +extend({ + init: function () { + this; + }, + mine: 12, + bar: function () { + this.init(); + }, + foo: function () { + this.bar; + this.url; + this.handler(); + this.baz; + this.willDestroy; + } +}); diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols new file mode 100644 index 00000000000..5e186e9485d --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -0,0 +1,56 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === +interface Arguments { +>Arguments : Symbol(Arguments, Decl(thisTypeInFunctions2.ts, 0, 0)) + + init?: (this: void) => void; +>init : Symbol(Arguments.init, Decl(thisTypeInFunctions2.ts, 0, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 1, 12)) + + willDestroy?: (this: any) => void; +>willDestroy : Symbol(Arguments.willDestroy, Decl(thisTypeInFunctions2.ts, 1, 32)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 19)) + + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +>propName : Symbol(propName, Decl(thisTypeInFunctions2.ts, 3, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 3, 87)) +>args : Symbol(args, Decl(thisTypeInFunctions2.ts, 3, 97)) +} +declare function extend(arguments: Arguments): void; +>extend : Symbol(extend, Decl(thisTypeInFunctions2.ts, 4, 1)) +>arguments : Symbol(arguments, Decl(thisTypeInFunctions2.ts, 5, 24)) +>Arguments : Symbol(Arguments, Decl(thisTypeInFunctions2.ts, 0, 0)) + +class Mixin { +>Mixin : Symbol(Mixin, Decl(thisTypeInFunctions2.ts, 5, 52)) + + stuff: number; +>stuff : Symbol(Mixin.stuff, Decl(thisTypeInFunctions2.ts, 6, 13)) +} + +extend({ +>extend : Symbol(extend, Decl(thisTypeInFunctions2.ts, 4, 1)) + + init() { +>init : Symbol(init, Decl(thisTypeInFunctions2.ts, 10, 8)) + + this + }, + mine: 12, +>mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 13, 6)) + + bar() { +>bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 14, 13)) + + this.init(); + }, + foo() { +>foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 17, 6)) + + this.bar; + this.url + this.handler() + this.baz + this.willDestroy + } +}) + diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types new file mode 100644 index 00000000000..3e3e9123549 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -0,0 +1,87 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === +interface Arguments { +>Arguments : Arguments + + init?: (this: void) => void; +>init : (this: void) => void +>this : void + + willDestroy?: (this: any) => void; +>willDestroy : (this: any) => void +>this : any + + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +>propName : string +>null : null +>this : any +>args : any[] +} +declare function extend(arguments: Arguments): void; +>extend : (arguments: Arguments) => void +>arguments : Arguments +>Arguments : Arguments + +class Mixin { +>Mixin : Mixin + + stuff: number; +>stuff : number +} + +extend({ +>extend({ init() { this }, mine: 12, bar() { this.init(); }, foo() { this.bar; this.url this.handler() this.baz this.willDestroy }}) : void +>extend : (arguments: Arguments) => void +>{ init() { this }, mine: 12, bar() { this.init(); }, foo() { this.bar; this.url this.handler() this.baz this.willDestroy }} : { init(): void; mine: number; bar(): void; foo(): void; } + + init() { +>init : () => void + + this +>this : void + + }, + mine: 12, +>mine : number +>12 : number + + bar() { +>bar : () => void + + this.init(); +>this.init() : any +>this.init : any +>this : any +>init : any + + }, + foo() { +>foo : () => void + + this.bar; +>this.bar : any +>this : any +>bar : any + + this.url +>this.url : any +>this : any +>url : any + + this.handler() +>this.handler() : any +>this.handler : any +>this : any +>handler : any + + this.baz +>this.baz : any +>this : any +>baz : any + + this.willDestroy +>this.willDestroy : any +>this : any +>willDestroy : any + } +}) + diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts new file mode 100644 index 00000000000..c33c5062249 --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts @@ -0,0 +1,26 @@ +interface Arguments { + init?: (this: void) => void; + willDestroy?: (this: any) => void; + [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); +} +declare function extend(arguments: Arguments): void; +class Mixin { + stuff: number; +} + +extend({ + init() { + this + }, + mine: 12, + bar() { + this.init(); + }, + foo() { + this.bar; + this.url + this.handler() + this.baz + this.willDestroy + } +}) From 3520c6e833a6b95baa81235db4de66bfd5dc79c5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 28 Apr 2016 09:02:20 -0700 Subject: [PATCH 2/2] Remove incorrectly added extra test --- .../reference/thisTypeInFunctions2.js | 51 ----------- .../reference/thisTypeInFunctions2.symbols | 56 ------------ .../reference/thisTypeInFunctions2.types | 87 ------------------- .../types/thisType/thisTypeInFunctions2.ts | 26 ------ 4 files changed, 220 deletions(-) delete mode 100644 tests/baselines/reference/thisTypeInFunctions2.js delete mode 100644 tests/baselines/reference/thisTypeInFunctions2.symbols delete mode 100644 tests/baselines/reference/thisTypeInFunctions2.types delete mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts diff --git a/tests/baselines/reference/thisTypeInFunctions2.js b/tests/baselines/reference/thisTypeInFunctions2.js deleted file mode 100644 index 7fc52877191..00000000000 --- a/tests/baselines/reference/thisTypeInFunctions2.js +++ /dev/null @@ -1,51 +0,0 @@ -//// [thisTypeInFunctions2.ts] -interface Arguments { - init?: (this: void) => void; - willDestroy?: (this: any) => void; - [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); -} -declare function extend(arguments: Arguments): void; -class Mixin { - stuff: number; -} - -extend({ - init() { - this - }, - mine: 12, - bar() { - this.init(); - }, - foo() { - this.bar; - this.url - this.handler() - this.baz - this.willDestroy - } -}) - - -//// [thisTypeInFunctions2.js] -var Mixin = (function () { - function Mixin() { - } - return Mixin; -}()); -extend({ - init: function () { - this; - }, - mine: 12, - bar: function () { - this.init(); - }, - foo: function () { - this.bar; - this.url; - this.handler(); - this.baz; - this.willDestroy; - } -}); diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols deleted file mode 100644 index 5e186e9485d..00000000000 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ /dev/null @@ -1,56 +0,0 @@ -=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === -interface Arguments { ->Arguments : Symbol(Arguments, Decl(thisTypeInFunctions2.ts, 0, 0)) - - init?: (this: void) => void; ->init : Symbol(Arguments.init, Decl(thisTypeInFunctions2.ts, 0, 21)) ->this : Symbol(this, Decl(thisTypeInFunctions2.ts, 1, 12)) - - willDestroy?: (this: any) => void; ->willDestroy : Symbol(Arguments.willDestroy, Decl(thisTypeInFunctions2.ts, 1, 32)) ->this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 19)) - - [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); ->propName : Symbol(propName, Decl(thisTypeInFunctions2.ts, 3, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions2.ts, 3, 87)) ->args : Symbol(args, Decl(thisTypeInFunctions2.ts, 3, 97)) -} -declare function extend(arguments: Arguments): void; ->extend : Symbol(extend, Decl(thisTypeInFunctions2.ts, 4, 1)) ->arguments : Symbol(arguments, Decl(thisTypeInFunctions2.ts, 5, 24)) ->Arguments : Symbol(Arguments, Decl(thisTypeInFunctions2.ts, 0, 0)) - -class Mixin { ->Mixin : Symbol(Mixin, Decl(thisTypeInFunctions2.ts, 5, 52)) - - stuff: number; ->stuff : Symbol(Mixin.stuff, Decl(thisTypeInFunctions2.ts, 6, 13)) -} - -extend({ ->extend : Symbol(extend, Decl(thisTypeInFunctions2.ts, 4, 1)) - - init() { ->init : Symbol(init, Decl(thisTypeInFunctions2.ts, 10, 8)) - - this - }, - mine: 12, ->mine : Symbol(mine, Decl(thisTypeInFunctions2.ts, 13, 6)) - - bar() { ->bar : Symbol(bar, Decl(thisTypeInFunctions2.ts, 14, 13)) - - this.init(); - }, - foo() { ->foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 17, 6)) - - this.bar; - this.url - this.handler() - this.baz - this.willDestroy - } -}) - diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types deleted file mode 100644 index 3e3e9123549..00000000000 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ /dev/null @@ -1,87 +0,0 @@ -=== tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts === -interface Arguments { ->Arguments : Arguments - - init?: (this: void) => void; ->init : (this: void) => void ->this : void - - willDestroy?: (this: any) => void; ->willDestroy : (this: any) => void ->this : any - - [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); ->propName : string ->null : null ->this : any ->args : any[] -} -declare function extend(arguments: Arguments): void; ->extend : (arguments: Arguments) => void ->arguments : Arguments ->Arguments : Arguments - -class Mixin { ->Mixin : Mixin - - stuff: number; ->stuff : number -} - -extend({ ->extend({ init() { this }, mine: 12, bar() { this.init(); }, foo() { this.bar; this.url this.handler() this.baz this.willDestroy }}) : void ->extend : (arguments: Arguments) => void ->{ init() { this }, mine: 12, bar() { this.init(); }, foo() { this.bar; this.url this.handler() this.baz this.willDestroy }} : { init(): void; mine: number; bar(): void; foo(): void; } - - init() { ->init : () => void - - this ->this : void - - }, - mine: 12, ->mine : number ->12 : number - - bar() { ->bar : () => void - - this.init(); ->this.init() : any ->this.init : any ->this : any ->init : any - - }, - foo() { ->foo : () => void - - this.bar; ->this.bar : any ->this : any ->bar : any - - this.url ->this.url : any ->this : any ->url : any - - this.handler() ->this.handler() : any ->this.handler : any ->this : any ->handler : any - - this.baz ->this.baz : any ->this : any ->baz : any - - this.willDestroy ->this.willDestroy : any ->this : any ->willDestroy : any - } -}) - diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts deleted file mode 100644 index c33c5062249..00000000000 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions2.ts +++ /dev/null @@ -1,26 +0,0 @@ -interface Arguments { - init?: (this: void) => void; - willDestroy?: (this: any) => void; - [propName: string]: number | string | boolean | symbol | undefined | null | {} | ((this: any, ...args:any[]) => any); -} -declare function extend(arguments: Arguments): void; -class Mixin { - stuff: number; -} - -extend({ - init() { - this - }, - mine: 12, - bar() { - this.init(); - }, - foo() { - this.bar; - this.url - this.handler() - this.baz - this.willDestroy - } -})