Let me explain the scenario I am facing:
// Application.ts
import MicroEvent from 'microevent-github'
class Application {
// stuff...
something() {
// It is also saying "trigger" is undefined,
// but it IS defined, MicroEvent defined it.
this.trigger('foo')
}
}
// get the `bind`, `unbind`, and other methods from MicroEvent
MicroEvent.mixin(Application)
const app = new Application()
const handleFoo = () => console.log('foo')
// try to use them, get the squiggly errors saying
// `bind` doesn't exist on Application, etc.
application.bind('foo', handleFoo)
application.unbind('foo', handleFoo)
I have incorporated the MicroEvent
into my application, which introduces some new methods to the object. But now, I'm facing issues in VSCode as it claims that bind
and unbind
are not present on the Application instance... even though they are. How can I make TypeScript recognize this?
Adding the following code did not resolve the problem:
type Application = {
bind: (eventType: string, callback: () => void) => void
unbind: (eventType: string, callback: () => void) => void
trigger: (eventType: string) => void
}