From aa7e5e32b1566ce4a3b399064f74206204af72dd Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 12 Aug 2020 23:05:49 +0200 Subject: [PATCH] add typings for createEventDispatcher (#5260) --- src/runtime/internal/lifecycle.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/internal/lifecycle.ts b/src/runtime/internal/lifecycle.ts index 34d52672a2..304e8d6a68 100644 --- a/src/runtime/internal/lifecycle.ts +++ b/src/runtime/internal/lifecycle.ts @@ -27,7 +27,9 @@ export function onDestroy(fn) { get_current_component().$$.on_destroy.push(fn); } -export function createEventDispatcher() { +export function createEventDispatcher< + EventMap extends {} = any +>(): >(type: EventKey, detail?: EventMap[EventKey]) => void { const component = get_current_component(); return (type: string, detail?: any) => { @@ -61,4 +63,4 @@ export function bubble(component, event) { if (callbacks) { callbacks.slice().forEach(fn => fn(event)); } -} \ No newline at end of file +}