TSConfig
noImplicitThis
Raise error on ‘this’ expressions with an implied ‘any’ type.
For example, the class below returns a function which tries to access this.width
and this.height
– but the context
for this
inside the function inside getAreaFunction
is not the instance of the Rectangle.
tsTry
classRectangle {width : number;height : number;constructor(width : number,height : number) {this.width =width ;this.height =height ;}getAreaFunction () {return function () {return'this' implicitly has type 'any' because it does not have a type annotation.'this' implicitly has type 'any' because it does not have a type annotation.2683this .width *this .height ;
2683'this' implicitly has type 'any' because it does not have a type annotation.'this' implicitly has type 'any' because it does not have a type annotation.};}}