Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Comments

Fix define Processor typing#1368

Closed
agix wants to merge 1 commit intoagenda:mainfrom
agix:define_typing
Closed

Fix define Processor typing#1368
agix wants to merge 1 commit intoagenda:mainfrom
agix:define_typing

Conversation

@agix
Copy link

@agix agix commented Aug 5, 2021

Processor type used in define doesn't use generic typing.

If you try this:

import Agenda, { Job } from 'agenda'

const agenda = new Agenda()

const run = async function(job: Job<{test: string}>) {
  return Promise.resolve()
}

agenda.define('test', run)

It would raise the following typescript error :

Type '(job: Job<{ test: string; }>) => Promise<void>' is not assignable to type '(job: Job<JobAttributesData>) => Promise<void>'.

Job class use generic type but default to JobAttributesData if none is provided https://github.com/agix/agenda/blob/73184aaa8309e5e89e0cfab766b2cdd6d80e9605/lib/job/index.ts?plain=1#L127

Which is exactly the case in the current Processor definition : https://github.com/agenda/agenda/blob/master/lib/agenda/define.ts#L39-L41

@harisvsulaiman
Copy link
Member

@agix We can merge this after #1358 Where this is an explicit issue

@agix
Copy link
Author

agix commented Aug 5, 2021

Ok thank you.

@imsergiobernal
Copy link

JobAttributesData should not be generic typed because is an external resource subject to async manipulations. It should be unknown always.

@simllll
Copy link
Member

simllll commented Jan 23, 2026

We are actively working on Agenda 6.x which includes a complete TypeScript rewrite with many improvements. This issue is being closed as part of our migration. If this is still relevant after 6.x is released, please open a new issue. Thank you for your patience!

@simllll simllll closed this Jan 23, 2026
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 this pull request may close these issues.

4 participants