Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CronRepeatOptions.repeat is wrongly enforcing declaration of the 'key' property in TS #2642

Closed
reinert opened this issue Aug 8, 2023 · 5 comments · Fixed by #2644
Closed
Labels

Comments

@reinert
Copy link

reinert commented Aug 8, 2023

Description

The 4.11 release, specifically the (e4e6457) commit, introduced a requirement in the repeat property of the CronRepeatOptions TS type to set a readonly key property. This is requiring us to declare the key property to add scheduled jobs. For example, if we try to add a job with the opts { repeat: { cron: "* * * * *" } } the TS compiler will fail with the following message:

error TS2322: Type '{ cron: string; }' is not assignable to type '((CronRepeatOptions | EveryRepeatOptions) & { readonly key: string; }) | undefined'.
  Type '{ cron: string; }' is not assignable to type 'CronRepeatOptions & { readonly key: string; }'.
     Property 'key' is missing in type '{ cron: string; }' but required in type '{ readonly key: string; }'.

According to the documentation this property is not set by the user, but by Bull. So this type declaration should be modified to conform with the documentation.

Minimal, Working Test code to reproduce the issue.

Try sending a scheduled job without the key property in TS and the compilation error will appear.

Bull version

4.11

Additional information

Introduced by this commit:

types: add missing keys to repeat opts (e4e6457)

@Addono
Copy link

Addono commented Aug 9, 2023

From what I gather, the key is simply generated here:

const repeatKey = getRepeatKey(name, repeat, jobId);

Before it's set on the scheduled job:

key: repeatKey

So my guess is that the type is correct as a return value, but not for input 🤷 At least, tracing the opts from scheduling a job with repeatable configuration leads me to the lines above, where the key isn't ever actually used.

@PrinceGuidon
Copy link

Got the same issue. Is a fix expected soon?

@KyleBrown-804
Copy link

Running into the same issue

@manast
Copy link
Member

manast commented Aug 11, 2023

Let me know if the fix solves the issue.

@manast
Copy link
Member

manast commented Aug 11, 2023

🎉 This issue has been resolved in version 4.11.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants