Skip to content

Commit ae6bf9c

Browse files
committed
bug(esnext) add overloads for flatten
1 parent 8c2eeb2 commit ae6bf9c

File tree

1 file changed

+154
-2
lines changed

1 file changed

+154
-2
lines changed

src/lib/esnext.array.d.ts

+154-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,101 @@ interface ReadonlyArray<T> {
1515
thisArg?: This
1616
): U[]
1717

18+
19+
/**
20+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
21+
* specified depth.
22+
*
23+
* @param depth The maximum recursion depth
24+
*/
25+
flatten<U>(this:
26+
ReadonlyArray<U[][][][]> |
27+
28+
ReadonlyArray<ReadonlyArray<U[][][]>> |
29+
ReadonlyArray<ReadonlyArray<U[][]>[]> |
30+
ReadonlyArray<ReadonlyArray<U[]>[][]> |
31+
ReadonlyArray<ReadonlyArray<U>[][][]> |
32+
33+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[][]>>> |
34+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[][]>> |
35+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[][]> |
36+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>[]> |
37+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>[]> |
38+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>[]>> |
39+
40+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>>> |
41+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>>> |
42+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]>> |
43+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>[]> |
44+
45+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>>,
46+
depth: 4): U[];
47+
48+
/**
49+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
50+
* specified depth.
51+
*
52+
* @param depth The maximum recursion depth
53+
*/
54+
flatten<U>(this:
55+
ReadonlyArray<U[][][]> |
56+
57+
ReadonlyArray<ReadonlyArray<U>[][]> |
58+
ReadonlyArray<ReadonlyArray<U[]>[]> |
59+
ReadonlyArray<ReadonlyArray<U[][]>> |
60+
61+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>> |
62+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>> |
63+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]> |
64+
65+
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>,
66+
depth: 3): U[];
67+
68+
/**
69+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
70+
* specified depth.
71+
*
72+
* @param depth The maximum recursion depth
73+
*/
74+
flatten<U>(this:
75+
ReadonlyArray<U[][]> |
76+
77+
ReadonlyArray<ReadonlyArray<U[]>> |
78+
ReadonlyArray<ReadonlyArray<U>[]> |
79+
80+
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>,
81+
depth: 2): U[];
82+
83+
/**
84+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
85+
* specified depth.
86+
*
87+
* @param depth The maximum recursion depth
88+
*/
89+
flatten<U>(this:
90+
ReadonlyArray<U[]> |
91+
ReadonlyArray<ReadonlyArray<U>>,
92+
depth?: 1
93+
): U[];
94+
95+
/**
96+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
97+
* specified depth.
98+
*
99+
* @param depth The maximum recursion depth
100+
*/
101+
flatten<U>(this:
102+
ReadonlyArray<U>,
103+
depth: 0
104+
): U[];
105+
18106
/**
19107
* Returns a new array with all sub-array elements concatenated into it recursively up to the
20108
* specified depth. If no depth is provided, flatten method defaults to the depth of 1.
21109
*
22110
* @param depth The maximum recursion depth
23111
*/
24-
flatten<U>(this: ReadonlyArray<U>, depth?: number): U[];
112+
flatten<U>(depth?: number): any[];
25113
}
26114

27115
interface Array<T> {
@@ -41,11 +129,75 @@ interface Array<T> {
41129
thisArg?: This
42130
): U[]
43131

132+
/**
133+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
134+
* specified depth.
135+
*
136+
* @param depth The maximum recursion depth
137+
*/
138+
flatten<U>(this: U[][][][][][][][], depth: 7): U[];
139+
140+
/**
141+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
142+
* specified depth.
143+
*
144+
* @param depth The maximum recursion depth
145+
*/
146+
flatten<U>(this: U[][][][][][][], depth: 6): U[];
147+
148+
/**
149+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
150+
* specified depth.
151+
*
152+
* @param depth The maximum recursion depth
153+
*/
154+
flatten<U>(this: U[][][][][][], depth: 5): U[];
155+
156+
/**
157+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
158+
* specified depth.
159+
*
160+
* @param depth The maximum recursion depth
161+
*/
162+
flatten<U>(this: U[][][][][], depth: 4): U[];
163+
164+
/**
165+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
166+
* specified depth.
167+
*
168+
* @param depth The maximum recursion depth
169+
*/
170+
flatten<U>(this: U[][][][], depth: 3): U[];
171+
172+
/**
173+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
174+
* specified depth.
175+
*
176+
* @param depth The maximum recursion depth
177+
*/
178+
flatten<U>(this: U[][][], depth: 2): U[];
179+
180+
/**
181+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
182+
* specified depth.
183+
*
184+
* @param depth The maximum recursion depth
185+
*/
186+
flatten<U>(this: U[][], depth?: 1): U[];
187+
188+
/**
189+
* Returns a new array with all sub-array elements concatenated into it recursively up to the
190+
* specified depth.
191+
*
192+
* @param depth The maximum recursion depth
193+
*/
194+
flatten<U>(this: U[], depth: 0): U[];
195+
44196
/**
45197
* Returns a new array with all sub-array elements concatenated into it recursively up to the
46198
* specified depth. If no depth is provided, flatten method defaults to the depth of 1.
47199
*
48200
* @param depth The maximum recursion depth
49201
*/
50-
flatten<U>(this: U[], depth?: number): U[];
202+
flatten<U>(depth?: number): any[];
51203
}

0 commit comments

Comments
 (0)