The second argument of setTimeout is optional

This commit is contained in:
Alex Dima 2021-11-22 20:47:27 +01:00
parent d27ef51905
commit 187ccb8ec4
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9

View file

@ -263,7 +263,7 @@ export const originalGlobalValues = {
Date: globalThis.Date,
};
function setTimeout(scheduler: Scheduler, handler: TimerHandler, timeout: number): IDisposable {
function setTimeout(scheduler: Scheduler, handler: TimerHandler, timeout: number = 0): IDisposable {
if (typeof handler === 'string') {
throw new Error('String handler args should not be used and are not supported');
}
@ -324,7 +324,7 @@ function setInterval(scheduler: Scheduler, handler: TimerHandler, interval: numb
}
function overwriteGlobals(scheduler: Scheduler): IDisposable {
globalThis.setTimeout = ((handler: TimerHandler, timeout: number) => setTimeout(scheduler, handler, timeout)) as any;
globalThis.setTimeout = ((handler: TimerHandler, timeout?: number) => setTimeout(scheduler, handler, timeout)) as any;
globalThis.clearTimeout = (timeoutId: any) => {
if (typeof timeoutId === 'object' && timeoutId && 'dispose' in timeoutId) {
timeoutId.dispose();