2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/thisInInnerFunctions.ts ===
|
|
|
|
class Foo {
|
|
|
|
>Foo : Foo
|
|
|
|
|
|
|
|
x = "hello";
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
bar() {
|
|
|
|
>bar : () => void
|
|
|
|
|
|
|
|
function inner() {
|
|
|
|
>inner : () => void
|
|
|
|
|
|
|
|
this.y = "hi"; // 'this' should be not type to 'Foo' either
|
|
|
|
>this.y = "hi" : string
|
|
|
|
>this.y : any
|
|
|
|
>this : any
|
|
|
|
>y : any
|
|
|
|
|
|
|
|
var f = () => this.y; // 'this' should be not type to 'Foo' either
|
|
|
|
>f : () => any
|
|
|
|
>() => this.y : () => any
|
|
|
|
>this.y : any
|
|
|
|
>this : any
|
|
|
|
>y : any
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function test() {
|
2014-08-28 21:52:44 +02:00
|
|
|
>test : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var x = () => {
|
|
|
|
>x : () => void
|
2014-08-22 03:39:46 +02:00
|
|
|
>() => { (() => this)(); this; } : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
(() => this)();
|
|
|
|
>(() => this)() : any
|
|
|
|
>(() => this) : () => any
|
|
|
|
>() => this : () => any
|
|
|
|
>this : any
|
|
|
|
|
|
|
|
this;
|
|
|
|
>this : any
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|