bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

Argument of type 'string' is not assignable to parameter of type 'ExtractNameType<DataTypeOrJob, DefaultNameType>

Open lucasctc opened this issue 5 months ago • 3 comments

Im getting an error upgrading to 5.56.8 from 5.7.1 when trying to add a job to the queue.

The error is error TS2345: Argument of type 'string' is not assignable to parameter of type 'ExtractNameType<DataTypeOrJob, DefaultNameType>'. NameType extends string, so a string should work. https://api.docs.bullmq.io/classes/v5.Queue.html#constructorqueuenametype

I can see on the unit tests a string is used too. https://github.com/taskforcesh/bullmq/blob/master/tests/test_queue.ts#L47

    const jobId = `${uid.toHexString()}-${importId.toString()}`;
    const jobName: string = `deleteImport:${jobId}`;

    const jobData: ImportDeletionJobData = {
      uid: uid.toHexString(),
      importId: importId.toHexString(),
      importType,
    };

    await importDeletionQueue.add(jobName, jobData);
  • here is my queue.
export const importDeletionQueue = new Queue<ImportDeletionJobData, any, string>(
  IMPORT_DELETE_QUEUE,
  {
    // @ts-expect-error - bullmq types are incorrect
    connection: getRedisClient(RedisClient.BullMQ) as IORedis.Redis,
    defaultJobOptions,
  },
);

My TypeScript compiler version is 5.4.5

lucasctc avatar Jul 28 '25 06:07 lucasctc

bump

hubertoschusch avatar Aug 11 '25 08:08 hubertoschusch

Have you tried omitting the third generic parameter? (not a fix but a workaround):

export const importDeletionQueue = new Queue<ImportDeletionJobData, any>(
  IMPORT_DELETE_QUEUE,
  {
    connection: getRedisClient(RedisClient.BullMQ) as IORedis.Redis,
    defaultJobOptions,
  },
);

manast avatar Aug 13 '25 06:08 manast

Have you tried omitting the third generic parameter? (not a fix but a workaround):

export const importDeletionQueue = new Queue<ImportDeletionJobData, any>(
  IMPORT_DELETE_QUEUE,
  {
    connection: getRedisClient(RedisClient.BullMQ) as IORedis.Redis,
    defaultJobOptions,
  },
);

Appreciate the suggestion. I think I tried this approach, but ill let you know for sure.

lucasctc avatar Aug 13 '25 22:08 lucasctc

Having the same issue!

nikhilgupta345 avatar Dec 15 '25 19:12 nikhilgupta345