Skip to content

Commit e8b5ad9

Browse files
authored
Improve flatMap typescript definitions (immutable-js#1133)
Fixes immutable-js#1128
1 parent 703b430 commit e8b5ad9

File tree

3 files changed

+492
-15
lines changed

3 files changed

+492
-15
lines changed

dist/immutable-nonambient.d.ts

+164-5
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,16 @@
648648
mapper: (value: T, key: number, iter: this) => M,
649649
context?: any
650650
): List<M>;
651+
652+
/**
653+
* Flat-maps the List, returning a new List.
654+
*
655+
* Similar to `list.map(...).flatten(true)`.
656+
*/
657+
flatMap<M>(
658+
mapper: (value: T, key: number, iter: this) => ESIterable<M>,
659+
context?: any
660+
): List<M>;
651661
}
652662

653663

@@ -1181,6 +1191,16 @@
11811191
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
11821192
context?: any
11831193
): Map<KM, VM>;
1194+
1195+
/**
1196+
* Flat-maps the Map, returning a new Map.
1197+
*
1198+
* Similar to `data.map(...).flatten(true)`.
1199+
*/
1200+
flatMap<KM, VM>(
1201+
mapper: (value: V, key: K, iter: this) => ESIterable<[KM, VM]>,
1202+
context?: any
1203+
): Map<KM, VM>;
11841204
}
11851205

11861206

@@ -1257,6 +1277,16 @@
12571277
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
12581278
context?: any
12591279
): OrderedMap<KM, VM>;
1280+
1281+
/**
1282+
* Flat-maps the OrderedMap, returning a new OrderedMap.
1283+
*
1284+
* Similar to `data.map(...).flatten(true)`.
1285+
*/
1286+
flatMap<KM, VM>(
1287+
mapper: (value: V, key: K, iter: this) => ESIterable<[KM, VM]>,
1288+
context?: any
1289+
): OrderedMap<KM, VM>;
12601290
}
12611291

12621292

@@ -1424,6 +1454,16 @@
14241454
mapper: (value: T, key: T, iter: this) => M,
14251455
context?: any
14261456
): Set<M>;
1457+
1458+
/**
1459+
* Flat-maps the Set, returning a new Set.
1460+
*
1461+
* Similar to `set.map(...).flatten(true)`.
1462+
*/
1463+
flatMap<M>(
1464+
mapper: (value: T, key: T, iter: this) => ESIterable<M>,
1465+
context?: any
1466+
): Set<M>;
14271467
}
14281468

14291469

@@ -1484,6 +1524,16 @@
14841524
context?: any
14851525
): OrderedSet<M>;
14861526

1527+
/**
1528+
* Flat-maps the OrderedSet, returning a new OrderedSet.
1529+
*
1530+
* Similar to `set.map(...).flatten(true)`.
1531+
*/
1532+
flatMap<M>(
1533+
mapper: (value: T, key: T, iter: this) => ESIterable<M>,
1534+
context?: any
1535+
): OrderedSet<M>;
1536+
14871537
/**
14881538
* Returns an OrderedSet of the same type "zipped" with the provided
14891539
* iterables.
@@ -1666,6 +1716,16 @@
16661716
mapper: (value: T, key: number, iter: this) => M,
16671717
context?: any
16681718
): Stack<M>;
1719+
1720+
/**
1721+
* Flat-maps the Stack, returning a new Stack.
1722+
*
1723+
* Similar to `stack.map(...).flatten(true)`.
1724+
*/
1725+
flatMap<M>(
1726+
mapper: (value: T, key: number, iter: this) => M,
1727+
context?: any
1728+
): Stack<M>;
16691729
}
16701730

16711731

@@ -1977,6 +2037,16 @@
19772037
mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
19782038
context?: any
19792039
): Seq.Keyed<KM, VM>;
2040+
2041+
/**
2042+
* Flat-maps the Seq, returning a Seq of the same type.
2043+
*
2044+
* Similar to `seq.map(...).flatten(true)`.
2045+
*/
2046+
flatMap<KM, VM>(
2047+
mapper: (value: V, key: K, iter: this) => ESIterable<[KM, VM]>,
2048+
context?: any
2049+
): Seq.Keyed<KM, VM>;
19802050
}
19812051

19822052

@@ -2029,6 +2099,16 @@
20292099
mapper: (value: T, key: number, iter: this) => M,
20302100
context?: any
20312101
): Seq.Indexed<M>;
2102+
2103+
/**
2104+
* Flat-maps the Seq, returning a a Seq of the same type.
2105+
*
2106+
* Similar to `seq.map(...).flatten(true)`.
2107+
*/
2108+
flatMap<M>(
2109+
mapper: (value: T, key: number, iter: this) => ESIterable<M>,
2110+
context?: any
2111+
): Seq.Indexed<M>;
20322112
}
20332113

20342114

@@ -2083,6 +2163,16 @@
20832163
mapper: (value: T, key: T, iter: this) => M,
20842164
context?: any
20852165
): Seq.Set<M>;
2166+
2167+
/**
2168+
* Flat-maps the Seq, returning a Seq of the same type.
2169+
*
2170+
* Similar to `seq.map(...).flatten(true)`.
2171+
*/
2172+
flatMap<M>(
2173+
mapper: (value: T, key: T, iter: this) => ESIterable<M>,
2174+
context?: any
2175+
): Seq.Set<M>;
20862176
}
20872177

20882178
}
@@ -2164,6 +2254,16 @@
21642254
mapper: (value: V, key: K, iter: this) => M,
21652255
context?: any
21662256
): Seq<K, M>;
2257+
2258+
/**
2259+
* Flat-maps the Seq, returning a Seq of the same type.
2260+
*
2261+
* Similar to `seq.map(...).flatten(true)`.
2262+
*/
2263+
flatMap<M>(
2264+
mapper: (value: V, key: K, iter: this) => ESIterable<M>,
2265+
context?: any
2266+
): Seq<K, M>;
21672267
}
21682268

21692269
/**
@@ -2295,6 +2395,16 @@
22952395
context?: any
22962396
): Iterable.Keyed<KM, VM>;
22972397

2398+
/**
2399+
* Flat-maps the Iterable, returning an Iterable of the same type.
2400+
*
2401+
* Similar to `iterable.map(...).flatten(true)`.
2402+
*/
2403+
flatMap<KM, VM>(
2404+
mapper: (value: V, key: K, iter: this) => ESIterable<[KM, VM]>,
2405+
context?: any
2406+
): Iterable.Keyed<KM, VM>;
2407+
22982408
[Symbol.iterator](): Iterator<[K, V]>;
22992409
}
23002410

@@ -2491,6 +2601,16 @@
24912601
context?: any
24922602
): Iterable.Indexed<M>;
24932603

2604+
/**
2605+
* Flat-maps the Iterable, returning an Iterable of the same type.
2606+
*
2607+
* Similar to `iterable.map(...).flatten(true)`.
2608+
*/
2609+
flatMap<M>(
2610+
mapper: (value: T, key: number, iter: this) => ESIterable<M>,
2611+
context?: any
2612+
): Iterable.Indexed<M>;
2613+
24942614
[Symbol.iterator](): Iterator<T>;
24952615
}
24962616

@@ -2548,6 +2668,16 @@
25482668
context?: any
25492669
): Iterable.Set<M>;
25502670

2671+
/**
2672+
* Flat-maps the Iterable, returning an Iterable of the same type.
2673+
*
2674+
* Similar to `iterable.map(...).flatten(true)`.
2675+
*/
2676+
flatMap<M>(
2677+
mapper: (value: T, key: T, iter: this) => ESIterable<M>,
2678+
context?: any
2679+
): Iterable.Set<M>;
2680+
25512681
[Symbol.iterator](): Iterator<T>;
25522682
}
25532683

@@ -3126,12 +3256,12 @@
31263256
/**
31273257
* Flat-maps the Iterable, returning an Iterable of the same type.
31283258
*
3129-
* Similar to `iter.map(...).flatten(true)`.
3259+
* Similar to `iterable.map(...).flatten(true)`.
31303260
*/
3131-
flatMap<R>(
3132-
mapper: (value: V, key: K, iter: this) => ESIterable<R>,
3261+
flatMap<M>(
3262+
mapper: (value: V, key: K, iter: this) => ESIterable<M>,
31333263
context?: any
3134-
): Iterable<K, R>;
3264+
): Iterable<K, M>;
31353265

31363266
// Reducing a value
31373267

@@ -3425,6 +3555,16 @@
34253555
mapper: (value: V, key: K, iter: this) => M,
34263556
context?: any
34273557
): Collection.Keyed<K, M>;
3558+
3559+
/**
3560+
* Flat-maps the Collection, returning an Collection of the same type.
3561+
*
3562+
* Similar to `collection.map(...).flatten(true)`.
3563+
*/
3564+
flatMap<KM, VM>(
3565+
mapper: (value: V, key: K, iter: this) => ESIterable<[KM, VM]>,
3566+
context?: any
3567+
): Collection.Keyed<KM, VM>;
34283568
}
34293569

34303570

@@ -3464,6 +3604,16 @@
34643604
mapper: (value: T, key: number, iter: this) => M,
34653605
context?: any
34663606
): Collection.Indexed<M>;
3607+
3608+
/**
3609+
* Flat-maps the Collection, returning an Collection of the same type.
3610+
*
3611+
* Similar to `collection.map(...).flatten(true)`.
3612+
*/
3613+
flatMap<M>(
3614+
mapper: (value: T, key: number, iter: this) => ESIterable<M>,
3615+
context?: any
3616+
): Collection.Indexed<M>;
34673617
}
34683618

34693619

@@ -3507,8 +3657,17 @@
35073657
mapper: (value: T, key: T, iter: this) => M,
35083658
context?: any
35093659
): Collection.Set<M>;
3510-
}
35113660

3661+
/**
3662+
* Flat-maps the Collection, returning an Collection of the same type.
3663+
*
3664+
* Similar to `collection.map(...).flatten(true)`.
3665+
*/
3666+
flatMap<M>(
3667+
mapper: (value: T, key: T, iter: this) => ESIterable<M>,
3668+
context?: any
3669+
): Collection.Set<M>;
3670+
}
35123671
}
35133672

35143673
export interface Collection<K, V> extends Iterable<K, V> {

0 commit comments

Comments
 (0)