add typings for createEventDispatcher (#5260)

pull/7738/head
Simon H 5 years ago committed by GitHub
parent 41dd18b8b9
commit 1226bdd771

@ -27,7 +27,9 @@ export function onDestroy(fn) {
get_current_component().$$.on_destroy.push(fn); get_current_component().$$.on_destroy.push(fn);
} }
export function createEventDispatcher() { export function createEventDispatcher<
EventMap extends {} = any
>(): <EventKey extends Extract<keyof EventMap, string>>(type: EventKey, detail?: EventMap[EventKey]) => void {
const component = get_current_component(); const component = get_current_component();
return (type: string, detail?: any) => { return (type: string, detail?: any) => {
@ -61,4 +63,4 @@ export function bubble(component, event) {
if (callbacks) { if (callbacks) {
callbacks.slice().forEach(fn => fn(event)); callbacks.slice().forEach(fn => fn(event));
} }
} }

Loading…
Cancel
Save