From df0b8b4e18c9b6016c35bd3dc5c75730f6148a07 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 16 Oct 2020 16:00:44 +0200 Subject: [PATCH] Improved the code to avoid @ts-ignore --- .../install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js | 7 +++---- .../install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js index 6949054298..3562eac3b5 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js @@ -48,17 +48,16 @@ define(["require", "exports", "../Core"], function (require, exports, Core) { }, options || {}); const callbackName = 'wcf_jsonp_' + Core.getUuid().replace(/-/g, '').substr(0, 8); let script; - const timeout = window.setTimeout(function () { + const timeout = window.setTimeout(() => { if (typeof failure === 'function') { failure(); } window[callbackName] = undefined; script.parentNode.removeChild(script); }, (~~options.timeout || 10) * 1000); - window[callbackName] = function () { + window[callbackName] = (...args) => { window.clearTimeout(timeout); - //@ts-ignore - success.apply(null, arguments); + success.apply(null, args); window[callbackName] = undefined; script.parentNode.removeChild(script); }; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts index faae75626c..dbd34f60cf 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts @@ -31,20 +31,19 @@ export function send(url: string, success: (...args: unknown[]) => void, failure const callbackName = 'wcf_jsonp_' + Core.getUuid().replace(/-/g, '').substr(0, 8); let script; - const timeout = window.setTimeout(function () { + const timeout = window.setTimeout(() => { if (typeof failure === 'function') { failure(); } window[callbackName] = undefined; script.parentNode.removeChild(script); - }, (~~options.timeout || 10) * 1000); + }, (~~options.timeout || 10) * 1_000); - window[callbackName] = function () { + window[callbackName] = (...args: any[]) => { window.clearTimeout(timeout); - //@ts-ignore - success.apply(null, arguments); + success.apply(null, args); window[callbackName] = undefined; script.parentNode.removeChild(script); -- 2.20.1