@@ -28,9 +28,9 @@ export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =
2828 readonly clearInterval : ( intervalId : TTimerId | undefined ) => void
2929 }
3030
31- export const defaultTimeoutProvider : TimeoutProvider <
32- ReturnType < typeof setTimeout >
33- > = {
31+ type SystemTimerId = ReturnType < typeof setTimeout >
32+
33+ export const defaultTimeoutProvider : TimeoutProvider = {
3434 // We need the wrapper function syntax below instead of direct references to
3535 // global setTimeout etc.
3636 //
@@ -42,10 +42,12 @@ export const defaultTimeoutProvider: TimeoutProvider<
4242 // have a hard reference to the original implementation at the time when this
4343 // file was imported.
4444 setTimeout : ( callback , delay ) => setTimeout ( callback , delay ) ,
45- clearTimeout : ( timeoutId ) => clearTimeout ( timeoutId ) ,
45+ clearTimeout : ( timeoutId ) =>
46+ clearTimeout ( timeoutId as SystemTimerId | undefined ) ,
4647
4748 setInterval : ( callback , delay ) => setInterval ( callback , delay ) ,
48- clearInterval : ( intervalId ) => clearInterval ( intervalId ) ,
49+ clearInterval : ( intervalId ) =>
50+ clearInterval ( intervalId as SystemTimerId | undefined ) ,
4951}
5052
5153/**
@@ -62,7 +64,8 @@ export const defaultTimeoutProvider: TimeoutProvider<
6264export class TimeoutManager implements Omit < TimeoutProvider , 'name' > {
6365 // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
6466 // type at app boot; and if we leave that type, then any new timer provider
65- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
67+ // would need to support the default provider's concrete timer ID, which is
68+ // infeasible across environments.
6669 //
6770 // We settle for type safety for the TimeoutProvider type, and accept that
6871 // this class is unsafe internally to allow for extension.
0 commit comments