Closed
Description
TypeScript Version: 3.4.5
Search Terms: setTimeout
Code
const timeout: number = setTimeout(() => console.log('anything'), 300);
Expected behavior:
It compiles correctly
Actual behavior:
Type 'Timeout' is not assignable to type 'number'.
1 const timeout: number = setTimeout(() => console.log('anything'), 300);
~~~~~~~
Found 1 error.
Playground Link:
Not reproducable in playground
Related Issues:
Possibly #19635, but this issue seems to be outdated because now the declaration of setTimeout looks like:
type TimerHandler = string | Function;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;