@types/bluebird: Make AggregateError ArrayLike (#16148)

* Make AggregateError ArrayLike

For simplification extend AggregateError from Array<Error>

* Make AggregateError implementing ArrayLike

AggregateError should be an Error and also an ArrayLike of Errors with a bunch of Array-methods.
This commit is contained in:
arlecchino 2017-04-26 23:35:30 +02:00 committed by Sheetal Nandi
parent 94f553150d
commit c4077c19e4

View File

@ -726,7 +726,28 @@ declare namespace Bluebird {
*
* `Promise.some` and `Promise.any` use `AggregateError` as rejection reason when they fail.
*/
export class AggregateError extends Error {}
export class AggregateError extends Error implements ArrayLike<Error> {
length: number;
[index: number]: Error;
join(separator?: string): string;
pop(): Error;
push(...errors: Error[]): number;
shift(): Error;
unshift(...errors: Error[]): number;
slice(begin?: number, end?: number): AggregateError;
filter(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): AggregateError;
forEach(callback: (element: Error, index: number, array: AggregateError) => void, thisArg?: any): undefined;
some(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): boolean;
every(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): boolean;
map(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): AggregateError;
indexOf(searchElement: Error, fromIndex?: number): number;
lastIndexOf(searchElement: Error, fromIndex?: number): number;
reduce(callback: (accumulator: any, element: Error, index: number, array: AggregateError) => any, initialValue?: any): any;
reduceRight(callback: (previousValue: any, element: Error, index: number, array: AggregateError) => any, initialValue?: any): any;
sort(compareFunction?: (errLeft: Error, errRight: Error) => number): AggregateError;
reverse(): AggregateError;
}
/**
* returned by `Bluebird.disposer()`.