Find the best solutions to your questions at Westonci.ca, the premier Q&A platform with a community of knowledgeable experts. Discover a wealth of knowledge from experts across different disciplines on our comprehensive Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

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`
});