From c62c3fea19da578f188d34ab4822c3c04cc9e9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sat, 18 Jan 2020 09:42:43 +0100 Subject: [PATCH] [FIX] types: improve type of useExternalListener so it can work on window closes #613 --- src/hooks.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks.ts b/src/hooks.ts index e7292a8a..6b06591a 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -149,7 +149,12 @@ export function useSubEnv(nextEnv) { * in the constructor of the OWL component that needs to be notified, * `useExternalListener(window, 'click', this._doSomething);` * */ -export function useExternalListener(target: HTMLElement, eventName: string, handler, eventParams?) { +export function useExternalListener( + target: HTMLElement | typeof window, + eventName: string, + handler, + eventParams? +) { const boundHandler = handler.bind(Component.current); onMounted(() => target.addEventListener(eventName, boundHandler, eventParams));