import { get_current_component, createEventDispatcher } from 'svelte/internal'; export class EventHandler { private component: HTMLElement; private svelteDispatch: ( type: EventKey, detail?: any, ) => void; constructor() { this.component = get_current_component() as unknown as HTMLElement; this.svelteDispatch = createEventDispatcher(); } dispatch(name: string, detail: CustomEvent['detail']): void { this.svelteDispatch(name, detail); /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment */ this.component.dispatchEvent && this.component.dispatchEvent(new CustomEvent(name, { detail: detail })); } }