fix event typing

You need to type it like CustomEvent<...> because when forwarding events it could also be MouseEvent or sth like that
pull/5431/head
Simon Holthausen 5 years ago
parent 01b104b5f4
commit e64a040d9f

@ -224,7 +224,7 @@ export class SvelteComponent<
this.$destroy = noop;
}
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: CustomEvent<Events[K]>) => void) {
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void) {
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
callbacks.push(callback);

@ -103,7 +103,7 @@ export interface SvelteComponentDev<
Slots extends Record<string, any> = any
> {
$set(props?: Partial<Props> & Record<string, any>): void;
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: CustomEvent<Events[K]>) => void): () => void;
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void): () => void;
$destroy(): void;
[accessor: string]: any;
}

Loading…
Cancel
Save