taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
6.07k stars 396 forks source link

[Question]: Job TypeScript Typings #1808

Open dvins opened 1 year ago

dvins commented 1 year ago

Is your feature request related to a problem? Please describe. Could someone in the know add some commentary or color on the thoughts behind how Job's are typed in TypeScript, particularly the intent behind the string-only NameType?

Describe the solution you'd like Some additional design documentation and guidance on how we should properly model or use this typing.

Describe alternatives you've considered Looking for guidance more than anything. It sort of gnaws at me every time I see it and I'm not sure I'm leveraging it either for or against me in any way that it is intended it be used.

Additional context Love BullMQ, awesome framework!

manast commented 4 months ago

For instance, if you want to just define a subset of valid job names, you could create a type like:

type MyJobNames = "foo" | "bar" | "baz";

They are still strings, but only those three would be allowed by the Typescript compiler.