fix: setTimeout and friends have too strict types (#5412)

This commit is contained in:
Tomasz Gałkowski 2020-05-15 15:51:49 +02:00 committed by GitHub
parent ce57a1824d
commit 8440d765d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View file

@ -176,16 +176,16 @@ declare namespace WebAssembly {
/** Sets a timer which executes a function once after the timer expires. */
declare function setTimeout(
cb: (...args: unknown[]) => void,
cb: (...args: any[]) => void,
delay?: number,
...args: unknown[]
...args: any[]
): number;
/** Repeatedly calls a function , with a fixed time delay between each call. */
declare function setInterval(
cb: (...args: unknown[]) => void,
cb: (...args: any[]) => void,
delay?: number,
...args: unknown[]
...args: any[]
): number;
declare function clearTimeout(id?: number): void;
declare function clearInterval(id?: number): void;

View file

@ -179,7 +179,8 @@ function fire(timer: Timer): void {
callback();
}
export type Args = unknown[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type Args = any[];
function checkThis(thisArg: unknown): void {
if (thisArg !== null && thisArg !== undefined && thisArg !== globalThis) {

View file

@ -5,7 +5,9 @@ export const clearTimeout = window.clearTimeout;
export const setInterval = window.setInterval;
export const clearInterval = window.clearInterval;
export const setImmediate = (
cb: (...args: unknown[]) => void,
...args: unknown[]
// eslint-disable-next-line @typescript-eslint/no-explicit-any
cb: (...args: any[]) => void,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...args: any[]
): number => window.setTimeout(cb, 0, ...args);
export const clearImmediate = window.clearTimeout;