add typings for createEventDispatcher (#5260)

pull/4602/head
Simon H 4 years ago committed by GitHub
parent 6ebe7f8210
commit aa7e5e32b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,7 +27,9 @@ export function onDestroy(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();
return (type: string, detail?: any) => {
@ -61,4 +63,4 @@ export function bubble(component, event) {
if (callbacks) {
callbacks.slice().forEach(fn => fn(event));
}
}
}

Loading…
Cancel
Save