Closed
Description
Given a class
class Foo {
private baz: string;
public bar() {
var x = this;
console.log(x.baz);
}
}
The compiler infers 'this' to be of type 'Foo' within the 'bar' function. However, the type of 'this' is not guaranteed to be 'Foo'.
Consider
var y = new Foo();
setTimeout(y.bar, 1000);
Given this possibility, should the type of 'this' within 'bar' be 'any' instead of 'Foo'?