Closed nguyentoanit closed 3 years ago
Hi,
I am trying CustomQueue in p-queue libs. But got an error need your help:
Sample:
class CustomQueue { private readonly _queue: RunFunction[] = [] constructor() { this._queue = []; } enqueue(run: RunFunction, options?: Partial<PriorityQueueOptions>): void { this._queue.push(run); } dequeue(): RunFunction | undefined { return this._queue.shift(); } get size(): number { return this._queue.length; } filter(options: Readonly<Partial<PriorityQueueOptions>>): RunFunction[] { return this._queue; } } const queue = new PQueue({ autoStart: false, queueClass: () => new CustomQueue() })
Error message:
Type '() => CustomQueue' is not assignable to type 'new () => PriorityQueue'. Type '() => CustomQueue' provides no match for the signature 'new (): PriorityQueue'.
Something is wrong? 🤔
Docs: https://github.com/sindresorhus/p-queue#custom-queueclass
You need to pass the class, not the instance.
Hi,
I am trying CustomQueue in p-queue libs. But got an error need your help:
Sample:
Error message:
Something is wrong? 🤔
Docs: https://github.com/sindresorhus/p-queue#custom-queueclass