2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/thisInLambda.ts ===
|
|
|
|
class Foo {
|
|
|
|
>Foo : Foo
|
|
|
|
|
|
|
|
x = "hello";
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
bar() {
|
|
|
|
>bar : () => void
|
|
|
|
|
|
|
|
this.x; // 'this' is type 'Foo'
|
|
|
|
>this.x : string
|
|
|
|
>this : Foo
|
|
|
|
>x : string
|
|
|
|
|
|
|
|
var f = () => this.x; // 'this' should be type 'Foo' as well
|
|
|
|
>f : () => string
|
|
|
|
>() => this.x : () => string
|
|
|
|
>this.x : string
|
|
|
|
>this : Foo
|
|
|
|
>x : string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function myFn(a:any) { }
|
2014-08-28 21:52:44 +02:00
|
|
|
>myFn : (a: any) => void
|
2014-08-15 23:33:16 +02:00
|
|
|
>a : any
|
|
|
|
|
|
|
|
class myCls {
|
|
|
|
>myCls : myCls
|
|
|
|
|
|
|
|
constructor () {
|
|
|
|
myFn(() => {
|
2014-08-22 03:39:46 +02:00
|
|
|
>myFn(() => { myFn(() => { var x = this; }); }) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>myFn : (a: any) => void
|
2014-08-22 03:39:46 +02:00
|
|
|
>() => { myFn(() => { var x = this; }); } : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
myFn(() => {
|
2014-08-22 03:39:46 +02:00
|
|
|
>myFn(() => { var x = this; }) : void
|
2014-08-28 21:52:44 +02:00
|
|
|
>myFn : (a: any) => void
|
2014-08-22 03:39:46 +02:00
|
|
|
>() => { var x = this; } : () => void
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var x = this;
|
|
|
|
>x : myCls
|
|
|
|
>this : myCls
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|