From bb2bd7459ec6eb38c8f019f96ce9340249d73ff2 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Tue, 19 Mar 2019 13:26:00 +1300 Subject: [PATCH] Support timeout typings on workers/jobs: - index.d.ts: QueueWorker typing expanded to include new supported timeout property. - index.test-d.ts: Test added for new typing support. --- index.d.ts | 5 +++++ index.test-d.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/index.d.ts b/index.d.ts index 7c6b49d..560d652 100644 --- a/index.d.ts +++ b/index.d.ts @@ -161,6 +161,11 @@ export default Queue; export interface QueueWorker { (callback?: QueueWorkerCallback): void; + + /** + * Override queue timeout. + */ + timeout?: number; } export interface QueueWorkerCallback { diff --git a/index.test-d.ts b/index.test-d.ts index b15d04b..f777f12 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -10,6 +10,11 @@ expectType({ results: [0, 'a', true, undefined, NaN] }); expectType(() => undefined); expectType((callback: QueueWorkerCallback) => undefined); +function withTimeout() { } +withTimeout.timeout = 1; + +expectType(withTimeout); + expectType(() => undefined); expectType((data: Error) => undefined); expectType((error: Error) => undefined);