diff --git a/packages/history/index.ts b/packages/history/index.ts index c8cdfc04..b63453d7 100644 --- a/packages/history/index.ts +++ b/packages/history/index.ts @@ -1015,13 +1015,15 @@ function promptBeforeUnload(event: BeforeUnloadEvent) { event.returnValue = ""; } -type Events = { +type EventHandler = (...args: any[]) => any; + +type Events = { length: number; push: (fn: F) => () => void; - call: (arg: any) => void; + call: (...arg: Parameters) => void; }; -function createEvents(): Events { +function createEvents(): Events { let handlers: F[] = []; return { @@ -1034,8 +1036,8 @@ function createEvents(): Events { handlers = handlers.filter((handler) => handler !== fn); }; }, - call(arg) { - handlers.forEach((fn) => fn && fn(arg)); + call(...arg) { + handlers.forEach((fn) => fn && fn(...arg)); }, }; }