nestjs/schedule

Missing CronJob type generics in SchedulerRegistry.addCronJob

nerdstep opened this issue · 3 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The SchedulerRegistry.addCronJob method should implement the CronJob type generics:

addCronJob<T = null, C = null>(name: string, job: CronJob<T, C>): void;

Otherwise a type error occurs when the onComplete function is defined.

image

Minimum reproduction code

https://github.com/nestjs/schedule/blob/master/lib/scheduler.registry.ts#L50

Steps to reproduce

  1. Create a new instance of CronJob with an onComplete callback defined.
  2. Call schedulerRegistry.addCronJob with the job instance

Expected behavior

Expected not to receive a type error when onComplete callback is defined.

Package version

4.0.0

NestJS version

10.3.0

Node.js version

18.18.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Would you like to create a PR for this issue?

Hey @kamilmysliwiec yeah I can put in a PR for this, no problem.

Let's track this here #1538