[Edit]
+
0
-
0
TypeScript - setInterval() with common types for web browser and Node.js
1 2 3 4 5 6 7 8 9 10let handle: NodeJS.Timer | number | null = null; const scheduleInterval = (callback: () => void, delay: number): void => { if (handle) { clearInterval(handle); } handle = setInterval(callback, delay); }; scheduleInterval((): void => { /* ... */ }, 1000);