@@ -49,6 +49,12 @@ type $ValOf<C, K = $KeyOf<C>> = $Call<
49
49
K
50
50
>;
51
51
52
+ type $IterableOf<C> = $Call<
53
+ & (<V: Array<any> | IndexedCollection<any> | SetCollection<any>>(V) => Iterable<$ValOf<V>>)
54
+ & (<V: KeyedCollection<any, any> | RecordInstance<any> | PlainObjInput<any, any>>(V) => Iterable<[$KeyOf<V>, $ValOf<V>]>),
55
+ C
56
+ >;
57
+
52
58
declare class _Collection<K, +V> /*implements ValueObject*/ {
53
59
equals(other: mixed): boolean;
54
60
hashCode(): number;
@@ -1372,6 +1378,10 @@ type RecordFactory<Values: Object> = Class<RecordInstance<Values>>;
1372
1378
// The type of runtime Record instances.
1373
1379
type RecordOf<Values: Object> = RecordInstance<Values> & Values;
1374
1380
1381
+ // The values of a Record instance.
1382
+ type _RecordValues<T, R: RecordInstance<T> | T> = R;
1383
+ type RecordValues<R> = _RecordValues<*, R>;
1384
+
1375
1385
declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance);
1376
1386
declare class Record {
1377
1387
static <Values: Object>(spec: Values, name?: string): RecordFactory<Values>;
@@ -1383,10 +1393,10 @@ declare class Record {
1383
1393
}
1384
1394
1385
1395
declare class RecordInstance<T: Object> {
1386
- static (values?: $Shape<T> | Iterable<[$Keys<T>, any] >): RecordOf<T>;
1396
+ static (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >): RecordOf<T>;
1387
1397
// Note: a constructor can only create an instance of RecordInstance<T>,
1388
1398
// it's encouraged to not use `new` when creating Records.
1389
- constructor (values?: $Shape<T> | Iterable<[$Keys<T>, any] >): void;
1399
+ constructor (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >): void;
1390
1400
1391
1401
size: number;
1392
1402
@@ -1407,16 +1417,16 @@ declare class RecordInstance<T: Object> {
1407
1417
1408
1418
set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & T;
1409
1419
update<K: $Keys<T>>(key: K, updater: (value: $ElementType<T, K>) => $ElementType<T, K>): this & T;
1410
- merge(...collections: Array<$Shape<T> | Iterable<[$Keys<T>, any] >>): this & T;
1411
- mergeDeep(...collections: Array<$Shape<T> | Iterable<[$Keys<T>, any] >>): this & T;
1420
+ merge(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >>): this & T;
1421
+ mergeDeep(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >>): this & T;
1412
1422
1413
1423
mergeWith(
1414
- merger: (oldVal: any , newVal: any , key: $Keys<T>) => any ,
1415
- ...collections: Array<$Shape<T> | Iterable<[$Keys<T>, any] >>
1424
+ merger: (oldVal: $ValOf<T> , newVal: $ValOf<T> , key: $Keys<T>) => $ValOf<T> ,
1425
+ ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >>
1416
1426
): this & T;
1417
1427
mergeDeepWith(
1418
1428
merger: (oldVal: any, newVal: any, key: any) => any,
1419
- ...collections: Array<$Shape<T> | Iterable<[$Keys<T>, any] >>
1429
+ ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T >>
1420
1430
): this & T;
1421
1431
1422
1432
delete<K: $Keys<T>>(key: K): this & T;
@@ -1471,7 +1481,7 @@ declare class RecordInstance<T: Object> {
1471
1481
wasAltered(): boolean;
1472
1482
asImmutable(): this & T;
1473
1483
1474
- @@iterator(): Iterator<[$Keys<T>, any ]>;
1484
+ @@iterator(): Iterator<[$Keys<T>, $ValOf<T> ]>;
1475
1485
}
1476
1486
1477
1487
declare function fromJS(
@@ -1533,21 +1543,21 @@ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<
1533
1543
1534
1544
declare function merge<C>(
1535
1545
collection: C,
1536
- ...collections: Array<Iterable<$ValOf <C>> | Iterable<[$KeyOf<C>, $ValOf <C>] > | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1546
+ ...collections: Array<$IterableOf <C> | $Shape<RecordValues <C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1537
1547
): C;
1538
1548
declare function mergeWith<C>(
1539
1549
merger: (oldVal: $ValOf<C>, newVal: $ValOf<C>, key: $KeyOf<C>) => $ValOf<C>,
1540
1550
collection: C,
1541
- ...collections: Array<Iterable<$ValOf <C>> | Iterable<[$KeyOf<C>, $ValOf <C>] > | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1551
+ ...collections: Array<$IterableOf <C> | $Shape<RecordValues <C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1542
1552
): C;
1543
1553
declare function mergeDeep<C>(
1544
1554
collection: C,
1545
- ...collections: Array<Iterable<$ValOf <C>> | Iterable<[$KeyOf<C>, $ValOf <C>] > | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1555
+ ...collections: Array<$IterableOf <C> | $Shape<RecordValues <C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1546
1556
): C;
1547
1557
declare function mergeDeepWith<C>(
1548
1558
merger: (oldVal: any, newVal: any, key: any) => mixed,
1549
1559
collection: C,
1550
- ...collections: Array<Iterable<$ValOf <C>> | Iterable<[$KeyOf<C>, $ValOf <C>] > | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1560
+ ...collections: Array<$IterableOf <C> | $Shape<RecordValues <C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1551
1561
): C;
1552
1562
1553
1563
export {
0 commit comments