-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
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.tsExpected 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?
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this