Open vanminhquangtri opened 1 year ago
You just need to define the typings for your Event
emitter:
// events.ts
import mitt
type Events = {
'component:display': { id?: string; value?: string }
}
export const emitter = mitt<Events>()
And in your main.ts
or wherever you are setting up nuxt it should infer $listen
with the function signatures from emitter.on
:
Hello,
I am using mitt 3.0.1 for my Nuxt app (nuxt 3.6.5). I use event-bus to emit/listen for the whole app:
File plugins/event-bus.ts
I am currently not able to declare event when I listen for event in my components. I have to use type "any" but this break out type safety rules.
I already tried assigned a sepecific type but it throw error:
It's now allowed to use flag @ts-ignore in my app so I don't know how to solve this now. I search on document but it seems no mention about this so I hope to receive any advice on this. Thank you so much.