@@ -55,6 +55,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
5555 */
5656 timeout ?: number ;
5757
58+ // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`
5859 constructor ( options ?: Options < QueueType , EnqueueOptionsType > ) {
5960 super ( ) ;
6061
@@ -237,8 +238,8 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
237238 /**
238239 Adds a sync or async task to the queue. Always returns a promise.
239240 */
240- async add < TaskResultType > ( function_ : Task < TaskResultType > , options ?: Partial < EnqueueOptionsType > ) : Promise < TaskResultType | void > ;
241241 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 > ;
242243 async add < TaskResultType > ( function_ : Task < TaskResultType > , options : Partial < EnqueueOptionsType > = { } ) : Promise < TaskResultType | void > {
243244 options = {
244245 timeout : this . timeout ,
@@ -295,14 +296,14 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
295296
296297 @returns A promise that resolves when all functions are resolved.
297298 */
298- async addAll < TaskResultsType > (
299- functions : ReadonlyArray < Task < TaskResultsType > > ,
300- options ?: Partial < EnqueueOptionsType > ,
301- ) : Promise < Array < TaskResultsType | void > > ;
302299 async addAll < TaskResultsType > (
303300 functions : ReadonlyArray < Task < TaskResultsType > > ,
304301 options ?: { throwOnTimeout : true } & Partial < Exclude < EnqueueOptionsType , 'throwOnTimeout' > > ,
305302 ) : Promise < TaskResultsType [ ] >
303+ async addAll < TaskResultsType > (
304+ functions : ReadonlyArray < Task < TaskResultsType > > ,
305+ options ?: Partial < EnqueueOptionsType > ,
306+ ) : Promise < Array < TaskResultsType | void > > ;
306307 async addAll < TaskResultsType > (
307308 functions : ReadonlyArray < Task < TaskResultsType > > ,
308309 options ?: Partial < EnqueueOptionsType > ,
0 commit comments