Explore Westonci.ca, the premier Q&A site that helps you find precise answers to your questions, no matter the topic. Discover a wealth of knowledge from professionals across various disciplines on our user-friendly Q&A platform. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.

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