File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
Create an error from multiple errors.
3
3
*/
4
- declare class AggregateError extends Error implements Iterable < Error > {
4
+ declare class AggregateError < T extends Error = Error > extends Error implements Iterable < T > {
5
5
readonly name : 'AggregateError' ;
6
6
7
7
/**
@@ -43,9 +43,9 @@ declare class AggregateError extends Error implements Iterable<Error> {
43
43
//=> [Error: baz]
44
44
```
45
45
*/
46
- constructor ( errors : ReadonlyArray < Error | { [ key : string ] : any } | string > ) ;
46
+ constructor ( errors : ReadonlyArray < T | { [ key : string ] : any } | string > ) ;
47
47
48
- [ Symbol . iterator ] ( ) : IterableIterator < Error > ;
48
+ [ Symbol . iterator ] ( ) : IterableIterator < T > ;
49
49
}
50
50
51
51
export = AggregateError ;
Original file line number Diff line number Diff line change @@ -12,3 +12,20 @@ expectType<IterableIterator<Error>>(aggregateError[Symbol.iterator]());
12
12
for ( const error of aggregateError ) {
13
13
expectType < Error > ( error ) ;
14
14
}
15
+
16
+ class CustomError extends Error {
17
+ public foo : string ;
18
+
19
+ constructor ( message : string ) {
20
+ super ( message )
21
+ this . name = 'CustomError' ;
22
+ this . foo = 'bar' ;
23
+ }
24
+ }
25
+ const customAggregateError = new AggregateError < CustomError > ( [
26
+ new CustomError ( 'foo' )
27
+ ] ) ;
28
+
29
+ for ( const error of customAggregateError ) {
30
+ expectType < string > ( error . foo ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments