Merge pull request #7232 from Microsoft/invalid-this-emit-in-contextual-object
Invalid this emit in contextual object
This commit is contained in:
commit
7bbd899b62
5 changed files with 123 additions and 0 deletions
|
@ -10754,6 +10754,7 @@ namespace ts {
|
|||
|
||||
// The identityMapper object is used to indicate that function expressions are wildcards
|
||||
if (contextualMapper === identityMapper && isContextSensitive(node)) {
|
||||
checkNodeDeferred(node);
|
||||
return anyFunctionType;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
//// [invalidThisEmitInContextualObjectLiteral.ts]
|
||||
interface IDef {
|
||||
p1: (e:string) => void;
|
||||
p2: () => (n: number) => any;
|
||||
}
|
||||
|
||||
class TestController {
|
||||
public m(def: IDef) { }
|
||||
public p = this.m({
|
||||
p1: e => { },
|
||||
p2: () => { return vvvvvvvvv => this; },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//// [invalidThisEmitInContextualObjectLiteral.js]
|
||||
var TestController = (function () {
|
||||
function TestController() {
|
||||
var _this = this;
|
||||
this.p = this.m({
|
||||
p1: function (e) { },
|
||||
p2: function () { return function (vvvvvvvvv) { return _this; }; }
|
||||
});
|
||||
}
|
||||
TestController.prototype.m = function (def) { };
|
||||
return TestController;
|
||||
}());
|
|
@ -0,0 +1,39 @@
|
|||
=== tests/cases/compiler/invalidThisEmitInContextualObjectLiteral.ts ===
|
||||
interface IDef {
|
||||
>IDef : Symbol(IDef, Decl(invalidThisEmitInContextualObjectLiteral.ts, 0, 0))
|
||||
|
||||
p1: (e:string) => void;
|
||||
>p1 : Symbol(p1, Decl(invalidThisEmitInContextualObjectLiteral.ts, 0, 16))
|
||||
>e : Symbol(e, Decl(invalidThisEmitInContextualObjectLiteral.ts, 1, 6))
|
||||
|
||||
p2: () => (n: number) => any;
|
||||
>p2 : Symbol(p2, Decl(invalidThisEmitInContextualObjectLiteral.ts, 1, 24))
|
||||
>n : Symbol(n, Decl(invalidThisEmitInContextualObjectLiteral.ts, 2, 12))
|
||||
}
|
||||
|
||||
class TestController {
|
||||
>TestController : Symbol(TestController, Decl(invalidThisEmitInContextualObjectLiteral.ts, 3, 1))
|
||||
|
||||
public m(def: IDef) { }
|
||||
>m : Symbol(m, Decl(invalidThisEmitInContextualObjectLiteral.ts, 5, 22))
|
||||
>def : Symbol(def, Decl(invalidThisEmitInContextualObjectLiteral.ts, 6, 10))
|
||||
>IDef : Symbol(IDef, Decl(invalidThisEmitInContextualObjectLiteral.ts, 0, 0))
|
||||
|
||||
public p = this.m({
|
||||
>p : Symbol(p, Decl(invalidThisEmitInContextualObjectLiteral.ts, 6, 24))
|
||||
>this.m : Symbol(m, Decl(invalidThisEmitInContextualObjectLiteral.ts, 5, 22))
|
||||
>this : Symbol(TestController, Decl(invalidThisEmitInContextualObjectLiteral.ts, 3, 1))
|
||||
>m : Symbol(m, Decl(invalidThisEmitInContextualObjectLiteral.ts, 5, 22))
|
||||
|
||||
p1: e => { },
|
||||
>p1 : Symbol(p1, Decl(invalidThisEmitInContextualObjectLiteral.ts, 7, 20))
|
||||
>e : Symbol(e, Decl(invalidThisEmitInContextualObjectLiteral.ts, 8, 5))
|
||||
|
||||
p2: () => { return vvvvvvvvv => this; },
|
||||
>p2 : Symbol(p2, Decl(invalidThisEmitInContextualObjectLiteral.ts, 8, 15))
|
||||
>vvvvvvvvv : Symbol(vvvvvvvvv, Decl(invalidThisEmitInContextualObjectLiteral.ts, 9, 20))
|
||||
>this : Symbol(TestController, Decl(invalidThisEmitInContextualObjectLiteral.ts, 3, 1))
|
||||
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
=== tests/cases/compiler/invalidThisEmitInContextualObjectLiteral.ts ===
|
||||
interface IDef {
|
||||
>IDef : IDef
|
||||
|
||||
p1: (e:string) => void;
|
||||
>p1 : (e: string) => void
|
||||
>e : string
|
||||
|
||||
p2: () => (n: number) => any;
|
||||
>p2 : () => (n: number) => any
|
||||
>n : number
|
||||
}
|
||||
|
||||
class TestController {
|
||||
>TestController : TestController
|
||||
|
||||
public m(def: IDef) { }
|
||||
>m : (def: IDef) => void
|
||||
>def : IDef
|
||||
>IDef : IDef
|
||||
|
||||
public p = this.m({
|
||||
>p : void
|
||||
>this.m({ p1: e => { }, p2: () => { return vvvvvvvvv => this; }, }) : void
|
||||
>this.m : (def: IDef) => void
|
||||
>this : this
|
||||
>m : (def: IDef) => void
|
||||
>{ p1: e => { }, p2: () => { return vvvvvvvvv => this; }, } : { p1: (e: string) => void; p2: () => {}; }
|
||||
|
||||
p1: e => { },
|
||||
>p1 : (e: string) => void
|
||||
>e => { } : (e: string) => void
|
||||
>e : string
|
||||
|
||||
p2: () => { return vvvvvvvvv => this; },
|
||||
>p2 : () => {}
|
||||
>() => { return vvvvvvvvv => this; } : () => {}
|
||||
>vvvvvvvvv => this : (vvvvvvvvv: number) => this
|
||||
>vvvvvvvvv : number
|
||||
>this : this
|
||||
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
interface IDef {
|
||||
p1: (e:string) => void;
|
||||
p2: () => (n: number) => any;
|
||||
}
|
||||
|
||||
class TestController {
|
||||
public m(def: IDef) { }
|
||||
public p = this.m({
|
||||
p1: e => { },
|
||||
p2: () => { return vvvvvvvvv => this; },
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue