Skip to content

Commit aa7e5e3

Browse files
authored
add typings for createEventDispatcher (#5260)
1 parent 6ebe7f8 commit aa7e5e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/internal/lifecycle.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export function onDestroy(fn) {
2727
get_current_component().$$.on_destroy.push(fn);
2828
}
2929

30-
export function createEventDispatcher() {
30+
export function createEventDispatcher<
31+
EventMap extends {} = any
32+
>(): <EventKey extends Extract<keyof EventMap, string>>(type: EventKey, detail?: EventMap[EventKey]) => void {
3133
const component = get_current_component();
3234

3335
return (type: string, detail?: any) => {
@@ -61,4 +63,4 @@ export function bubble(component, event) {
6163
if (callbacks) {
6264
callbacks.slice().forEach(fn => fn(event));
6365
}
64-
}
66+
}

0 commit comments

Comments
 (0)