Skip to content

Commit

Permalink
chore: add stricter argument types to timeout and interval providers (#…
Browse files Browse the repository at this point in the history
…6847)

Co-authored-by: Christine Legge <clegge@gogle.com>
  • Loading branch information
leggechr and Christine Legge committed Mar 8, 2022
1 parent 35fe753 commit 22f340a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/internal/scheduler/intervalProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ interface IntervalProvider {
export const intervalProvider: IntervalProvider = {
// When accessing the delegate, use the variable rather than `this` so that
// the functions can be called without being bound to the provider.
setInterval(...args) {
const { delegate } = intervalProvider;
return (delegate?.setInterval || setInterval)(...args);
setInterval(handler: () => void, timeout?: number, ...args) {
const {delegate} = intervalProvider;
if (delegate?.setInterval) {
return delegate.setInterval(handler, timeout, ...args);
}
return setInterval(handler, timeout, ...args);
},
clearInterval(handle) {
const { delegate } = intervalProvider;
Expand Down
9 changes: 6 additions & 3 deletions src/internal/scheduler/timeoutProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ interface TimeoutProvider {
export const timeoutProvider: TimeoutProvider = {
// When accessing the delegate, use the variable rather than `this` so that
// the functions can be called without being bound to the provider.
setTimeout(...args) {
const { delegate } = timeoutProvider;
return (delegate?.setTimeout || setTimeout)(...args);
setTimeout(handler: () => void, timeout?: number, ...args) {
const {delegate} = timeoutProvider;
if (delegate?.setTimeout) {
return delegate.setTimeout(handler, timeout, ...args);
}
return setTimeout(handler, timeout, ...args);
},
clearTimeout(handle) {
const { delegate } = timeoutProvider;
Expand Down

0 comments on commit 22f340a

Please sign in to comment.