From e64a040d9f4ed75fa6267a8177fcb18427894118 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Sun, 20 Sep 2020 13:08:37 +0200 Subject: [PATCH] fix event typing You need to type it like CustomEvent<...> because when forwarding events it could also be MouseEvent or sth like that --- src/runtime/internal/Component.ts | 2 +- src/runtime/internal/dev.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index f6fc91d497..e249b9d566 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -224,7 +224,7 @@ export class SvelteComponent< this.$destroy = noop; } - $on>(type: K, callback: (e: CustomEvent) => void) { + $on>(type: K, callback: (e: Events[K]) => void) { const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = [])); callbacks.push(callback); diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index ee32fe5778..3569a68edb 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -103,7 +103,7 @@ export interface SvelteComponentDev< Slots extends Record = any > { $set(props?: Partial & Record): void; - $on>(type: K, callback: (e: CustomEvent) => void): () => void; + $on>(type: K, callback: (e: Events[K]) => void): () => void; $destroy(): void; [accessor: string]: any; }