diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7ae21a6338e..9363a8796ee 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1307,9 +1307,6 @@ namespace ts { // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - if (options.strictThisChecks) { - seenThisKeyword = true; - } return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); case SyntaxKind.FunctionDeclaration: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5017f0dcd2c..51fad3e7f33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3520,7 +3520,6 @@ namespace ts { return isIndependentVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return compilerOptions.strictThisChecks ? false : isIndependentFunctionLikeDeclaration(declaration); case SyntaxKind.Constructor: return isIndependentFunctionLikeDeclaration(declaration); } @@ -4234,21 +4233,6 @@ namespace ts { if (minArgumentCount < 0) { minArgumentCount = declaration.parameters.length - (hasThisParameter ? 1 : 0); } - if (!hasThisParameter && compilerOptions.strictThisChecks) { - if (declaration.kind === SyntaxKind.FunctionDeclaration || - declaration.kind === SyntaxKind.CallSignature || - declaration.kind == SyntaxKind.FunctionExpression || - declaration.kind === SyntaxKind.FunctionType) { - thisType = voidType; - } - else if ((declaration.kind === SyntaxKind.MethodDeclaration || declaration.kind === SyntaxKind.MethodSignature) - && (isClassLike(declaration.parent) || declaration.parent.kind === SyntaxKind.InterfaceDeclaration)) { - thisType = declaration.flags & NodeFlags.Static ? - getTypeOfSymbol(getSymbolOfNode(declaration.parent)) : - getThisType(declaration.name); - Debug.assert(!!thisType, "couldn't find implicit this type"); - } - } if (isJSConstructSignature) { minArgumentCount--; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f6e1d9b48d7..cf55f030c33 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -137,10 +137,6 @@ namespace ts { name: "skipDefaultLibCheck", type: "boolean", }, - { - name: "strictThisChecks", - type: "boolean", - }, { name: "out", type: "string", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dfa1b54e428..5965a39a79e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2407,7 +2407,6 @@ namespace ts { rootDir?: string; sourceMap?: boolean; sourceRoot?: string; - strictThisChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; diff --git a/tests/baselines/reference/thisTypeInFunctions.js b/tests/baselines/reference/thisTypeInFunctions.js index e963dad60f7..74eba32082b 100644 --- a/tests/baselines/reference/thisTypeInFunctions.js +++ b/tests/baselines/reference/thisTypeInFunctions.js @@ -8,9 +8,6 @@ class C { explicitThis(this: this, m: number): number { return this.n + m; } - implicitThis(m: number): number { - return this.n + m; - } explicitC(this: C, m: number): number { return this.n + m; } @@ -29,8 +26,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; - implicitMethod(): number; - implicitFunction: () => number; } function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -39,7 +34,7 @@ function justThis(this: { y: number }): number { return this.y; } function implicitThis(n: number): number { - return 12; + return this.m + n + 12; } let impl: I = { a: 12, @@ -54,10 +49,6 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) } impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = () => 12; @@ -66,9 +57,6 @@ impl.explicitInterface = function() { return this.a; }; impl.explicitStructural = () => 12; impl.explicitInterface = () => 12; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = () => 12; -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; @@ -82,29 +70,26 @@ let ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); - +let explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -143,8 +128,6 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; -c.implicitThis = function(m) { return this.n + m }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; @@ -154,19 +137,17 @@ c.explicitVoid = n => n; // class-based assignability class Base1 { x: number; - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.y; } static explicitStatic(this: typeof Base1): number { return this.y; } static y: number; - } class Derived1 extends Base1 { y: number } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -176,14 +157,14 @@ let b1 = new Base1(); let b2 = new Base2(); let d1 = new Derived1(); let d2 = new Derived2(); -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -206,7 +187,7 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } //// [thisTypeInFunctions.js] @@ -228,9 +209,6 @@ var C = (function () { C.prototype.explicitThis = function (m) { return this.n + m; }; - C.prototype.implicitThis = function (m) { - return this.n + m; - }; C.prototype.explicitC = function (m) { return this.n + m; }; @@ -256,7 +234,7 @@ function justThis() { return this.y; } function implicitThis(n) { - return 12; + return this.m + n + 12; } var impl = { a: 12, @@ -270,11 +248,7 @@ var impl = { }, explicitThis: function () { return this.a; - }, - implicitMethod: function () { - return this.a; - }, - implicitFunction: function () { return _this.a; } + } }; impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = function () { return 12; }; @@ -283,9 +257,6 @@ impl.explicitInterface = function () { return this.a; }; impl.explicitStructural = function () { return 12; }; impl.explicitInterface = function () { return 12; }; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = function () { return 12; }; -impl.implicitFunction = function () { return _this.a; }; // ok, this: any because it refers to some outer object (window?) // parameter checking var ok = { y: 12, f: explicitStructural }; var implicitAnyOk = { notSpecified: 12, f: implicitThis }; @@ -298,21 +269,20 @@ var ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); var reconstructed = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); +var explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking var unboundToSpecified = function (x) { return x + _this.y; }; // ok, this:any var specifiedToSpecified = explicitStructural; @@ -344,8 +314,6 @@ c.explicitThis = function (m) { return this.n + m; }; c.explicitC = function (m) { return this.n + m; }; c.explicitProperty = function (m) { return this.n + m; }; c.explicitThis = function (m) { return this.n + m; }; -c.implicitThis = function (m) { return this.n + m; }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function (m) { return this.n + m; }; // this:void compatibility c.explicitVoid = function (n) { return n; }; @@ -353,9 +321,8 @@ c.explicitVoid = function (n) { return n; }; var Base1 = (function () { function Base1() { } - Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.polymorphic = function () { return this.x; }; Base1.prototype.explicit = function () { return this.x; }; - Base1.implicitStatic = function () { return this.y; }; Base1.explicitStatic = function () { return this.y; }; return Base1; }()); @@ -369,7 +336,7 @@ var Derived1 = (function (_super) { var Base2 = (function () { function Base2() { } - Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.polymorphic = function () { return this.y; }; Base2.prototype.explicit = function () { return this.x; }; return Base2; }()); @@ -384,13 +351,13 @@ var b1 = new Base1(); var b2 = new Base2(); var d1 = new Derived1(); var d2 = new Derived2(); -d2.implicit = d1.implicit; // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit; // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic; // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic; // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit; // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit; // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit; // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic; // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit; // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic; // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic; // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis() { this.a = 12; @@ -405,4 +372,4 @@ var interfaceThis = new InterfaceThis(); var literalTypeThis = new LiteralTypeThis(); var anyThis = new AnyThis(); var n = f.call(12); -function missingTypeIsImplicitAny(a) { return a; } +function missingTypeIsImplicitAny(a) { return this.anything + a; } diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 9cd1915fc94..1d51f4aaca0 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -22,841 +22,763 @@ class C { >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 6, 28)) - } - implicitThis(m: number): number { ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) - - return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 17)) } explicitC(this: C, m: number): number { ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 14)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) return this.n + m; >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 9, 22)) } explicitProperty(this: {n: number}, m: number): number { ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 21)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) return this.n + m; ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 39)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 12, 39)) } explicitVoid(this: void, m: number): number { ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 18, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 15, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) return m + 1; ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 18, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 15, 28)) } } class D extends C { } ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) interface I { ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) a: number; ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 23, 13)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 20, 13)) explicitVoid1(this: void): number; ->explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 18)) +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 22, 18)) explicitVoid2(this: void): number; ->explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 18)) +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 23, 18)) explicitStructural(this: {a: number}): number; ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 27, 23)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) explicitInterface(this: I): number; ->explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 22)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) explicitThis(this: this): number; ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 29, 17)) - - implicitMethod(): number; ->implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) - - implicitFunction: () => number; ->implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) } function explicitStructural(this: { y: number }, x: number): number { ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 33, 28)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 28, 28)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 28, 48)) return x + this.y; ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 33, 48)) ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 33, 33)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 33, 35)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 28, 48)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 28, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 28, 35)) } function justThis(this: { y: number }): number { ->justThis : Symbol(justThis, Decl(thisTypeInFunctions.ts, 35, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 36, 18)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +>justThis : Symbol(justThis, Decl(thisTypeInFunctions.ts, 30, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 31, 18)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) return this.y; ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 36, 23)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 36, 25)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 31, 23)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 31, 25)) } function implicitThis(n: number): number { ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 39, 22)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 34, 22)) - return 12; + return this.m + n + 12; +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 34, 22)) } let impl: I = { ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) a: 12, ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 42, 15)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 37, 15)) explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) ->explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 43, 10)) +>explicitVoid2 : Symbol(explicitVoid2, Decl(thisTypeInFunctions.ts, 38, 10)) explicitVoid1() { return 12; }, ->explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 44, 32)) +>explicitVoid1 : Symbol(explicitVoid1, Decl(thisTypeInFunctions.ts, 39, 32)) explicitStructural() { ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 45, 35)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 40, 35)) return this.a; ->this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) }, explicitInterface() { ->explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 48, 6)) +>explicitInterface : Symbol(explicitInterface, Decl(thisTypeInFunctions.ts, 43, 6)) return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, explicitThis() { ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 51, 6)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 46, 6)) return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, - implicitMethod() { ->implicitMethod : Symbol(implicitMethod, Decl(thisTypeInFunctions.ts, 54, 6)) - - return this.a; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) ->implicitFunction : Symbol(implicitFunction, Decl(thisTypeInFunctions.ts, 57, 6)) } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 24, 14)) +>impl.explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitVoid1 : Symbol(I.explicitVoid1, Decl(thisTypeInFunctions.ts, 21, 14)) impl.explicitVoid2 = () => 12; ->impl.explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 25, 38)) +>impl.explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitVoid2 : Symbol(I.explicitVoid2, Decl(thisTypeInFunctions.ts, 22, 38)) impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 27, 28)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 27, 30)) +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) impl.explicitStructural = () => 12; ->impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 26, 38)) +>impl.explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) impl.explicitInterface = () => 12; ->impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 27, 50)) +>impl.explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) impl.explicitThis = function () { return this.a; }; ->impl.explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 28, 39)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - -impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) - -impl.implicitMethod = () => 12; ->impl.implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitMethod : Symbol(I.implicitMethod, Decl(thisTypeInFunctions.ts, 29, 37)) - -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) ->impl.implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) ->impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 42, 3)) ->implicitFunction : Symbol(I.implicitFunction, Decl(thisTypeInFunctions.ts, 30, 29)) +>impl.explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) +>explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; ->ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 9)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 71, 24)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 31)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 71, 44)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 71, 70)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 77)) ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 59, 3)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 9)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 59, 24)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 31)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 59, 44)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 59, 70)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 77)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; ->implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) ->notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 20)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 72, 46)) ->notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 72, 71)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 89)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 60, 3)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 60, 20)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 60, 46)) +>notSpecified : Symbol(notSpecified, Decl(thisTypeInFunctions.ts, 60, 71)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 89)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) ok.f(13); ->ok.f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) ->ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 71, 3)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 71, 19)) +>ok.f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) +>ok : Symbol(ok, Decl(thisTypeInFunctions.ts, 59, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 59, 19)) implicitThis(12); ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 38, 1)) +>implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 33, 1)) implicitAnyOk.f(12); ->implicitAnyOk.f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) ->implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 72, 3)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 72, 41)) +>implicitAnyOk.f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) +>implicitAnyOk : Symbol(implicitAnyOk, Decl(thisTypeInFunctions.ts, 60, 3)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 60, 41)) let c = new C(); ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) let d = new D(); ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->D : Symbol(D, Decl(thisTypeInFunctions.ts, 21, 1)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>D : Symbol(D, Decl(thisTypeInFunctions.ts, 18, 1)) let ripped = c.explicitC; ->ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 79, 3)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>ripped : Symbol(ripped, Decl(thisTypeInFunctions.ts, 67, 3)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) c.explicitC(12); ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) c.explicitProperty(12); ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) c.explicitThis(12); >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) -c.implicitThis(12); ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - d.explicitC(12); ->d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>d.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) d.explicitProperty(12); ->d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>d.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) d.explicitThis(12); >d.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) +>d : Symbol(d, Decl(thisTypeInFunctions.ts, 66, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) -d.implicitThis(12); ->d.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->d : Symbol(d, Decl(thisTypeInFunctions.ts, 78, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - let reconstructed: { ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) n: number, ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 88, 20)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 74, 20)) explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 89, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 90, 17)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 76, 17)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 90, 25)) - - implicitThis(m: number): number, ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 91, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 76, 25)) explicitC(this: C, m: number): number, ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 91, 36)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 14)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 76, 45)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 77, 14)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 92, 22)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 77, 22)) explicitProperty: (this: {n : number}, m: number) => number, ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 93, 23)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 93, 30)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 93, 42)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 78, 23)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 78, 30)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 78, 42)) explicitVoid(this: void, m: number): number, ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 93, 64)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 94, 17)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 94, 28)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 79, 17)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 79, 28)) } = { n: 12, ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 95, 5)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 80, 5)) explicitThis: c.explicitThis, ->explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 96, 10)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 81, 10)) >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) - implicitThis: c.implicitThis, ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 97, 33)) ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) - explicitC: c.explicitC, ->explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 98, 33)) ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitC : Symbol(explicitC, Decl(thisTypeInFunctions.ts, 82, 33)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) explicitProperty: c.explicitProperty, ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 99, 27)) ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 83, 27)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) explicitVoid: c.explicitVoid ->explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 100, 41)) ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 84, 41)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) }; -reconstructed.explicitProperty(11); ->reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +reconstructed.explicitThis(10); +>reconstructed.explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitThis : Symbol(explicitThis, Decl(thisTypeInFunctions.ts, 75, 14)) -reconstructed.implicitThis(11); ->reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +reconstructed.explicitProperty(11); +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) + +let explicitVoid = reconstructed.explicitVoid; +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 89, 3)) +>reconstructed.explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 78, 64)) + +explicitVoid(12); +>explicitVoid : Symbol(explicitVoid, Decl(thisTypeInFunctions.ts, 89, 3)) // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any ->unboundToSpecified : Symbol(unboundToSpecified, Decl(thisTypeInFunctions.ts, 107, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 25)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 107, 32)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 45)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 107, 68)) +>unboundToSpecified : Symbol(unboundToSpecified, Decl(thisTypeInFunctions.ts, 92, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 92, 25)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 92, 32)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 45)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 92, 68)) let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; ->specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 108, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 108, 27)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 108, 34)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 108, 45)) ->explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 32, 1)) +>specifiedToSpecified : Symbol(specifiedToSpecified, Decl(thisTypeInFunctions.ts, 93, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 93, 27)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 93, 34)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 93, 45)) +>explicitStructural : Symbol(explicitStructural, Decl(thisTypeInFunctions.ts, 27, 1)) let anyToSpecified: (this: { y: number }, x: number) => number = function(x: number): number { return x + 12; }; ->anyToSpecified : Symbol(anyToSpecified, Decl(thisTypeInFunctions.ts, 109, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 109, 21)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 109, 28)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 41)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 109, 74)) +>anyToSpecified : Symbol(anyToSpecified, Decl(thisTypeInFunctions.ts, 94, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 94, 21)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 94, 28)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 41)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 74)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 94, 74)) let unspecifiedLambda: (x: number) => number = x => x + 12; ->unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 111, 46)) +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 96, 3)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 46)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 96, 46)) let specifiedLambda: (this: void, x: number) => number = x => x + 12; ->specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 112, 22)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 33)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 112, 56)) +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 97, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 97, 22)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 33)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 56)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 97, 56)) let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; ->unspecifiedLambdaToSpecified : Symbol(unspecifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 113, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 113, 35)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 113, 42)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 113, 53)) ->unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 111, 3)) +>unspecifiedLambdaToSpecified : Symbol(unspecifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 98, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 98, 35)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 98, 42)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 98, 53)) +>unspecifiedLambda : Symbol(unspecifiedLambda, Decl(thisTypeInFunctions.ts, 96, 3)) let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; ->specifiedLambdaToSpecified : Symbol(specifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 114, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 114, 33)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 114, 40)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 114, 51)) ->specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 112, 3)) +>specifiedLambdaToSpecified : Symbol(specifiedLambdaToSpecified, Decl(thisTypeInFunctions.ts, 99, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 99, 33)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 99, 40)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 99, 51)) +>specifiedLambda : Symbol(specifiedLambda, Decl(thisTypeInFunctions.ts, 97, 3)) let explicitCFunction: (this: C, m: number) => number; ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 117, 24)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 102, 24)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 32)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 102, 32)) let explicitPropertyFunction: (this: {n: number}, m: number) => number; ->explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 118, 31)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 118, 38)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 49)) +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 103, 3)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 103, 31)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 103, 38)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 103, 49)) c.explicitC = explicitCFunction; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) c.explicitC = function(this: C, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 120, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 105, 23)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 120, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 105, 31)) c.explicitProperty = explicitPropertyFunction; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 118, 3)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>explicitPropertyFunction : Symbol(explicitPropertyFunction, Decl(thisTypeInFunctions.ts, 103, 3)) c.explicitProperty = function(this: {n: number}, m: number) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 122, 30)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 122, 35)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 122, 37)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 122, 48)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 107, 30)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 107, 35)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 107, 37)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 107, 48)) c.explicitProperty = reconstructed.explicitProperty; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 92, 42)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>reconstructed.explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) +>reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 74, 3)) +>explicitProperty : Symbol(explicitProperty, Decl(thisTypeInFunctions.ts, 77, 42)) // lambdas are assignable to anything c.explicitC = m => m; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 13)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 111, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 111, 13)) c.explicitThis = m => m; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 112, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 112, 16)) c.explicitProperty = m => m; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 20)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 113, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 113, 20)) // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 132, 13)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 117, 13)) c.explicitThis = m => m + this.n; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 133, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 118, 16)) c.explicitProperty = m => m + this.n; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 134, 20)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 119, 20)) //NOTE: this=C here, I guess? c.explicitThis = explicitCFunction; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 117, 3)) +>explicitCFunction : Symbol(explicitCFunction, Decl(thisTypeInFunctions.ts, 102, 3)) c.explicitThis = function(this: C, m: number) { return this.n + m }; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 26)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 123, 26)) >C : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 138, 34)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 123, 34)) // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 141, 23)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 14, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) ->this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 15, 26)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 15, 28)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 142, 30)) +>c.explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) +>this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) c.explicitThis = function(m) { return this.n + m }; >c.explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 143, 26)) - -c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) ->n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 144, 26)) - -c.implicitThis = reconstructed.implicitThis; ->c.implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->implicitThis : Symbol(C.implicitThis, Decl(thisTypeInFunctions.ts, 8, 5)) ->reconstructed.implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) ->reconstructed : Symbol(reconstructed, Decl(thisTypeInFunctions.ts, 88, 3)) ->implicitThis : Symbol(implicitThis, Decl(thisTypeInFunctions.ts, 90, 45)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) c.explicitC = function(this: B, m: number) { return this.n + m }; ->c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 11, 5)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 147, 23)) +>c.explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 130, 23)) >B : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) >this.n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) >this : Symbol(B, Decl(thisTypeInFunctions.ts, 0, 0)) >n : Symbol(B.n, Decl(thisTypeInFunctions.ts, 1, 9)) ->m : Symbol(m, Decl(thisTypeInFunctions.ts, 147, 31)) +>m : Symbol(m, Decl(thisTypeInFunctions.ts, 130, 31)) // this:void compatibility c.explicitVoid = n => n; ->c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->c : Symbol(c, Decl(thisTypeInFunctions.ts, 77, 3)) ->explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 17, 5)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 150, 16)) +>c.explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>c : Symbol(c, Decl(thisTypeInFunctions.ts, 65, 3)) +>explicitVoid : Symbol(C.explicitVoid, Decl(thisTypeInFunctions.ts, 14, 5)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 133, 16)) // class-based assignability class Base1 { ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) x: number; ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) - public implicit(): number { return this.x; } ->implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) + public polymorphic(this: this): number { return this.x; } +>polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 138, 23)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 156, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 153, 13)) - - static implicitStatic(): number { return this.y; } ->implicitStatic : Symbol(Base1.implicitStatic, Decl(thisTypeInFunctions.ts, 156, 52)) ->this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 139, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 136, 13)) static explicitStatic(this: typeof Base1): number { return this.y; } ->explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 157, 54)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 158, 26)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) +>explicitStatic : Symbol(Base1.explicitStatic, Decl(thisTypeInFunctions.ts, 139, 52)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 140, 26)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) static y: number; ->y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 158, 72)) - +>y : Symbol(Base1.y, Decl(thisTypeInFunctions.ts, 140, 72)) } class Derived1 extends Base1 { ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 162, 30)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 143, 30)) } class Base2 { ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) y: number ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) - implicit(): number { return this.y; } ->implicit : Symbol(implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) ->this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) ->y : Symbol(y, Decl(thisTypeInFunctions.ts, 165, 13)) + polymorphic(this: this): number { return this.y; } +>polymorphic : Symbol(polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 148, 16)) +>this.y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) +>this : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) +>y : Symbol(y, Decl(thisTypeInFunctions.ts, 146, 13)) explicit(this: Base1): number { return this.x; } ->explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 167, 41)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 13)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) ->this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) ->x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 153, 13)) +>explicit : Symbol(explicit, Decl(thisTypeInFunctions.ts, 148, 54)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 149, 13)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>this.x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) +>this : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) +>x : Symbol(Base1.x, Decl(thisTypeInFunctions.ts, 136, 13)) } class Derived2 extends Base2 { ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) x: number ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 170, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 151, 30)) } let b1 = new Base1(); ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 150, 24)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>Base1 : Symbol(Base1, Decl(thisTypeInFunctions.ts, 133, 24)) let b2 = new Base2(); ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) ->Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 164, 1)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) +>Base2 : Symbol(Base2, Decl(thisTypeInFunctions.ts, 145, 1)) let d1 = new Derived1(); ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 161, 1)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>Derived1 : Symbol(Derived1, Decl(thisTypeInFunctions.ts, 142, 1)) let d2 = new Derived2(); ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 169, 1)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>Derived2 : Symbol(Derived2, Decl(thisTypeInFunctions.ts, 150, 1)) -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) ->d1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->b2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 174, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +>d1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>b2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>b2 : Symbol(b2, Decl(thisTypeInFunctions.ts, 155, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 175, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>d1 : Symbol(d1, Decl(thisTypeInFunctions.ts, 156, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->implicit : Symbol(Base1.implicit, Decl(thisTypeInFunctions.ts, 154, 14)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>polymorphic : Symbol(Base1.polymorphic, Decl(thisTypeInFunctions.ts, 137, 14)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 173, 3)) ->explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 155, 48)) ->d2.implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) ->d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 176, 3)) ->implicit : Symbol(Base2.implicit, Decl(thisTypeInFunctions.ts, 166, 13)) +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>b1 : Symbol(b1, Decl(thisTypeInFunctions.ts, 154, 3)) +>explicit : Symbol(Base1.explicit, Decl(thisTypeInFunctions.ts, 138, 61)) +>d2.polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) +>d2 : Symbol(d2, Decl(thisTypeInFunctions.ts, 157, 3)) +>polymorphic : Symbol(Base2.polymorphic, Decl(thisTypeInFunctions.ts, 147, 13)) ////// use this-type for construction with new //// function InterfaceThis(this: I) { ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 187, 23)) ->I : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 168, 23)) +>I : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) this.a = 12; ->this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 22, 21)) ->a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 23, 13)) +>this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) +>this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) } function LiteralTypeThis(this: {x: string}) { ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 190, 25)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 171, 25)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) this.x = "ok"; ->this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 190, 30)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 190, 32)) +>this.x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) +>this : Symbol(, Decl(thisTypeInFunctions.ts, 171, 30)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 171, 32)) } function AnyThis(this: any) { ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 193, 17)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 174, 17)) this.x = "ok"; } let interfaceThis = new InterfaceThis(); ->interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 196, 3)) ->InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 184, 25)) +>interfaceThis : Symbol(interfaceThis, Decl(thisTypeInFunctions.ts, 177, 3)) +>InterfaceThis : Symbol(InterfaceThis, Decl(thisTypeInFunctions.ts, 165, 28)) let literalTypeThis = new LiteralTypeThis(); ->literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 197, 3)) ->LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 189, 1)) +>literalTypeThis : Symbol(literalTypeThis, Decl(thisTypeInFunctions.ts, 178, 3)) +>LiteralTypeThis : Symbol(LiteralTypeThis, Decl(thisTypeInFunctions.ts, 170, 1)) let anyThis = new AnyThis(); ->anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 198, 3)) ->AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 192, 1)) +>anyThis : Symbol(anyThis, Decl(thisTypeInFunctions.ts, 179, 3)) +>AnyThis : Symbol(AnyThis, Decl(thisTypeInFunctions.ts, 173, 1)) //// type parameter inference //// declare var f: { ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) (this: void, x: number): number, ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 202, 5)) ->x : Symbol(x, Decl(thisTypeInFunctions.ts, 202, 16)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 183, 5)) +>x : Symbol(x, Decl(thisTypeInFunctions.ts, 183, 16)) call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 203, 12)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 19)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) ->argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 203, 44)) ->U : Symbol(U, Decl(thisTypeInFunctions.ts, 203, 9)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 184, 12)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 19)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) +>argArray : Symbol(argArray, Decl(thisTypeInFunctions.ts, 184, 44)) +>U : Symbol(U, Decl(thisTypeInFunctions.ts, 184, 9)) }; let n: number = f.call(12); ->n : Symbol(n, Decl(thisTypeInFunctions.ts, 205, 3)) ->f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) ->f : Symbol(f, Decl(thisTypeInFunctions.ts, 201, 11)) ->call : Symbol(call, Decl(thisTypeInFunctions.ts, 202, 36)) +>n : Symbol(n, Decl(thisTypeInFunctions.ts, 186, 3)) +>f.call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) +>f : Symbol(f, Decl(thisTypeInFunctions.ts, 182, 11)) +>call : Symbol(call, Decl(thisTypeInFunctions.ts, 183, 36)) -function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 205, 27)) ->this : Symbol(this, Decl(thisTypeInFunctions.ts, 207, 34)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) ->a : Symbol(a, Decl(thisTypeInFunctions.ts, 207, 39)) +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } +>missingTypeIsImplicitAny : Symbol(missingTypeIsImplicitAny, Decl(thisTypeInFunctions.ts, 186, 27)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 188, 34)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) +>a : Symbol(a, Decl(thisTypeInFunctions.ts, 188, 39)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 3922e454c3f..48186eee2d0 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -22,17 +22,6 @@ class C { >this.n : number >this : this >n : number ->m : number - } - implicitThis(m: number): number { ->implicitThis : (this: this, m: number) => number ->m : number - - return this.n + m; ->this.n + m : number ->this.n : number ->this : this ->n : number >m : number } explicitC(this: C, m: number): number { @@ -103,12 +92,6 @@ interface I { explicitThis(this: this): number; >explicitThis : (this: this) => number >this : this - - implicitMethod(): number; ->implicitMethod : (this: this) => number - - implicitFunction: () => number; ->implicitFunction : (this: void) => number } function explicitStructural(this: { y: number }, x: number): number { >explicitStructural : (this: { y: number; }, x: number) => number @@ -134,16 +117,22 @@ function justThis(this: { y: number }): number { >y : number } function implicitThis(n: number): number { ->implicitThis : (this: void, n: number) => number +>implicitThis : (n: number) => number >n : number - return 12; + return this.m + n + 12; +>this.m + n + 12 : any +>this.m + n : any +>this.m : any +>this : any +>m : any +>n : number >12 : number } let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; }, implicitMethod() { return this.a; }, implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?)} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; implicitMethod(): number; implicitFunction: () => any; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; } a: 12, >a : number @@ -187,28 +176,13 @@ let impl: I = { >a : number }, - implicitMethod() { ->implicitMethod : () => number - - return this.a; ->this.a : number ->this : I ->a : number - - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) ->implicitFunction : () => any ->() => this.a : () => any ->this.a : any ->this : any ->a : any } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : (this: void) => number +>impl.explicitVoid1 = function () { return 12; } : () => number >impl.explicitVoid1 : (this: void) => number >impl : I >explicitVoid1 : (this: void) => number ->function () { return 12; } : (this: void) => number +>function () { return 12; } : () => number >12 : number impl.explicitVoid2 = () => 12; @@ -220,21 +194,21 @@ impl.explicitVoid2 = () => 12; >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : (this: void) => number +>impl.explicitStructural = function() { return this.a; } : () => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : (this: void) => number +>function() { return this.a; } : () => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : (this: void) => number +>impl.explicitInterface = function() { return this.a; } : () => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : (this: void) => number +>function() { return this.a; } : () => number >this.a : number >this : I >a : number @@ -256,43 +230,15 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : (this: void) => number +>impl.explicitThis = function () { return this.a; } : () => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : (this: void) => number +>function () { return this.a; } : () => number >this.a : number >this : I >a : number -impl.implicitMethod = function () { return this.a; }; ->impl.implicitMethod = function () { return this.a; } : (this: void) => number ->impl.implicitMethod : (this: I) => number ->impl : I ->implicitMethod : (this: I) => number ->function () { return this.a; } : (this: void) => number ->this.a : number ->this : I ->a : number - -impl.implicitMethod = () => 12; ->impl.implicitMethod = () => 12 : () => number ->impl.implicitMethod : (this: I) => number ->impl : I ->implicitMethod : (this: I) => number ->() => 12 : () => number ->12 : number - -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) ->impl.implicitFunction = () => this.a : () => any ->impl.implicitFunction : (this: void) => number ->impl : I ->implicitFunction : (this: void) => number ->() => this.a : () => any ->this.a : any ->this : any ->a : any - // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; >ok : { y: number; f: (this: { y: number; }, x: number) => number; } @@ -308,15 +254,15 @@ let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: >explicitStructural : (this: { y: number; }, x: number) => number let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; ->implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } >notSpecified : number ->f : (this: void, x: number) => number +>f : (x: number) => number >x : number ->{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (this: void, n: number) => number; } +>{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (n: number) => number; } >notSpecified : number >12 : number ->f : (this: void, n: number) => number ->implicitThis : (this: void, n: number) => number +>f : (n: number) => number +>implicitThis : (n: number) => number ok.f(13); >ok.f(13) : number @@ -327,14 +273,14 @@ ok.f(13); implicitThis(12); >implicitThis(12) : number ->implicitThis : (this: void, n: number) => number +>implicitThis : (n: number) => number >12 : number implicitAnyOk.f(12); >implicitAnyOk.f(12) : number ->implicitAnyOk.f : (this: void, x: number) => number ->implicitAnyOk : { notSpecified: number; f: (this: void, x: number) => number; } ->f : (this: void, x: number) => number +>implicitAnyOk.f : (x: number) => number +>implicitAnyOk : { notSpecified: number; f: (x: number) => number; } +>f : (x: number) => number >12 : number let c = new C(); @@ -374,13 +320,6 @@ c.explicitThis(12); >explicitThis : (this: C, m: number) => number >12 : number -c.implicitThis(12); ->c.implicitThis(12) : number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->12 : number - d.explicitC(12); >d.explicitC(12) : number >d.explicitC : (this: C, m: number) => number @@ -402,15 +341,8 @@ d.explicitThis(12); >explicitThis : (this: D, m: number) => number >12 : number -d.implicitThis(12); ->d.implicitThis(12) : number ->d.implicitThis : (this: D, m: number) => number ->d : D ->implicitThis : (this: D, m: number) => number ->12 : number - let reconstructed: { ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } n: number, >n : number @@ -419,10 +351,6 @@ let reconstructed: { >explicitThis : (this: C, m: number) => number >this : C >C : C ->m : number - - implicitThis(m: number): number, ->implicitThis : (m: number) => number >m : number explicitC(this: C, m: number): number, @@ -443,7 +371,7 @@ let reconstructed: { >m : number } = { ->{ n: 12, explicitThis: c.explicitThis, implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; implicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (this: void, m: number) => number; } +>{ n: 12, explicitThis: c.explicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid} : { n: number; explicitThis: (this: C, m: number) => number; explicitC: (this: C, m: number) => number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid: (this: void, m: number) => number; } n: 12, >n : number @@ -455,12 +383,6 @@ let reconstructed: { >c : C >explicitThis : (this: C, m: number) => number - implicitThis: c.implicitThis, ->implicitThis : (this: C, m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number - explicitC: c.explicitC, >explicitC : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number @@ -480,19 +402,30 @@ let reconstructed: { >explicitVoid : (this: void, m: number) => number }; +reconstructed.explicitThis(10); +>reconstructed.explicitThis(10) : number +>reconstructed.explicitThis : (this: C, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>explicitThis : (this: C, m: number) => number +>10 : number + reconstructed.explicitProperty(11); >reconstructed.explicitProperty(11) : number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number >11 : number -reconstructed.implicitThis(11); ->reconstructed.implicitThis(11) : number ->reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } ->implicitThis : (m: number) => number ->11 : number +let explicitVoid = reconstructed.explicitVoid; +>explicitVoid : (this: void, m: number) => number +>reconstructed.explicitVoid : (this: void, m: number) => number +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>explicitVoid : (this: void, m: number) => number + +explicitVoid(12); +>explicitVoid(12) : number +>explicitVoid : (this: void, m: number) => number +>12 : number // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any @@ -520,14 +453,14 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >this : { y: number; } >y : number >x : number ->function(x: number): number { return x + 12; } : (this: void, x: number) => number +>function(x: number): number { return x + 12; } : (x: number) => number >x : number >x + 12 : number >x : number >12 : number let unspecifiedLambda: (x: number) => number = x => x + 12; ->unspecifiedLambda : (this: void, x: number) => number +>unspecifiedLambda : (x: number) => number >x : number >x => x + 12 : (x: number) => number >x : number @@ -550,7 +483,7 @@ let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = uns >this : { y: number; } >y : number >x : number ->unspecifiedLambda : (this: void, x: number) => number +>unspecifiedLambda : (x: number) => number let specifiedLambdaToSpecified: (this: {y: number}, x: number) => number = specifiedLambda; >specifiedLambdaToSpecified : (this: { y: number; }, x: number) => number @@ -622,7 +555,7 @@ c.explicitProperty = reconstructed.explicitProperty; >c : C >explicitProperty : (this: { n: number; }, m: number) => number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } +>reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number // lambdas are assignable to anything @@ -719,11 +652,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitC = function(m) { return this.n + m } : (m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -732,11 +665,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -745,11 +678,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (this: void, m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number +>function(m) { return this.n + m } : (m: number) => number >m : number >this.n + m : number >this.n : number @@ -757,28 +690,6 @@ c.explicitThis = function(m) { return this.n + m }; >n : number >m : number -c.implicitThis = function(m) { return this.n + m }; ->c.implicitThis = function(m) { return this.n + m } : (this: void, m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (this: void, m: number) => number ->m : number ->this.n + m : number ->this.n : number ->this : C ->n : number ->m : number - -c.implicitThis = reconstructed.implicitThis; ->c.implicitThis = reconstructed.implicitThis : (m: number) => number ->c.implicitThis : (this: C, m: number) => number ->c : C ->implicitThis : (this: C, m: number) => number ->reconstructed.implicitThis : (m: number) => number ->reconstructed : { n: number; explicitThis(this: C, m: number): number; implicitThis(m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } ->implicitThis : (m: number) => number - c.explicitC = function(this: B, m: number) { return this.n + m }; >c.explicitC = function(this: B, m: number) { return this.n + m } : (this: B, m: number) => number >c.explicitC : (this: C, m: number) => number @@ -811,8 +722,9 @@ class Base1 { x: number; >x : number - public implicit(): number { return this.x; } ->implicit : (this: this) => number + public polymorphic(this: this): number { return this.x; } +>polymorphic : (this: this) => number +>this : this >this.x : number >this : this >x : number @@ -825,12 +737,6 @@ class Base1 { >this : Base1 >x : number - static implicitStatic(): number { return this.y; } ->implicitStatic : (this: typeof Base1) => number ->this.y : number ->this : typeof Base1 ->y : number - static explicitStatic(this: typeof Base1): number { return this.y; } >explicitStatic : (this: typeof Base1) => number >this : typeof Base1 @@ -841,7 +747,6 @@ class Base1 { static y: number; >y : number - } class Derived1 extends Base1 { >Derived1 : Derived1 @@ -856,8 +761,9 @@ class Base2 { y: number >y : number - implicit(): number { return this.y; } ->implicit : (this: this) => number + polymorphic(this: this): number { return this.y; } +>polymorphic : (this: this) => number +>this : this >this.y : number >this : this >y : number @@ -897,60 +803,60 @@ let d2 = new Derived2(); >new Derived2() : Derived2 >Derived2 : typeof Derived2 -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) ->d2.implicit = d1.implicit : (this: Derived1) => number ->d2.implicit : (this: Derived2) => number +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +>d2.polymorphic = d1.polymorphic : (this: Derived1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number ->d1.implicit : (this: Derived1) => number +>polymorphic : (this: Derived2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number +>polymorphic : (this: Derived1) => number -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) ->d1.implicit = d2.implicit : (this: Derived2) => number ->d1.implicit : (this: Derived1) => number +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } +>d1.polymorphic = d2.polymorphic : (this: Derived2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number ->d2.implicit : (this: Derived2) => number +>polymorphic : (this: Derived1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) ->d1.implicit = b2.implicit : (this: Base2) => number ->d1.implicit : (this: Derived1) => number +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +>d1.polymorphic = b2.polymorphic : (this: Base2) => number +>d1.polymorphic : (this: Derived1) => number >d1 : Derived1 ->implicit : (this: Derived1) => number ->b2.implicit : (this: Base2) => number +>polymorphic : (this: Derived1) => number +>b2.polymorphic : (this: Base2) => number >b2 : Base2 ->implicit : (this: Base2) => number +>polymorphic : (this: Base2) => number -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) ->d2.implicit = d1.explicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +>d2.polymorphic = d1.explicit : (this: Base1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number >d1.explicit : (this: Base1) => number >d1 : Derived1 >explicit : (this: Base1) => number -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.implicit = d2.implicit : (this: Derived2) => number ->b1.implicit : (this: Base1) => number +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.polymorphic = d2.polymorphic : (this: Derived2) => number +>b1.polymorphic : (this: Base1) => number >b1 : Base1 ->implicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +>polymorphic : (this: Base1) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) ->b1.explicit = d2.implicit : (this: Derived2) => number +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +>b1.explicit = d2.polymorphic : (this: Derived2) => number >b1.explicit : (this: Base1) => number >b1 : Base1 >explicit : (this: Base1) => number ->d2.implicit : (this: Derived2) => number +>d2.polymorphic : (this: Derived2) => number >d2 : Derived2 ->implicit : (this: Derived2) => number +>polymorphic : (this: Derived2) => number ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -1005,16 +911,16 @@ let anyThis = new AnyThis(); //// type parameter inference //// declare var f: { ->f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } +>f : { (this: void, x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } (this: void, x: number): number, >this : void >x : number call(this: (...argArray: any[]) => U, ...argArray: any[]): U; ->call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U >U : U ->this : (this: void, ...argArray: any[]) => U +>this : (...argArray: any[]) => U >argArray : any[] >U : U >argArray : any[] @@ -1024,14 +930,18 @@ declare var f: { let n: number = f.call(12); >n : number >f.call(12) : number ->f.call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U ->f : { (this: void, x: number): number; call(this: (this: void, ...argArray: any[]) => U, ...argArray: any[]): U; } ->call : (this: (this: void, ...argArray: any[]) => U, ...argArray: any[]) => U +>f.call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U +>f : { (this: void, x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } +>call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U >12 : number -function missingTypeIsImplicitAny(this, a: number) { return a; } ->missingTypeIsImplicitAny : (this: any, a: number) => number +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } +>missingTypeIsImplicitAny : (this: any, a: number) => any >this : any >a : number +>this.anything + a : any +>this.anything : any +>this : any +>anything : any >a : number diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index c48ea11b3b0..c888f4e5ecb 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -1,126 +1,103 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(16,15): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(44,21): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(55,49): error TS2339: Property 'a' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(58,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(60,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(70,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(39,21): error TS2339: Property 'a' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(49,1): error TS2345: Argument of type 'void' is not assignable to parameter of type '{ a: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(51,1): error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(56,21): error TS2339: Property 'notFound' does not exist on type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(59,21): error TS2339: Property 'notSpecified' does not exist on type 'void'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(61,79): error TS2322: Type '{ y: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,97): error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,97): error TS2322: Type '{ y: string; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2345: Argument of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. Types of property 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(84,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2345: Argument of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to parameter of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(87,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(88,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(89,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(90,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(91,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(92,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(93,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(94,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(95,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(96,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(97,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(101,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(75,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(79,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(86,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type '{ y: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(124,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(107,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. Property 'x' is missing in type 'C'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(108,1): error TS2322: Type '(this: { x: number; }, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type '{ n: number; }' is not assignable to type '{ x: number; }'. Property 'x' is missing in type '{ n: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(127,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(110,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(128,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(111,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(129,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(112,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(130,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(113,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(131,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(132,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'C' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(133,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(114,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type '{ n: number; }' is not assignable to type 'D'. Property 'x' is missing in type '{ n: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(134,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type '{ n: number; }' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(135,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(136,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(115,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(116,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(137,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(117,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(138,1): error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'void' is not assignable to type 'D'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,51): error TS2339: Property 'x' does not exist on type 'typeof Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(147,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(125,69): error TS2339: Property 'x' does not exist on type 'typeof Base1'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(145,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. Property 'y' is missing in type 'Base1'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(146,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. Types of parameters 'this' and 'this' are incompatible. Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. - Types of parameters 'this' and 'this' are incompatible. - Type 'Base1' is not assignable to type 'Base2'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(179,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(180,24): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(184,17): error TS2680: A constructor cannot have a 'this' parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,30): error TS2679: 'this' parameter must be the first parameter. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(187,61): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(190,57): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,20): error TS2370: A rest parameter must be of an array type. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,27): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(191,54): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,23): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(192,24): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,32): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(193,59): error TS2339: Property 'n' does not exist on type 'void'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,32): error TS1138: Parameter declaration expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,39): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,40): error TS1128: Declaration or statement expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,42): error TS2304: Cannot find name 'number'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(194,49): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,1): error TS7027: Unreachable code detected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,29): error TS2304: Cannot find name 'm'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,32): error TS1005: ';' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(148,1): error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(154,16): error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(158,17): error TS2680: A constructor cannot have a 'this' parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(161,30): error TS2679: 'this' parameter must be the first parameter. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,26): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,23): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,23): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(166,24): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,28): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(167,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,30): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,32): error TS1138: Parameter declaration expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,42): error TS2304: Cannot find name 'number'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,1): error TS7027: Unreachable code detected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,29): error TS2304: Cannot find name 'm'. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (76 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (63 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -149,9 +126,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -160,8 +134,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -176,12 +148,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' - ~ -!!! error TS2339: Property 'a' does not exist on type 'void'. } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' @@ -190,10 +156,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. - let implImplicitMethod = impl.implicitMethod; - implImplicitMethod(); // error, no 'a' in 'void' - ~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'void' is not assignable to parameter of type 'I'. function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -206,12 +168,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; ~~~~~~~~~~~~ -!!! error TS2339: Property 'notSpecified' does not exist on type 'void'. - } - function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; - ~~~~~~~~~~~~ !!! error TS2339: Property 'notSpecified' does not exist on type 'void'. } let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; @@ -285,8 +241,8 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. - let specifiedToImplicitVoid: (x: number) => number = explicitStructural; - ~~~~~~~~~~~~~~~~~~~~~~~ + let specifiedToVoid: (this: void, x: number) => number = explicitStructural; + ~~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type '{ y: number; }'. @@ -294,14 +250,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -325,11 +279,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Type '{ n: number; }' is not assignable to type '{ x: number; }'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. - c.explicitC = d.implicitD; - ~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitC = d.explicitD; ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. @@ -339,11 +288,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e ~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'C' is not assignable to type 'D'. - c.explicitThis = d.implicitD; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'C' is not assignable to type 'D'. c.explicitThis = d.explicitD; ~~~~~~~~~~~~~~ @@ -361,19 +305,9 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. !!! error TS2322: Property 'x' is missing in type '{ n: number; }'. - c.explicitProperty = d.implicitD; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: { n: number; }, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type '{ n: number; }' is not assignable to type 'D'. c.explicitThis = d.explicitThis; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: C, m: number) => number'. - c.explicitVoid = d.implicitD; - ~~~~~~~~~~~~~~ -!!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'void' is not assignable to type 'D'. c.explicitVoid = d.explicitD; ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: D, m: number) => number' is not assignable to type '(this: void, m: number) => number'. @@ -385,15 +319,12 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'void' is not assignable to type 'D'. - /// class-based implicit assignability (with inheritance!) /// + /// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } - ~ -!!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. static explicitStatic(this: typeof Base1): number { return this.x; } ~ !!! error TS2339: Property 'x' does not exist on type 'typeof Base1'. @@ -403,7 +334,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -416,37 +347,29 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e let b2 = new Base2(); let d2 = new Derived2(); - b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) - ~~~~~~~~~~~ + b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } + ~~~~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. !!! error TS2322: Property 'y' is missing in type 'Base1'. - b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. !!! error TS2322: Types of parameters 'this' and 'this' are incompatible. !!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. - d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) + d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ~~~~~~~~~~~ !!! error TS2322: Type '(this: Base2) => number' is not assignable to type '(this: Base1) => number'. -!!! error TS2322: Types of parameters 'this' and 'this' are incompatible. -!!! error TS2322: Type 'Base1' is not assignable to type 'Base2'. ////// use this-type for construction with new //// function VoidThis(this: void) { - } - function ImplicitVoidThis() { - } let voidThis = new VoidThis(); ~~~~~~~~~~~~~~ !!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. - let implicitVoidThis = new ImplicitVoidThis(); - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2678: A function that is called with the 'new' keyword cannot have a 'this' type that is void. ///// syntax-ish errors ///// class ThisConstructor { @@ -458,8 +381,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e function notFirst(a: number, this: C): number { return this.n; } ~~~~~~~ !!! error TS2679: 'this' parameter must be the first parameter. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. ///// parse errors ///// function modifiers(async this: C): number { return this.n; } @@ -467,8 +388,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function restParam(...this: C): number { return this.n; } ~~~~~~~ !!! error TS2370: A rest parameter must be of an array type. @@ -476,8 +395,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function optional(this?: C): number { return this.n; } ~ !!! error TS1005: ',' expected. @@ -488,8 +405,6 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(197,35): e !!! error TS1003: Identifier expected. ~ !!! error TS1005: ',' expected. - ~ -!!! error TS2339: Property 'n' does not exist on type 'void'. function initializer(this: C = new C()): number { return this.n; } ~ !!! error TS1005: ',' expected. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index c0892d9e4c8..8fa5aba6ad2 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -25,9 +25,6 @@ class D { explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -36,8 +33,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -50,17 +45,11 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -let implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -70,10 +59,6 @@ function propertyName(this: { y: number }, x: number): number { function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; } -function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; -} let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; @@ -99,19 +84,17 @@ c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -let specifiedToImplicitVoid: (x: number) => number = explicitStructural; +let specifiedToVoid: (this: void, x: number) => number = explicitStructural; let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -125,26 +108,21 @@ let explicitXProperty: (this: { x: number }, m: number) => number; c.explicitC = function(this: D, m: number) { return this.x + m }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } static explicitStatic(this: typeof Base1): number { return this.x; } } class Derived1 extends Base1 { @@ -152,7 +130,7 @@ class Derived1 extends Base1 { } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -165,20 +143,16 @@ let d1 = new Derived1(); let b2 = new Base2(); let d2 = new Derived2(); -b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } -d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis(this: void) { -} -function ImplicitVoidThis() { - } let voidThis = new VoidThis(); -let implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// class ThisConstructor { @@ -234,9 +208,6 @@ var D = (function () { D.prototype.explicitD = function (m) { return this.x + m; }; - D.prototype.implicitD = function (m) { - return this.x + m; - }; return D; }()); var impl = { @@ -249,18 +220,12 @@ var impl = { explicitInterface: function () { return 12; }, explicitThis: function () { return this.a; - }, - implicitMethod: function () { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' + } }; var implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' var implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -var implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(x) { return x + this.y; } @@ -270,10 +235,6 @@ function propertyName(x) { function voidThisSpecified(x) { return x + this.notSpecified; } -function noThisSpecified(x) { - // this:void unless loose-this is on - return x + this.notSpecified; -} var ok = { y: 12, explicitStructural: explicitStructural }; var wrongPropertyType = { y: 'foo', explicitStructural: explicitStructural }; var wrongPropertyName = { wrongName: 12, explicitStructural: explicitStructural }; @@ -296,11 +257,10 @@ c.explicitProperty(); // not enough arguments c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -var specifiedToImplicitVoid = explicitStructural; +var specifiedToVoid = explicitStructural; var reconstructed = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -312,25 +272,20 @@ var explicitXProperty; // from differing object types c.explicitC = function (m) { return this.x + m; }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// var Base1 = (function () { function Base1() { } - Base1.prototype.implicit = function () { return this.x; }; + Base1.prototype.polymorphic = function () { return this.x; }; Base1.prototype.explicit = function () { return this.x; }; - Base1.implicitStatic = function () { return this.x; }; Base1.explicitStatic = function () { return this.x; }; return Base1; }()); @@ -344,7 +299,7 @@ var Derived1 = (function (_super) { var Base2 = (function () { function Base2() { } - Base2.prototype.implicit = function () { return this.y; }; + Base2.prototype.polymorphic = function () { return this.y; }; Base2.prototype.explicit = function () { return this.x; }; return Base2; }()); @@ -359,16 +314,13 @@ var b1 = new Base1(); var d1 = new Derived1(); var b2 = new Base2(); var d2 = new Derived2(); -b1.implicit = b2.implicit; // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) -d1.explicit = b2.implicit; // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic; // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic; // error, 'y' not in Base1: { x } +d1.explicit = b2.polymorphic; // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis() { } -function ImplicitVoidThis() { -} var voidThis = new VoidThis(); -var implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// var ThisConstructor = (function () { function ThisConstructor(n) { diff --git a/tests/baselines/reference/unionThisTypeInFunctions.js b/tests/baselines/reference/unionThisTypeInFunctions.js index 31ff266087b..0d4b535ff8b 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.js +++ b/tests/baselines/reference/unionThisTypeInFunctions.js @@ -1,10 +1,10 @@ //// [unionThisTypeInFunctions.ts] interface Real { - method(n: number): void; + method(this: this, n: number): void; data: string; } interface Fake { - method(n: number): void; + method(this: this, n: number): void; data: number; } function test(r: Real | Fake) { diff --git a/tests/baselines/reference/unionThisTypeInFunctions.symbols b/tests/baselines/reference/unionThisTypeInFunctions.symbols index 8b5f2af01e0..d18fb3475bb 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.symbols +++ b/tests/baselines/reference/unionThisTypeInFunctions.symbols @@ -2,22 +2,24 @@ interface Real { >Real : Symbol(Real, Decl(unionThisTypeInFunctions.ts, 0, 0)) - method(n: number): void; + method(this: this, n: number): void; >method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 0, 16)) ->n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 11)) +>this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 1, 11)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 1, 22)) data: string; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 28)) +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 1, 40)) } interface Fake { >Fake : Symbol(Fake, Decl(unionThisTypeInFunctions.ts, 3, 1)) - method(n: number): void; + method(this: this, n: number): void; >method : Symbol(method, Decl(unionThisTypeInFunctions.ts, 4, 16)) ->n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 11)) +>this : Symbol(this, Decl(unionThisTypeInFunctions.ts, 5, 11)) +>n : Symbol(n, Decl(unionThisTypeInFunctions.ts, 5, 22)) data: number; ->data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 28)) +>data : Symbol(data, Decl(unionThisTypeInFunctions.ts, 5, 40)) } function test(r: Real | Fake) { >test : Symbol(test, Decl(unionThisTypeInFunctions.ts, 7, 1)) diff --git a/tests/baselines/reference/unionThisTypeInFunctions.types b/tests/baselines/reference/unionThisTypeInFunctions.types index f2c4f7ee4ec..3c5181166b6 100644 --- a/tests/baselines/reference/unionThisTypeInFunctions.types +++ b/tests/baselines/reference/unionThisTypeInFunctions.types @@ -2,8 +2,9 @@ interface Real { >Real : Real - method(n: number): void; + method(this: this, n: number): void; >method : (this: this, n: number) => void +>this : this >n : number data: string; @@ -12,15 +13,16 @@ interface Real { interface Fake { >Fake : Fake - method(n: number): void; + method(this: this, n: number): void; >method : (this: this, n: number) => void +>this : this >n : number data: number; >data : number } function test(r: Real | Fake) { ->test : (this: void, r: Real | Fake) => void +>test : (r: Real | Fake) => void >r : Real | Fake >Real : Real >Fake : Fake diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts index 3a1de178eea..80f5fce9a97 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true // body checking class B { n: number; @@ -8,9 +7,6 @@ class C { explicitThis(this: this, m: number): number { return this.n + m; } - implicitThis(m: number): number { - return this.n + m; - } explicitC(this: C, m: number): number { return this.n + m; } @@ -29,8 +25,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; - implicitMethod(): number; - implicitFunction: () => number; } function explicitStructural(this: { y: number }, x: number): number { return x + this.y; @@ -39,7 +33,7 @@ function justThis(this: { y: number }): number { return this.y; } function implicitThis(n: number): number { - return 12; + return this.m + n + 12; } let impl: I = { a: 12, @@ -54,10 +48,6 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; - }, - implicitFunction: () => this.a, // ok, this: any because it refers to some outer object (window?) } impl.explicitVoid1 = function () { return 12; }; impl.explicitVoid2 = () => 12; @@ -66,9 +56,6 @@ impl.explicitInterface = function() { return this.a; }; impl.explicitStructural = () => 12; impl.explicitInterface = () => 12; impl.explicitThis = function () { return this.a; }; -impl.implicitMethod = function () { return this.a; }; -impl.implicitMethod = () => 12; -impl.implicitFunction = () => this.a; // ok, this: any because it refers to some outer object (window?) // parameter checking let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: explicitStructural }; let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpecified: 12, f: implicitThis }; @@ -82,29 +69,26 @@ let ripped = c.explicitC; c.explicitC(12); c.explicitProperty(12); c.explicitThis(12); -c.implicitThis(12); d.explicitC(12); d.explicitProperty(12); d.explicitThis(12); -d.implicitThis(12); let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid }; +reconstructed.explicitThis(10); reconstructed.explicitProperty(11); -reconstructed.implicitThis(11); - +let explicitVoid = reconstructed.explicitVoid; +explicitVoid(12); // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any let specifiedToSpecified: (this: {y: number}, x: number) => number = explicitStructural; @@ -143,8 +127,6 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; c.explicitC = function(m) { return this.n + m }; c.explicitProperty = function(m) { return this.n + m }; c.explicitThis = function(m) { return this.n + m }; -c.implicitThis = function(m) { return this.n + m }; -c.implicitThis = reconstructed.implicitThis; c.explicitC = function(this: B, m: number) { return this.n + m }; @@ -154,19 +136,17 @@ c.explicitVoid = n => n; // class-based assignability class Base1 { x: number; - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.y; } static explicitStatic(this: typeof Base1): number { return this.y; } static y: number; - } class Derived1 extends Base1 { y: number } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -176,14 +156,14 @@ let b1 = new Base1(); let b2 = new Base2(); let d1 = new Derived1(); let d2 = new Derived2(); -d2.implicit = d1.implicit // ok, 'x' and 'y' in { x, y } (d assignable to f and vice versa) -d1.implicit = d2.implicit // ok, 'x' and 'y' in { x, y } (f assignable to d and vice versa) +d2.polymorphic = d1.polymorphic // ok, 'x' and 'y' in { x, y } +d1.polymorphic = d2.polymorphic // ok, 'x' and 'y' in { x, y } // bivariance-allowed cases -d1.implicit = b2.implicit // ok, 'y' in D: { x, y } (d assignable e) -d2.implicit = d1.explicit // ok, 'y' in { x, y } (c assignable to f) -b1.implicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) -b1.explicit = d2.implicit // ok, 'x' and 'y' not in C: { x } (c assignable to f) +d1.polymorphic = b2.polymorphic // ok, 'y' in D: { x, y } +d2.polymorphic = d1.explicit // ok, 'y' in { x, y } +b1.polymorphic = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } +b1.explicit = d2.polymorphic // ok, 'x' and 'y' not in Base1: { x } ////// use this-type for construction with new //// function InterfaceThis(this: I) { @@ -206,4 +186,4 @@ declare var f: { }; let n: number = f.call(12); -function missingTypeIsImplicitAny(this, a: number) { return a; } +function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts index bec0b9ab434..394b1867490 100644 --- a/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true class C { n: number; explicitThis(this: this, m: number): number { @@ -25,9 +24,6 @@ class D { explicitD(this: D, m: number): number { return this.x + m; } - implicitD(m: number): number { - return this.x + m; - } } interface I { a: number; @@ -36,8 +32,6 @@ interface I { explicitStructural(this: {a: number}): number; explicitInterface(this: I): number; explicitThis(this: this): number; // TODO: Allow `this` types for interfaces - implicitMethod(): number; - implicitFunction: () => number; } let impl: I = { a: 12, @@ -50,17 +44,11 @@ let impl: I = { explicitThis() { return this.a; }, - implicitMethod() { - return this.a; // ok, I.a: number - }, - implicitFunction: function () { return this.a; } // TODO: error 'a' not found in 'void' } let implExplicitStructural = impl.explicitStructural; implExplicitStructural(); // error, no 'a' in 'void' let implExplicitInterface = impl.explicitInterface; implExplicitInterface(); // error, no 'a' in 'void' -let implImplicitMethod = impl.implicitMethod; -implImplicitMethod(); // error, no 'a' in 'void' function explicitStructural(this: { y: number }, x: number): number { return x + this.y; } @@ -70,10 +58,6 @@ function propertyName(this: { y: number }, x: number): number { function voidThisSpecified(this: void, x: number): number { return x + this.notSpecified; } -function noThisSpecified(x: number): number { - // this:void unless loose-this is on - return x + this.notSpecified; -} let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, explicitStructural }; let wrongPropertyType: {y: string, f: (this: { y: number }, x: number) => number} = { y: 'foo', explicitStructural }; let wrongPropertyName: {wrongName: number, f: (this: { y: number }, x: number) => number} = { wrongName: 12, explicitStructural }; @@ -99,19 +83,17 @@ c.explicitProperty('wrong type 3'); c.explicitProperty(15, 'too many arguments 3'); // oops, this triggers contextual typing, which needs to be updated to understand that =>'s `this` is void. -let specifiedToImplicitVoid: (x: number) => number = explicitStructural; +let specifiedToVoid: (this: void, x: number) => number = explicitStructural; let reconstructed: { n: number, explicitThis(this: C, m: number): number, // note: this: this is not allowed in an object literal type. - implicitThis(m: number): number, explicitC(this: C, m: number): number, explicitProperty: (this: {n : number}, m: number) => number, explicitVoid(this: void, m: number): number, } = { n: 12, explicitThis: c.explicitThis, - implicitThis: c.implicitThis, // error not assignable -- c.this:c not assignable to this:void. explicitC: c.explicitC, explicitProperty: c.explicitProperty, explicitVoid: c.explicitVoid @@ -125,26 +107,21 @@ let explicitXProperty: (this: { x: number }, m: number) => number; c.explicitC = function(this: D, m: number) { return this.x + m }; c.explicitProperty = explicitXProperty; -c.explicitC = d.implicitD; c.explicitC = d.explicitD; c.explicitC = d.explicitThis; -c.explicitThis = d.implicitD; c.explicitThis = d.explicitD; c.explicitThis = d.explicitThis; c.explicitProperty = d.explicitD; -c.explicitProperty = d.implicitD; c.explicitThis = d.explicitThis; -c.explicitVoid = d.implicitD; c.explicitVoid = d.explicitD; c.explicitVoid = d.explicitThis; -/// class-based implicit assignability (with inheritance!) /// +/// class-based polymorphic assignability (with inheritance!) /// class Base1 { x: number - public implicit(): number { return this.x; } + public polymorphic(this: this): number { return this.x; } explicit(this: Base1): number { return this.x; } - static implicitStatic(): number { return this.x; } static explicitStatic(this: typeof Base1): number { return this.x; } } class Derived1 extends Base1 { @@ -152,7 +129,7 @@ class Derived1 extends Base1 { } class Base2 { y: number - implicit(): number { return this.y; } + polymorphic(this: this): number { return this.y; } explicit(this: Base1): number { return this.x; } } class Derived2 extends Base2 { @@ -165,20 +142,16 @@ let d1 = new Derived1(); let b2 = new Base2(); let d2 = new Derived2(); -b1.implicit = b2.implicit // error, 'this.y' not in C: { x } (c assignable to e) -b1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +b1.polymorphic = b2.polymorphic // error, 'this.y' not in Base1: { x } +b1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } -d1.explicit = b2.implicit // error, 'y' not in C: { x } (c assignable to e) +d1.explicit = b2.polymorphic // error, 'y' not in Base1: { x } ////// use this-type for construction with new //// function VoidThis(this: void) { -} -function ImplicitVoidThis() { - } let voidThis = new VoidThis(); -let implicitVoidThis = new ImplicitVoidThis(); ///// syntax-ish errors ///// class ThisConstructor { diff --git a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts index c0a55f138ce..4f74058cc48 100644 --- a/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts +++ b/tests/cases/conformance/types/thisType/unionThisTypeInFunctions.ts @@ -1,10 +1,9 @@ -// @strictThisChecks: true interface Real { - method(n: number): void; + method(this: this, n: number): void; data: string; } interface Fake { - method(n: number): void; + method(this: this, n: number): void; data: number; } function test(r: Real | Fake) { diff --git a/tests/cases/fourslash/memberListOnExplicitThis.ts b/tests/cases/fourslash/memberListOnExplicitThis.ts index 207ec8796fa..b776a7c0641 100644 --- a/tests/cases/fourslash/memberListOnExplicitThis.ts +++ b/tests/cases/fourslash/memberListOnExplicitThis.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true /// ////interface Restricted { @@ -7,10 +6,10 @@ ////class C1 implements Restricted { //// n: number; //// m: number; -//// f() {this./*1*/} // test on 'this.' +//// f(this: this) {this./*1*/} // test on 'this.' //// g(this: Restricted) {this./*2*/} ////} -////function f() {this./*3*/} +////function f(this: void) {this./*3*/} ////function g(this: Restricted) {this./*4*/} goTo.marker('1'); diff --git a/tests/cases/fourslash/quickInfoOnThis.ts b/tests/cases/fourslash/quickInfoOnThis.ts index bfed13ea89c..91083d41e6b 100644 --- a/tests/cases/fourslash/quickInfoOnThis.ts +++ b/tests/cases/fourslash/quickInfoOnThis.ts @@ -1,4 +1,3 @@ -// @strictThisChecks: true /// ////interface Restricted { //// n: number; @@ -6,9 +5,9 @@ ////function wrapper(wrapped: { (): void; }) { } ////class Foo { //// n: number; -//// public implicitThis() { +//// public explicitThis(this: this) { //// wrapper( -//// function implicitVoid() { +//// function explicitVoid(this: void) { //// console.log(th/*1*/is); //// } //// ) @@ -22,15 +21,15 @@ //// } ////} ////class Bar { -//// public implicitThis() { +//// public explicitThis(this: this) { //// console.log(th/*7*/is); //// } -//// public explicitThis(this: Bar) { +//// public explicitClass(this: Bar) { //// console.log(thi/*8*/s); //// } ////} //// -////function implicitVoid(x: number): void { +////function implicitAny(x: number): void { //// return th/*9*/is; ////} ////function explicitVoid(th/*10*/is: void, x: number): void { @@ -75,7 +74,7 @@ verify.quickInfoIs('this: this'); goTo.marker('8'); verify.quickInfoIs('this: Bar'); goTo.marker('9'); -verify.quickInfoIs('void'); +verify.quickInfoIs('any'); goTo.marker('10'); verify.quickInfoIs('(parameter) this: void'); goTo.marker('11');