Solvedagenda typing issue
✔️Accepted Answer
I can confirm this works with node 14.16.0
and agenda 4.1.2
. Faced this issue today after updating from 4.1.0
to 4.1.2
.
import { Agenda } from 'agenda';
Other Answers:
As a temporary solution, this older version coupled with the deprecated typings seems to be working fine for me:
"agenda": "^3.1.0"
"@types/agenda": "^2.0.8"
const {Agenda} = require('agenda');
require agenda like this, and it works fine for me
I'll create a PR to show you what I mean. The problem with this approach would be furthermore that everyone who has changed their imports to { Agenda } will stop working again, and they would either need to require('agenda') again direclty:
I think the subsequent replies to this issue show that the longer this goes unpatched, the more painful it's going to be to go back to the old behaviour, because more people will have applied the fix that compensates for the behaviour change.
I don't have a particular preference and obviously the fix is easy, it's just unexpected when you have npm set to not take major version updates for the module. I have agenda in use across a bunch of projects and have pinned it back to 4.1.0 rather than make fixes to all those projects I think I might have to roll back.
I think it wouldn't be unreasonable to make a 4.1.3 that reverts to the old behaviour (even if it means losing typescript/import functionality), and immediately make a 5.0.0 that works the same way 4.1.2 does, but with the documentation fixed. That way users who blindly npm update
won't find their code breaks, anyone who updated to 4.1.1/4.1.2 can update to 4.1.3 to fix the break; anyone who has applied the fix already will have the choice of rolling back their fix to use 4.1.3, or taking the major version update if they prefer the new interface.
Hi,
I am trying out
agenda
but facing with types issue hence, unable to proceed. Could be related to #1218, and #1265The example usage of initializing
agenda
isconst agenda = new Agenda({ db: { address: mongoConnectionString } });
. However, the typing does not match what is in the docs.agenda/lib/agenda/index.ts
Lines 36 to 51 in adc22b8
The definition is as such, and since
db.collection
anddb.options
are not declared as optional (?), it will throw type error like suchThe 2nd issue is the constructor error
Using
agenda: 4.1.0
andtypescript: 4.1.5