-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type 'number' is not assignable to type 'Timeout' #30128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You included the DOM typings in your |
Thanks @RyanCavanaugh. I guess I'll move on with |
For anyone else having this error what worked for me is adding in the tsconfig.js file:
|
The compiler is getting confused between |
…y explicitly specifying the global setInterval 'microsoft/TypeScript#30128'
This is because More docs on symbol.toPrimitive here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive . |
Typescript compiler gets confused between which setTimeout is being used. See microsoft/TypeScript#30128
Typescript compiler gets confused between which setTimeout is being used. See microsoft/TypeScript#30128
global.setTimeout worked in React: ^16.13.1. |
I'm on Angular and declared
Because // Global scrope (lib.dom.d.ts)
function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout
// WindowOrWorkerGlobalScope (lib.dom.d.ts)
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number; In my opinion NodeJS should change that. But anyway, I wonder how can TypeScript provide the correct types in this context. A DOM context. How to tell TypeScript that I'm on browser and not on NodeJS. As a workaround I could call Another use case: Have DOM (Browser) stuff on runtime but test in a NodeJS environment (Jest). Not sure if this really matter. But when working with type, this could be an issue. ... |
Could you folks please advice which types should I use in |
TypeScript Version: 3.3.3
Search Terms:
Code
My config:
Expected behavior:
No error. I have
@types/node
installed.Actual behavior:
Error.
Playground Link:
Related Issues:
#842
The text was updated successfully, but these errors were encountered: