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
3.01k stars 78 forks source link

[discussion] type definition of `jobs` attribute of `Bree.BreeOptions` seems incorrect (or not working as expected) #165

Closed ksze closed 2 years ago

ksze commented 2 years ago

What would you like to discuss?

In the examples, the jobs array can take objects that are simply like this:

{
  name: 'my_awesome_job',
}

And Bree would look for the my_awesome_job.js or my_awesome_job.ts file under the jobs root folder.

However, when I try to use that convention, TypeScript tells me that the path, interval, and timeout are also required, contrary to the examples.

I'm using TypeScript 4.6.2 and Bree 8.0.1

Here is a screenshot from VS Code: image

Checklist

ksze commented 2 years ago

I suspect that this needs to be changed:

type BreeOptions = Partial<BreeConfigs> & {
  jobs?: Array<string | (() => void) | JobOptions>;
};

It needs to become this:

type BreeOptions = Partial<Omit<BreeConfigs, "jobs">> & {
  jobs?: Array<string | (() => void) | JobOptions>;
};
shadowgate15 commented 2 years ago

Fixed! Update to v8.0.2.