From 791d105ad0c5b46490de365a4a6f7fe15678c4ed Mon Sep 17 00:00:00 2001 From: Brian Bugh Date: Thu, 29 Nov 2018 08:30:45 -0600 Subject: [PATCH] Fix implicit any type for Scheduler.next()/remove() Scheduler takes a type, but its internal representation of the object tracker was set to `any` instead of `T`. This resulted in `next()` returning `any`, which lost typing and required unnecessary casting when it is called.. This also creates an error, as `next()` can also return null, which is not enforced by the type checker. Lastly, `remove()` item was `any`, rather than `T`, so you lost the type checking for calling it. This fixes `next()` and `remove()` to use the expected `T` so that the type checker catches all of these issues with all of the schedulers. --- src/scheduler/scheduler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scheduler/scheduler.ts b/src/scheduler/scheduler.ts index 20167987..b5fddfaa 100644 --- a/src/scheduler/scheduler.ts +++ b/src/scheduler/scheduler.ts @@ -3,7 +3,7 @@ import EventQueue from "../eventqueue.js"; export default class Scheduler { _queue: EventQueue; _repeat: T[]; - _current: any; + _current: T | null; /** * @class Abstract scheduler @@ -52,7 +52,7 @@ export default class Scheduler { * @param {?} item * @returns {bool} successful? */ - remove(item: any) { + remove(item: T) { let result = this._queue.remove(item); let index = this._repeat.indexOf(item);