"TS2322: Type 'Timeout' is not assignable to type 'number'" when running unit tests
Solution 1:
You could try with using window.setTimeout
instead of just setTimeout, this way the typescript one will be explicitly used
Solution 2:
You can use:
let timeoutId: null | ReturnType<typeof setTimeout> = null
...
timeoutId = setTimeout(...)
It'll pick correct declaration depending on your context.
I'm seeing this discrepency when using vscode/tsc (NodeJS.Timeout) and running ts-jest (number). This is the only way the whole thing typechecks on both sides.