Closed
Description
TypeScript Version: (2.2.0-dev.20161128)
Code
tets.ts
class A {
options: any[]
addOptions(options: any[]) {
if (!this.options) {
this.options = [];
}
options.forEach(function (item) {
this.options.push(item);
}, this);
return this;
}
}
tsc --module commonjs --noImplicitThis --noEmit test.ts
Expected behavior:
compile with no error output
Actual behavior:
test.ts(8,13): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
As some built-in method of array can assign this, could it be inferred through the scopes?