-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Labels
bugSomething isn't working correctlySomething isn't working correctlygood first issueGood for newcomersGood for newcomerstypesIssues related to TypeScript typesIssues related to TypeScript types
Description
In lib.deno.shared_globals.d.ts
, setTimeout
is typed as below, and doesn't accept string
as callback.
declare function setTimeout(
/** callback function to execute when timer expires */
cb: (...args: any[]) => void,
/** delay in ms */
delay?: number,
/** arguments passed to callback function */
...args: any[]
): number;
On the other hand, in lib.dom.d.ts
, setTimeout is typed as:
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
where TimerHandler
is string | Function
.
In Deno's setTimeout
implementation, string
callback seems explicitly supported:
Lines 47 to 51 in fece050
// If callback is a string, replace it with a function that evals the string on every timeout | |
if (typeof callback !== "function") { | |
const unboundCallback = webidl.converters.DOMString(callback); | |
callback = () => indirectEval(unboundCallback); | |
} |
Is this discrepancy of setTimeout
typing between lib.deno
and lib.dom
intentional?
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctlygood first issueGood for newcomersGood for newcomerstypesIssues related to TypeScript typesIssues related to TypeScript types