Closed
Description
TypeScript Version:
1.8.0 (through npm), 1.8.2 (visual studio)
Code
namespace Bug {
export interface IDef {
test2: () => any;
test: (e:any) => any;
}
class TestController {
protected from: number;
public prepareDefinition(def: IDef) {
return def;
}
public prepared = this.prepareDefinition({
test2: () => {
var q = this.from; // uses _this;
var helper = () => {
var q2 = this.from; // uses _this
};
return {
fn1: (v) => {
var q3 = this.from; //uses this
},
fn2: helper
}
},
test: (e) => { }
}
);
}
}
The code is compiled to ES5
Expected behavior:
All the 3 assignments (q, q2, q3) should compile to using _this
Actual behavior:
The q3 assignment refers to "this". The code above (with the exception of the helper(), which I kept for comparison) seems to be the minimal code to trigger the issue - even removing test() or its parameters (or parameter of fn1) results in what I believe is the correct code (using _this). The code also compiles correctly in 1.7.x