diff --git a/src/dom/event/event.ts b/src/dom/event/event.ts index c572692..a854f1b 100644 --- a/src/dom/event/event.ts +++ b/src/dom/event/event.ts @@ -14,14 +14,17 @@ type DomEventSwitchOptionsBase = { context: unknown }> -export type DomEventSwitchOptionsUsesHandler = - | (DomEventSwitchOptionsBase & { - event: string - handler: EventHandlerAsync - }) - | (DomEventSwitchOptionsBase & { - handlers: EventHandlersAsync - }) +type DomEventSwitchOptionsHandlerSingle = { + event: string + handler: EventHandlerAsync +} + +type DomEventSwitchOptionsHandlerMultiple = { + handlers: EventHandlersAsync +} + +export type DomEventSwitchOptionsUsesHandler = DomEventSwitchOptionsBase & + (DomEventSwitchOptionsHandlerSingle | DomEventSwitchOptionsHandlerMultiple) type SwitchableStates = 'on' | 'off' export type DomEventSwitchOptions = @@ -46,7 +49,7 @@ function domEventSwitch( >options if ('event' in options && 'handler' in options) { - const { handler, event } = options + const { handler, event }: DomEventSwitchOptionsHandlerSingle = options return DomEvent[switchable]( element, event, @@ -54,7 +57,7 @@ function domEventSwitch( context, ) } else if ('handlers' in options) { - const { handlers } = options + const { handlers }: DomEventSwitchOptionsHandlerMultiple = options return DomEvent[switchable](element, handlers, context) } else if (switchable === 'off') return DomEvent.off(element)