1+ type Flatten < T > = T extends readonly ( infer U ) [ ] ? U : T ;
2+
13interface ReadonlyArray < T > {
24
35 /**
@@ -10,106 +12,23 @@ interface ReadonlyArray<T> {
1012 * @param thisArg An object to which the this keyword can refer in the callback function. If
1113 * thisArg is omitted, undefined is used as the this value.
1214 */
13- flatMap < U , This = undefined > (
14- callback : ( this : This , value : T , index : number , array : T [ ] ) => U | ReadonlyArray < U > ,
15- thisArg ?: This
16- ) : U [ ]
17-
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- flat < 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- flat < 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- flat < U > ( this :
75- ReadonlyArray < U [ ] [ ] > |
76-
77- ReadonlyArray < ReadonlyArray < U [ ] > > |
78- ReadonlyArray < ReadonlyArray < U > [ ] > |
79-
80- ReadonlyArray < ReadonlyArray < ReadonlyArray < U > > > ,
81- depth : 2 ) : U [ ] ;
15+ flatMap < U > (
16+ callbackfn : ( value : T , index : number , array : readonly T [ ] ) => U ,
17+ thisArg ?: any
18+ ) : Flatten < U > [ ] ;
8219
8320 /**
8421 * Returns a new array with all sub-array elements concatenated into it recursively up to the
8522 * specified depth.
8623 *
8724 * @param depth The maximum recursion depth
8825 */
89- flat < 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- flat < U > ( this :
102- ReadonlyArray < U > ,
103- depth : 0
104- ) : U [ ] ;
105-
106- /**
107- * Returns a new array with all sub-array elements concatenated into it recursively up to the
108- * specified depth. If no depth is provided, flat method defaults to the depth of 1.
109- *
110- * @param depth The maximum recursion depth
111- */
112- flat < U > ( depth ?: number ) : any [ ] ;
26+ flat ( depth : 4 ) : Flatten < Flatten < Flatten < Flatten < this[ number ] > > > > [ ] ;
27+ flat ( depth : 3 ) : Flatten < Flatten < Flatten < this[ number ] > > > [ ] ;
28+ flat ( depth : 2 ) : Flatten < Flatten < this[ number ] > > [ ] ;
29+ flat ( depth ?: 1 ) : Flatten < this[ number ] > [ ] ;
30+ flat ( depth : 0 ) : { - readonly [ P in keyof this] : this[ P ] } ;
31+ flat ( depth : number ) : any [ ] ;
11332}
11433
11534interface Array < T > {
@@ -124,80 +43,21 @@ interface Array<T> {
12443 * @param thisArg An object to which the this keyword can refer in the callback function. If
12544 * thisArg is omitted, undefined is used as the this value.
12645 */
127- flatMap < U , This = undefined > (
128- callback : ( this : This , value : T , index : number , array : T [ ] ) => U | ReadonlyArray < U > ,
129- thisArg ?: This
130- ) : U [ ]
131-
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- flat < 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- flat < 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- flat < 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- flat < 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- flat < U > ( this : U [ ] [ ] [ ] [ ] , depth : 3 ) : U [ ] ;
46+ flatMap < U > (
47+ callbackfn : ( value : T , index : number , array : T [ ] ) => U ,
48+ thisArg ?: any
49+ ) : Flatten < U > [ ] ;
17150
17251 /**
17352 * Returns a new array with all sub-array elements concatenated into it recursively up to the
17453 * specified depth.
17554 *
17655 * @param depth The maximum recursion depth
17756 */
178- flat < 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- flat < 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- flat < U > ( this : U [ ] , depth : 0 ) : U [ ] ;
195-
196- /**
197- * Returns a new array with all sub-array elements concatenated into it recursively up to the
198- * specified depth. If no depth is provided, flat method defaults to the depth of 1.
199- *
200- * @param depth The maximum recursion depth
201- */
202- flat < U > ( depth ?: number ) : any [ ] ;
57+ flat ( depth : 4 ) : Flatten < Flatten < Flatten < Flatten < this[ number ] > > > > [ ] ;
58+ flat ( depth : 3 ) : Flatten < Flatten < Flatten < this[ number ] > > > [ ] ;
59+ flat ( depth : 2 ) : Flatten < Flatten < this[ number ] > > [ ] ;
60+ flat ( depth ?: 1 ) : Flatten < this[ number ] > [ ] ;
61+ flat ( depth : 0 ) : { - readonly [ P in keyof this] : this[ P ] } ;
62+ flat ( depth : number ) : any [ ] ;
20363}
0 commit comments