Skip to content

Commit

Permalink
add typings for createEventDispatcher (#5260)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Aug 12, 2020
1 parent 6ebe7f8 commit aa7e5e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime/internal/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -61,4 +63,4 @@ export function bubble(component, event) {
if (callbacks) {
callbacks.slice().forEach(fn => fn(event));
}
}
}

0 comments on commit aa7e5e3

Please sign in to comment.