From 558f5f4f451db5916a56041dbdb44d43180a1076 Mon Sep 17 00:00:00 2001 From: Dan Gamble Date: Thu, 28 Mar 2024 21:23:44 +0000 Subject: [PATCH] Correctly type `Job.dispatch` (#64) Using an example job like this: ```typescript export class TestJob extends Job { constructor (public readonly name: string) {super();} async handle () { console.log(`Hello, ${this.name}!`); } } ``` You'll get type safety --- packages/superflare/src/job.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/superflare/src/job.ts b/packages/superflare/src/job.ts index a8312bae..dca27068 100644 --- a/packages/superflare/src/job.ts +++ b/packages/superflare/src/job.ts @@ -29,13 +29,14 @@ export abstract class Job { /** * Dispatch the job with the given arguments. */ - static async dispatch( - this: new (...arg: any[]) => T, - ...args: any[] - ) { - const job = new this(...args); - return job.dispatch(...args); - } + static async dispatch( + this: new (...args: Args) => T, + ...args: Args + ) { + const job = new this(...args); + + return job.dispatch(...args); + } /** * Convert the constructor arguments to a payload that can be sent to the queue.