From 60a142e4830b920a96bd1e2538285eb47791aaad Mon Sep 17 00:00:00 2001 From: Allan Jardine <84905443+AllanJard@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:56:42 +0100 Subject: [PATCH] Fix - Typescript: `this` is now an HTMLElement in event handlers https://datatables.net/forums/discussion/77427 --- types/types.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/types.d.ts b/types/types.d.ts index 72b8cf08..8f1063e9 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -813,7 +813,7 @@ export interface Api { * @param callback Specific callback function to remove if you want to unbind a single event listener. * @returns DataTables Api instance */ - off(event: string, callback?: ((e: Event, ...args: any[]) => void)): Api; + off(event: string, callback?: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Remove event handlers from selected elements @@ -823,7 +823,7 @@ export interface Api { * @param callback Specific callback function to remove if you want to unbind a single event listener. * @returns DataTables Api instance */ - off(event: string, selector: string, callback?: ((e: Event, ...args: any[]) => void)): Api; + off(event: string, selector: string, callback?: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Table events listener. @@ -832,7 +832,7 @@ export interface Api { * @param callback Specific callback function to remove if you want to unbind a single event listener. * @returns DataTables Api instance */ - on(event: string, callback: ((e: Event, ...args: any[]) => void)): Api; + on(event: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Listen for events from selected elements @@ -842,7 +842,7 @@ export interface Api { * @param callback Event handler. * @returns DataTables Api instance */ - on(event: string, selector: string, callback: ((e: Event, ...args: any[]) => void)): Api; + on(event: string, selector: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Listen for a table event once and then remove the listener. @@ -852,7 +852,7 @@ export interface Api { * Listen for events from tables and fire a callback when they occur * @returns DataTables Api instance */ - one(event: string, callback: ((e: Event, ...args: any[]) => void)): Api; + one(event: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Listen for events from a selected element and trigger only once then remove the listener. @@ -862,7 +862,7 @@ export interface Api { * @param callback Event handler. * @returns DataTables Api instance */ - one(event: string, selector: string, callback: ((e: Event, ...args: any[]) => void)): Api; + one(event: string, selector: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api; /** * Page Methods / object