typescript this implicitly has type 'any'

Developer from somewhere

Problem: received this error in typescript: ‘this’ implicitly has type ‘any’ because it does not have a type annotation.

Solution:

foo.on('error', function(this: Foo, err: any) {