Re:SetBigTimeout
by wging on Friday October 18, 2024 @02:27PM
(#41882110)
In nodejs you at least get a warning along with the problematic behavior:
I'm surprised to see that setTimeout returns an object - I assume at one point it was an integer identifying the timer, the same way it is on the web. (I think I remember it being so at one point.)
[ Parent
| on HN ]
Re:SetBigTimeout
by augusto-moura on Friday October 18, 2024 @02:47PM
(#41882311)
It returns an object for a long time now, I might say it was always like this actually. Don't know about very old versions
Re:SetBigTimeout
by dgoldstein0 on Friday October 18, 2024 @07:04PM
(#41884284)
It's return your differs between node and in a browser. If you want to type a variable to hold the return value in typescript and share that across node (eg jest tests where you might include @types/node) and the browser you need ReturnType<typeof setTimeout>, otherwise the code won't typecheck in all cases. Similar with setInterval.