What type of value is returned by setTimeout in ts, isn't it Timer?

let timeoutId: Timer = setTimeout(() => {
    console.log("ok");
}, 250);

vscode prompts that there is no Timer type, but if I replace Timer with number, he prompts me that the Timer type returned by setTimeout cannot be assigned to the number type

in the tsconfig of the root directory of the ant component, there is an attribute: "

"
lib": [
    "dom",
    "es7"
]

what are these two for? do they have anything to do with the questions I asked? For beginners of ts, please give me a lot of advice

< hr >

clipboard.png


delete @ types/node dependency
if not, use window.setTimeout


clipboard.png
should be number type


is number type, but your setTimeout and setInterval should be called with window.setTimeout and window.setInterval, you can use


var timeoutID = window.setTimeout (func, delay, [param1, param2,.]);

returns an ID, that is a positive integer.

window.setTimeout

Menu