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