Skip to content

Commit

Permalink
fix: setTimeout and friends have too strict types (denoland#5412)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Gałkowski committed May 15, 2020
1 parent ce57a18 commit 8440d76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions cli/js/lib.deno.shared_globals.d.ts
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion cli/js/web/timers.ts
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions std/node/timers.ts
Expand Up @@ -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;

0 comments on commit 8440d76

Please sign in to comment.