@@ -55,6 +55,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
55
55
*/
56
56
timeout ?: number ;
57
57
58
+ // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
58
59
constructor ( options ?: Options < QueueType , EnqueueOptionsType > ) {
59
60
super ( ) ;
60
61
@@ -237,8 +238,8 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
237
238
/**
238
239
Adds a sync or async task to the queue. Always returns a promise.
239
240
*/
240
- async add < TaskResultType > ( function_ : Task < TaskResultType > , options ?: Partial < EnqueueOptionsType > ) : Promise < TaskResultType | void > ;
241
241
async add < TaskResultType > ( function_ : Task < TaskResultType > , options : { throwOnTimeout : true } & Exclude < EnqueueOptionsType , 'throwOnTimeout' > ) : Promise < TaskResultType > ;
242
+ async add < TaskResultType > ( function_ : Task < TaskResultType > , options ?: Partial < EnqueueOptionsType > ) : Promise < TaskResultType | void > ;
242
243
async add < TaskResultType > ( function_ : Task < TaskResultType > , options : Partial < EnqueueOptionsType > = { } ) : Promise < TaskResultType | void > {
243
244
options = {
244
245
timeout : this . timeout ,
@@ -295,14 +296,14 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
295
296
296
297
@returns A promise that resolves when all functions are resolved.
297
298
*/
298
- async addAll < TaskResultsType > (
299
- functions : ReadonlyArray < Task < TaskResultsType > > ,
300
- options ?: Partial < EnqueueOptionsType > ,
301
- ) : Promise < Array < TaskResultsType | void > > ;
302
299
async addAll < TaskResultsType > (
303
300
functions : ReadonlyArray < Task < TaskResultsType > > ,
304
301
options ?: { throwOnTimeout : true } & Partial < Exclude < EnqueueOptionsType , 'throwOnTimeout' > > ,
305
302
) : Promise < TaskResultsType [ ] >
303
+ async addAll < TaskResultsType > (
304
+ functions : ReadonlyArray < Task < TaskResultsType > > ,
305
+ options ?: Partial < EnqueueOptionsType > ,
306
+ ) : Promise < Array < TaskResultsType | void > > ;
306
307
async addAll < TaskResultsType > (
307
308
functions : ReadonlyArray < Task < TaskResultsType > > ,
308
309
options ?: Partial < EnqueueOptionsType > ,
0 commit comments