-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.0.0 beta with "noImplicitThis": true
Code
interface String {
contains(this: string, str: string): boolean;
}
// OK
String.prototype.contains = function (this: string, str: string): boolean {
return this.indexOf(element) != -1;
};
//Error: 'this' implicitly has type 'any' because it does not have a type annotation.
String.prototype.contains = function (str: string) {
return this.indexOf(str) != -1;
};
// OK
String.prototype.contains = function (str): boolean {
return this.indexOf(str) != -1;
};
// OK
String.prototype.contains = function (str) {
return this.indexOf(str) != -1;
};Look like once you type some parameters you have to type all of them, including the this.
What's the reason?
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issue