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

Typescript typing issue with work and batchSize #401

Closed
nomocas opened this issue Jun 19, 2023 · 0 comments · Fixed by #402
Closed

Typescript typing issue with work and batchSize #401

nomocas opened this issue Jun 19, 2023 · 0 comments · Fixed by #402

Comments

@nomocas
Copy link
Contributor

nomocas commented Jun 19, 2023

Hello @timgit,

There is an issue with the typing when using boss.work with batchSize.

As the documentations say, and as the tests files show, when using batchSize in work options, we should provide a work handler that accept an array of jobs as argument.

But when doing this in TS, there is an error.

await boss.work(
    'myqueue',
    { batchSize: 3 },
    (jobs: Job<Foo>[]) => Promise.resolve() 
);
error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '(jobs: Job<Foo>[]) => Promise<void>' is not assignable to parameter of type 'WorkHandler<unknown>'.
      Types of parameters 'jobs' and 'job' are incompatible.
        Type 'Job<unknown>' is missing the following properties from type 'Job<Foo>[]': length, pop, push, concat, and 29 more.

The typing misses some overloads to handle this case.

I prepare a PR.

Cheers.

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

Successfully merging a pull request may close this issue.

1 participant