breejs / bree

Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
https://jobscheduler.net
MIT License
2.96k stars 80 forks source link

fix(types): `BreeConfigs` properties as optional #216

Closed cursande closed 1 year ago

cursande commented 1 year ago

Hi 👋 great lib! I've recently started to integrate this into a TS project to manage some file upload scheduling.

One thing I have noticed is when declaring a value as type BreeConfigs, the behaviour and documentation do not seem to align with the property definitions. For instance why iserrorHandler optional while other properties with defaults are not? The BreeConfigs interface may not be the ideal place to change this, but looking at past changes it seemed the most sensible.

The default values are all declared within src/index.js, so by making these mandatory properties of BreeConfigs it will be incorrectly reported as a type error when these fields are omitted. Certainly I can ignore it or write workarounds, but without looking into the source code it wasn't clear to me what was or wasn't really optional.

Any thoughts? Apologies if I've missed something silly.

Also updates README with absent config vars, I just used the descriptions also from src/index.js.

Checklist

shadowgate15 commented 1 year ago

Thank you for making a PR. I think that you are looking for BreeOptions. That is the type used in the constructor. BreeConfigs is the type of the bree.configs property after bree is constructed.

cursande commented 1 year ago

Thank you for making a PR. I think that you are looking for BreeOptions. That is the type used in the constructor. BreeConfigs is the type of the bree.configs property after bree is constructed.

I got these mixed up, should have picked that up earlier. Thanks for the quick response! Will close