Skip to content

Commit

Permalink
Support timeout typings on workers/jobs:
Browse files Browse the repository at this point in the history
- index.d.ts: QueueWorker typing expanded to include new supported timeout property.
- index.test-d.ts: Test added for new typing support.
  • Loading branch information
Codex- committed Mar 19, 2019
1 parent 75e62bc commit bb2bd74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ export default Queue;

export interface QueueWorker {
(callback?: QueueWorkerCallback): void;

/**
* Override queue timeout.
*/
timeout?: number;
}

export interface QueueWorkerCallback {
Expand Down
5 changes: 5 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ expectType<Options>({ results: [0, 'a', true, undefined, NaN] });
expectType<QueueWorker>(() => undefined);
expectType<QueueWorker>((callback: QueueWorkerCallback) => undefined);

function withTimeout() { }
withTimeout.timeout = 1;

expectType<QueueWorker>(withTimeout);

expectType<QueueWorkerCallback>(() => undefined);
expectType<QueueWorkerCallback>((data: Error) => undefined);
expectType<QueueWorkerCallback>((error: Error) => undefined);
Expand Down

0 comments on commit bb2bd74

Please sign in to comment.