Westonci.ca offers fast, accurate answers to your questions. Join our community and get the insights you need now. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

When I enable noImplicitThis in tsconfig.json, I get this error for the following code:

'this' implicitly has type 'any' because it does not have a type annotation.

class Foo implements EventEmitter {
on(name: string, fn: Function) { }
emit(name: string) { }
}

const foo = new Foo();
foo.on('error', function(err: any) {
console.log(err);
this.emit('end'); // error: `this` implicitly has type `any`
});