diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt b/tests/baselines/reference/assignmentToObjectAndFunction.errors.txt index 2e85ee101f5..454ac41b5b8 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 '(thisArg: any, argArray?: any) => any'. + 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; }'. ==== 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 '(thisArg: any, argArray?: any) => any'. \ No newline at end of file +!!! 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 diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es6.symbols index 2f516d7d758..bc061211b88 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.d.ts, --, --)) +>other.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.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 76853858c5c..18a08ffface 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) : any ->other.apply(this, arguments) : any ->other.apply : (thisArg: any, argArray?: any) => any +>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; } >other : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >this : this >arguments : IArguments } diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.symbols index ea0ed9a605c..b836bc88573 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, --, --)) +>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0)) ->call : Symbol(Function.call, Decl(lib.d.ts, --, --)) +>call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types index 55d72e854d3..58c576bf24e 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 : (thisArg: any, ...argArray: any[]) => any +>fn.call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } >fn : (x?: () => any, y?: any) => any ->call : (thisArg: any, ...argArray: any[]) => any +>call : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; } >4 : number diff --git a/tests/baselines/reference/functionType.symbols b/tests/baselines/reference/functionType.symbols index 30a5a7cc447..65347d39b5a 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, --, --)) +>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >salt : Symbol(salt, Decl(functionType.ts, 0, 0)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 e7ea7a47edf..9183ec4a13e 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", []) : any ->salt.apply : (thisArg: any, argArray?: any) => any +>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 : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (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 cd558fdd10a..1aa22b1e994 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, --, --)) +>g.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >g : Symbol(g, Decl(genericTypeParameterEquivalence2.ts, 1, 41)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 3b2c533543d..9fdb03b0fbe 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) : any ->g.apply : (thisArg: any, argArray?: any) => any +>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 : (a: A) => B ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >null : null >a : A diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.symbols index 60b7b08397a..08d3d75e9dc 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, --, --)) +>i.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 7, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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, --, --)) +>b.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(objectTypeWithCallSignatureAppearsToBeFunctionType.ts, 11, 3)) ->apply : Symbol(Function.apply, Decl(lib.d.ts, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types b/tests/baselines/reference/objectTypeWithCallSignatureAppearsToBeFunctionType.types index 74d8ef57d67..496734c9183 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 : (thisArg: any, argArray?: any) => any +>i.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >i : I ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (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 : (thisArg: any, argArray?: any) => any +>b.apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >b : () => void ->apply : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } diff --git a/tests/baselines/reference/returnTypeParameterWithModules.symbols b/tests/baselines/reference/returnTypeParameterWithModules.symbols index 7f8fab382a3..e3b7c50948f 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, --, --)) +>Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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, --, --)) +>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), 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 be09b8f46b0..ffb058daa08 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 : (thisArg: any, argArray?: any) => 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 : { (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 : (thisArg: any, argArray?: any) => any +>apply : { (this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; } >ar : any >e ? [f, e] : [f] : any[] >e : any diff --git a/tests/cases/fourslash/commentsClassMembers.ts b/tests/cases/fourslash/commentsClassMembers.ts index 54b4f0253d4..d719253a57b 100644 --- a/tests/cases/fourslash/commentsClassMembers.ts +++ b/tests/cases/fourslash/commentsClassMembers.ts @@ -694,7 +694,7 @@ verify.completionListContains("a", "(parameter) a: number", "this is first param verify.quickInfoIs("(parameter) a: number", "this is first parameter a\nmore info about a"); goTo.marker('116'); -verify.quickInfoIs("class cWithConstructorProperty", ""); +verify.quickInfoIs("this: this", ""); goTo.marker('117'); verify.quickInfoIs("(local var) bbbb: number", ""); diff --git a/tests/cases/fourslash/instanceTypesForGenericType1.ts b/tests/cases/fourslash/instanceTypesForGenericType1.ts index 96ee175383e..a3d119785bf 100644 --- a/tests/cases/fourslash/instanceTypesForGenericType1.ts +++ b/tests/cases/fourslash/instanceTypesForGenericType1.ts @@ -11,4 +11,4 @@ goTo.marker('1'); verify.quickInfoIs('(property) G.self: G'); goTo.marker('2'); -verify.quickInfoIs('class G'); \ No newline at end of file +verify.quickInfoIs('this: this'); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index c4eecfca5d5..cef78efe0cc 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -1,15 +1,76 @@ +// @strictThis: true /// - -////function someFn1(someFn: { (): void; }) { } +////interface Restricted { +//// n: number; +////} +////function wrapper(wrapped: { (): void; }) { } ////class Foo { -//// public bar() { -//// someFn1( -//// function doSomething() { -//// console.log(th/**/is); +//// n: number; +//// public implicitThis() { +//// wrapper( +//// function implicitVoid() { +//// console.log(th/*1*/is); //// } //// ) +//// console.log(th/*2*/is); +//// } +//// public explicitInterface(th/*3*/is: Restricted) { +//// console.log(th/*4*/is); +//// } +//// public explicitClass(th/*5*/is: Foo) { +//// console.log(th/*6*/is); //// } ////} +////class Bar { +//// public implicitThis() { +//// console.log(th/*7*/is); +//// } +//// public explicitThis(this: Bar) { +//// console.log(thi/*8*/s); +//// } +////} +//// +////function implicitVoid(x: number): void { +//// return th/*9*/is; +////} +////function explicitVoid(th/*10*/is: void, x: number): void { +//// return th/*11*/is; +////} +////function explicitInterface(th/*12*/is: Restricted): void { +//// console.log(thi/*13*/s); +////} +////function explicitLiteral(th/*14*/is: { n: number }): void { +//// console.log(th/*15*/is); +////} -goTo.marker(); -verify.quickInfoIs('any'); +goTo.marker('1'); +verify.quickInfoIs('void'); +goTo.marker('2'); +verify.quickInfoIs('this: this'); +goTo.marker('3'); +verify.quickInfoIs('(parameter) this: Restricted'); +goTo.marker('4'); +verify.quickInfoIs('this: Restricted'); +goTo.marker('5'); +verify.quickInfoIs('(parameter) this: Foo'); +goTo.marker('6'); +verify.quickInfoIs('this: Foo'); +goTo.marker('7'); +verify.quickInfoIs('this: this'); +goTo.marker('8'); +verify.quickInfoIs('this: Bar'); +goTo.marker('9'); +verify.quickInfoIs('void'); +goTo.marker('10'); +verify.quickInfoIs('(parameter) this: void'); +goTo.marker('11'); +verify.quickInfoIs('void'); +goTo.marker('12'); +verify.quickInfoIs('(parameter) this: Restricted'); +goTo.marker('13'); +verify.quickInfoIs('this: Restricted'); +goTo.marker('14'); + +verify.quickInfoIs('(parameter) this: {\n n: number;\n}'); +goTo.marker('15'); +verify.quickInfoIs('this: {\n n: number;\n}'); \ No newline at end of file diff --git a/tests/cases/fourslash/thisBindingInLambda.ts b/tests/cases/fourslash/thisBindingInLambda.ts index f6dfdbdec08..d9c43796bd8 100644 --- a/tests/cases/fourslash/thisBindingInLambda.ts +++ b/tests/cases/fourslash/thisBindingInLambda.ts @@ -9,4 +9,4 @@ ////} goTo.marker(); -verify.quickInfoIs('class Greeter'); +verify.quickInfoIs('this: this');