From b68f1696a419ff775e759b33611b79434d8cc2a7 Mon Sep 17 00:00:00 2001 From: Manuel Saelices Date: Tue, 24 Mar 2020 18:06:12 +0100 Subject: [PATCH] feat(runtime): better typing declarations in the patchEvent() feature --- packages/runtime/src/modules/events.ts | 2 +- packages/runtime/src/nodes.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/runtime/src/modules/events.ts b/packages/runtime/src/modules/events.ts index 96b24832..2f772d68 100644 --- a/packages/runtime/src/modules/events.ts +++ b/packages/runtime/src/modules/events.ts @@ -20,7 +20,7 @@ function addEventListener( el: INSVElement, event: string, handler: EventListener, - options?: EventListenerOptions + options: EventListenerOptions = {} ) { el.addEventListener(event, handler, options) } diff --git a/packages/runtime/src/nodes.ts b/packages/runtime/src/nodes.ts index f933de23..80753d06 100644 --- a/packages/runtime/src/nodes.ts +++ b/packages/runtime/src/nodes.ts @@ -50,7 +50,11 @@ export interface INSVElement extends INSVNode { meta: NSVViewMeta style: Style | string - addEventListener(event: string, handler: any, options?: any): void + addEventListener( + event: string, + handler: any, + options: AddEventListenerOptions + ): void removeEventListener(event: string, handler?: any): void @@ -138,7 +142,11 @@ export class NSVElement extends NSVNode implements INSVElement { return (this._meta = getViewMeta(this.tagName)) } - addEventListener(event: string, handler: any, options: any = {}) { + addEventListener( + event: string, + handler: any, + options: AddEventListenerOptions = {} + ) { const { capture, once } = options if (capture) { console.log('Bubble propagation is not supported')