immutable 4.0.0-rc.14 → 4.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,7 +90,7 @@
90
90
  * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
91
91
  */
92
92
 
93
- declare module Immutable {
93
+ declare namespace Immutable {
94
94
  /**
95
95
  * Lists are ordered indexed dense collections, much like a JavaScript
96
96
  * Array.
@@ -105,7 +105,7 @@ declare module Immutable {
105
105
  * "unset" index and an index set to `undefined`. `List#forEach` visits all
106
106
  * indices from 0 to size, regardless of whether they were explicitly defined.
107
107
  */
108
- export module List {
108
+ namespace List {
109
109
  /**
110
110
  * True if the provided value is a List
111
111
  *
@@ -171,11 +171,9 @@ declare module Immutable {
171
171
  * listFromPlainSet.equals(listFromPlainArray) // true
172
172
  * ```
173
173
  */
174
- export function List<T>(collection: Iterable<T>): List<T>;
175
- export function List<T>(): List<T>;
176
- export function List(): List<unknown>;
174
+ function List<T>(collection?: Iterable<T> | ArrayLike<T>): List<T>;
177
175
 
178
- export interface List<T> extends Collection.Indexed<T> {
176
+ interface List<T> extends Collection.Indexed<T> {
179
177
  /**
180
178
  * The number of items in this List.
181
179
  */
@@ -661,7 +659,7 @@ declare module Immutable {
661
659
  thirdCollection: Collection<unknown, V>
662
660
  ): List<Z>;
663
661
  zipWith<Z>(
664
- zipper: (...any: Array<unknown>) => Z,
662
+ zipper: (...values: Array<unknown>) => Z,
665
663
  ...collections: Array<Collection<unknown, unknown>>
666
664
  ): List<Z>;
667
665
  }
@@ -693,7 +691,7 @@ declare module Immutable {
693
691
  *
694
692
  * Implemented by a hash-array mapped trie.
695
693
  */
696
- export module Map {
694
+ namespace Map {
697
695
  /**
698
696
  * True if the provided value is a Map
699
697
  *
@@ -761,13 +759,11 @@ declare module Immutable {
761
759
  * but since Immutable Map keys can be of any type the argument to `get()` is
762
760
  * not altered.
763
761
  */
764
- export function Map(): Map<unknown, unknown>;
765
- export function Map<K, V>(): Map<K, V>;
766
- export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
767
- export function Map<V>(obj: { [key: string]: V }): Map<string, V>;
768
- export function Map<K extends string, V>(obj: { [P in K]?: V }): Map<K, V>;
762
+ function Map<K, V>(collection?: Iterable<[K, V]>): Map<K, V>;
763
+ function Map<V>(obj: { [key: string]: V }): Map<string, V>;
764
+ function Map<K extends string, V>(obj: { [P in K]?: V }): Map<K, V>;
769
765
 
770
- export interface Map<K, V> extends Collection.Keyed<K, V> {
766
+ interface Map<K, V> extends Collection.Keyed<K, V> {
771
767
  /**
772
768
  * The number of entries in this Map.
773
769
  */
@@ -1019,12 +1015,18 @@ declare module Immutable {
1019
1015
  ): this;
1020
1016
 
1021
1017
  /**
1022
- * Like `merge()`, but when two Collections conflict, it merges them as well,
1023
- * recursing deeply through the nested data.
1018
+ * Like `merge()`, but when two compatible collections are encountered with
1019
+ * the same key, it merges them as well, recursing deeply through the nested
1020
+ * data. Two collections are considered to be compatible (and thus will be
1021
+ * merged together) if they both fall into one of three categories: keyed
1022
+ * (e.g., `Map`s, `Record`s, and objects), indexed (e.g., `List`s and
1023
+ * arrays), or set-like (e.g., `Set`s). If they fall into separate
1024
+ * categories, `mergeDeep` will replace the existing collection with the
1025
+ * collection being merged in. This behavior can be customized by using
1026
+ * `mergeDeepWith()`.
1024
1027
  *
1025
- * Note: Values provided to `merge` are shallowly converted before being
1026
- * merged. No nested values are altered unless they will also be merged at
1027
- * a deeper level.
1028
+ * Note: Indexed and set-like collections are merged using
1029
+ * `concat()`/`union()` and therefore do not recurse.
1028
1030
  *
1029
1031
  * <!-- runkit:activate -->
1030
1032
  * ```js
@@ -1046,8 +1048,11 @@ declare module Immutable {
1046
1048
  ): this;
1047
1049
 
1048
1050
  /**
1049
- * Like `mergeDeep()`, but when two non-Collections conflict, it uses the
1050
- * `merger` function to determine the resulting value.
1051
+ * Like `mergeDeep()`, but when two non-collections or incompatible
1052
+ * collections are encountered at the same key, it uses the `merger`
1053
+ * function to determine the resulting value. Collections are considered
1054
+ * incompatible if they fall into separate categories between keyed,
1055
+ * indexed, and set-like.
1051
1056
  *
1052
1057
  * <!-- runkit:activate -->
1053
1058
  * ```js
@@ -1061,7 +1066,7 @@ declare module Immutable {
1061
1066
  * // "c": Map { "z": 3 }
1062
1067
  * // }
1063
1068
  * ```
1064
-
1069
+ *
1065
1070
  * Note: `mergeDeepWith` can be used in `withMutations`.
1066
1071
  */
1067
1072
  mergeDeepWith(
@@ -1367,7 +1372,11 @@ declare module Immutable {
1367
1372
  * @see Collection.Keyed.mapEntries
1368
1373
  */
1369
1374
  mapEntries<KM, VM>(
1370
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
1375
+ mapper: (
1376
+ entry: [K, V],
1377
+ index: number,
1378
+ iter: this
1379
+ ) => [KM, VM] | undefined,
1371
1380
  context?: unknown
1372
1381
  ): Map<KM, VM>;
1373
1382
 
@@ -1414,8 +1423,7 @@ declare module Immutable {
1414
1423
  * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not
1415
1424
  * stable.
1416
1425
  */
1417
-
1418
- export module OrderedMap {
1426
+ namespace OrderedMap {
1419
1427
  /**
1420
1428
  * True if the provided value is an OrderedMap.
1421
1429
  */
@@ -1439,16 +1447,10 @@ declare module Immutable {
1439
1447
  * Note: `OrderedMap` is a factory function and not a class, and does not use
1440
1448
  * the `new` keyword during construction.
1441
1449
  */
1442
- export function OrderedMap(): OrderedMap<unknown, unknown>;
1443
- export function OrderedMap<K, V>(): OrderedMap<K, V>;
1444
- export function OrderedMap<K, V>(
1445
- collection: Iterable<[K, V]>
1446
- ): OrderedMap<K, V>;
1447
- export function OrderedMap<V>(obj: {
1448
- [key: string]: V;
1449
- }): OrderedMap<string, V>;
1450
+ function OrderedMap<K, V>(collection?: Iterable<[K, V]>): OrderedMap<K, V>;
1451
+ function OrderedMap<V>(obj: { [key: string]: V }): OrderedMap<string, V>;
1450
1452
 
1451
- export interface OrderedMap<K, V> extends Map<K, V> {
1453
+ interface OrderedMap<K, V> extends Map<K, V> {
1452
1454
  /**
1453
1455
  * The number of entries in this OrderedMap.
1454
1456
  */
@@ -1538,7 +1540,11 @@ declare module Immutable {
1538
1540
  * @see Collection.Keyed.mapEntries
1539
1541
  */
1540
1542
  mapEntries<KM, VM>(
1541
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
1543
+ mapper: (
1544
+ entry: [K, V],
1545
+ index: number,
1546
+ iter: this
1547
+ ) => [KM, VM] | undefined,
1542
1548
  context?: unknown
1543
1549
  ): OrderedMap<KM, VM>;
1544
1550
 
@@ -1585,7 +1591,7 @@ declare module Immutable {
1585
1591
  * `Immutable.is`, enabling Sets to uniquely include other Immutable
1586
1592
  * collections, custom value types, and NaN.
1587
1593
  */
1588
- export module Set {
1594
+ namespace Set {
1589
1595
  /**
1590
1596
  * True if the provided value is a Set
1591
1597
  */
@@ -1641,11 +1647,9 @@ declare module Immutable {
1641
1647
  * Note: `Set` is a factory function and not a class, and does not use the
1642
1648
  * `new` keyword during construction.
1643
1649
  */
1644
- export function Set<T>(collection: Iterable<T>): Set<T>;
1645
- export function Set<T>(): Set<T>;
1646
- export function Set(): Set<unknown>;
1650
+ function Set<T>(collection?: Iterable<T> | ArrayLike<T>): Set<T>;
1647
1651
 
1648
- export interface Set<T> extends Collection.Set<T> {
1652
+ interface Set<T> extends Collection.Set<T> {
1649
1653
  /**
1650
1654
  * The number of items in this Set.
1651
1655
  */
@@ -1795,7 +1799,7 @@ declare module Immutable {
1795
1799
  * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not
1796
1800
  * stable.
1797
1801
  */
1798
- export module OrderedSet {
1802
+ namespace OrderedSet {
1799
1803
  /**
1800
1804
  * True if the provided value is an OrderedSet.
1801
1805
  */
@@ -1821,11 +1825,11 @@ declare module Immutable {
1821
1825
  * Note: `OrderedSet` is a factory function and not a class, and does not use
1822
1826
  * the `new` keyword during construction.
1823
1827
  */
1824
- export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
1825
- export function OrderedSet<T>(): OrderedSet<T>;
1826
- export function OrderedSet(): OrderedSet<unknown>;
1828
+ function OrderedSet<T>(
1829
+ collection?: Iterable<T> | ArrayLike<T>
1830
+ ): OrderedSet<T>;
1827
1831
 
1828
- export interface OrderedSet<T> extends Set<T> {
1832
+ interface OrderedSet<T> extends Set<T> {
1829
1833
  /**
1830
1834
  * The number of items in this OrderedSet.
1831
1835
  */
@@ -1947,7 +1951,7 @@ declare module Immutable {
1947
1951
  thirdCollection: Collection<unknown, V>
1948
1952
  ): OrderedSet<Z>;
1949
1953
  zipWith<Z>(
1950
- zipper: (...any: Array<unknown>) => Z,
1954
+ zipper: (...values: Array<unknown>) => Z,
1951
1955
  ...collections: Array<Collection<unknown, unknown>>
1952
1956
  ): OrderedSet<Z>;
1953
1957
  }
@@ -1965,7 +1969,7 @@ declare module Immutable {
1965
1969
  *
1966
1970
  * Stack is implemented with a Single-Linked List.
1967
1971
  */
1968
- export module Stack {
1972
+ namespace Stack {
1969
1973
  /**
1970
1974
  * True if the provided value is a Stack
1971
1975
  */
@@ -1987,11 +1991,9 @@ declare module Immutable {
1987
1991
  * Note: `Stack` is a factory function and not a class, and does not use the
1988
1992
  * `new` keyword during construction.
1989
1993
  */
1990
- export function Stack<T>(collection: Iterable<T>): Stack<T>;
1991
- export function Stack<T>(): Stack<T>;
1992
- export function Stack(): Stack<unknown>;
1994
+ function Stack<T>(collection?: Iterable<T> | ArrayLike<T>): Stack<T>;
1993
1995
 
1994
- export interface Stack<T> extends Collection.Indexed<T> {
1996
+ interface Stack<T> extends Collection.Indexed<T> {
1995
1997
  /**
1996
1998
  * The number of items in this Stack.
1997
1999
  */
@@ -2197,7 +2199,7 @@ declare module Immutable {
2197
2199
  thirdCollection: Collection<unknown, V>
2198
2200
  ): Stack<Z>;
2199
2201
  zipWith<Z>(
2200
- zipper: (...any: Array<unknown>) => Z,
2202
+ zipper: (...values: Array<unknown>) => Z,
2201
2203
  ...collections: Array<Collection<unknown, unknown>>
2202
2204
  ): Stack<Z>;
2203
2205
  }
@@ -2220,7 +2222,7 @@ declare module Immutable {
2220
2222
  * Range(30, 30, 5) // []
2221
2223
  * ```
2222
2224
  */
2223
- export function Range(
2225
+ function Range(
2224
2226
  start?: number,
2225
2227
  end?: number,
2226
2228
  step?: number
@@ -2239,7 +2241,7 @@ declare module Immutable {
2239
2241
  * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ]
2240
2242
  * ```
2241
2243
  */
2242
- export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
2244
+ function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
2243
2245
 
2244
2246
  /**
2245
2247
  * A record is similar to a JS object, but enforces a specific set of allowed
@@ -2400,11 +2402,11 @@ declare module Immutable {
2400
2402
  * form isn't free. If converting Records to plain objects is common,
2401
2403
  * consider sticking with plain objects to begin with.
2402
2404
  */
2403
- export module Record {
2405
+ namespace Record {
2404
2406
  /**
2405
2407
  * True if `maybeRecord` is an instance of a Record.
2406
2408
  */
2407
- export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
2409
+ function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
2408
2410
 
2409
2411
  /**
2410
2412
  * Records allow passing a second parameter to supply a descriptive name
@@ -2423,7 +2425,7 @@ declare module Immutable {
2423
2425
  * Record.getDescriptiveName(me) // "Person"
2424
2426
  * ```
2425
2427
  */
2426
- export function getDescriptiveName(record: Record<any>): string;
2428
+ function getDescriptiveName(record: Record<any>): string;
2427
2429
 
2428
2430
  /**
2429
2431
  * A Record.Factory is created by the `Record()` function. Record instances
@@ -2473,15 +2475,14 @@ declare module Immutable {
2473
2475
  * const alan: Person = makePerson({ name: 'Alan' });
2474
2476
  * ```
2475
2477
  */
2476
- export module Factory {}
2478
+ namespace Factory {}
2477
2479
 
2478
- export interface Factory<TProps extends Object> {
2480
+ interface Factory<TProps extends object> {
2479
2481
  (values?: Partial<TProps> | Iterable<[string, unknown]>): Record<TProps> &
2480
2482
  Readonly<TProps>;
2481
- new (values?: Partial<TProps> | Iterable<[string, unknown]>): Record<
2482
- TProps
2483
- > &
2484
- Readonly<TProps>;
2483
+ new (
2484
+ values?: Partial<TProps> | Iterable<[string, unknown]>
2485
+ ): Record<TProps> & Readonly<TProps>;
2485
2486
 
2486
2487
  /**
2487
2488
  * The name provided to `Record(values, name)` can be accessed with
@@ -2490,7 +2491,7 @@ declare module Immutable {
2490
2491
  displayName: string;
2491
2492
  }
2492
2493
 
2493
- export function Factory<TProps extends Object>(
2494
+ function Factory<TProps extends object>(
2494
2495
  values?: Partial<TProps> | Iterable<[string, unknown]>
2495
2496
  ): Record<TProps> & Readonly<TProps>;
2496
2497
  }
@@ -2504,12 +2505,12 @@ declare module Immutable {
2504
2505
  * Note: `Record` is a factory function and not a class, and does not use the
2505
2506
  * `new` keyword during construction.
2506
2507
  */
2507
- export function Record<TProps>(
2508
+ function Record<TProps extends object>(
2508
2509
  defaultValues: TProps,
2509
2510
  name?: string
2510
2511
  ): Record.Factory<TProps>;
2511
2512
 
2512
- export interface Record<TProps extends Object> {
2513
+ interface Record<TProps extends object> {
2513
2514
  // Reading values
2514
2515
 
2515
2516
  has(key: string): key is keyof TProps & string;
@@ -2650,8 +2651,7 @@ declare module Immutable {
2650
2651
  *
2651
2652
  * This is equivalent to an instance of a record created by a Record Factory.
2652
2653
  */
2653
- export type RecordOf<TProps extends Object> = Record<TProps> &
2654
- Readonly<TProps>;
2654
+ type RecordOf<TProps extends object> = Record<TProps> & Readonly<TProps>;
2655
2655
 
2656
2656
  /**
2657
2657
  * `Seq` describes a lazy operation, allowing them to efficiently chain
@@ -2728,7 +2728,7 @@ declare module Immutable {
2728
2728
  * ```
2729
2729
  */
2730
2730
 
2731
- export module Seq {
2731
+ namespace Seq {
2732
2732
  /**
2733
2733
  * True if `maybeSeq` is a Seq, it is not backed by a concrete
2734
2734
  * structure such as Map, List, or Set.
@@ -2743,7 +2743,7 @@ declare module Immutable {
2743
2743
  /**
2744
2744
  * `Seq` which represents key-value pairs.
2745
2745
  */
2746
- export module Keyed {}
2746
+ namespace Keyed {}
2747
2747
 
2748
2748
  /**
2749
2749
  * Always returns a Seq.Keyed, if input is not keyed, expects an
@@ -2752,12 +2752,10 @@ declare module Immutable {
2752
2752
  * Note: `Seq.Keyed` is a conversion function and not a class, and does not
2753
2753
  * use the `new` keyword during construction.
2754
2754
  */
2755
- export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
2756
- export function Keyed<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
2757
- export function Keyed<K, V>(): Seq.Keyed<K, V>;
2758
- export function Keyed(): Seq.Keyed<unknown, unknown>;
2755
+ function Keyed<K, V>(collection?: Iterable<[K, V]>): Seq.Keyed<K, V>;
2756
+ function Keyed<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
2759
2757
 
2760
- export interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
2758
+ interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
2761
2759
  /**
2762
2760
  * Deeply converts this Keyed Seq to equivalent native JavaScript Object.
2763
2761
  *
@@ -2825,7 +2823,11 @@ declare module Immutable {
2825
2823
  * @see Collection.Keyed.mapEntries
2826
2824
  */
2827
2825
  mapEntries<KM, VM>(
2828
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
2826
+ mapper: (
2827
+ entry: [K, V],
2828
+ index: number,
2829
+ iter: this
2830
+ ) => [KM, VM] | undefined,
2829
2831
  context?: unknown
2830
2832
  ): Seq.Keyed<KM, VM>;
2831
2833
 
@@ -2859,12 +2861,14 @@ declare module Immutable {
2859
2861
  * @see Collection.Keyed.flip
2860
2862
  */
2861
2863
  flip(): Seq.Keyed<V, K>;
2864
+
2865
+ [Symbol.iterator](): IterableIterator<[K, V]>;
2862
2866
  }
2863
2867
 
2864
2868
  /**
2865
2869
  * `Seq` which represents an ordered indexed list of values.
2866
2870
  */
2867
- module Indexed {
2871
+ namespace Indexed {
2868
2872
  /**
2869
2873
  * Provides an Seq.Indexed of the values provided.
2870
2874
  */
@@ -2878,11 +2882,9 @@ declare module Immutable {
2878
2882
  * Note: `Seq.Indexed` is a conversion function and not a class, and does
2879
2883
  * not use the `new` keyword during construction.
2880
2884
  */
2881
- export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
2882
- export function Indexed<T>(): Seq.Indexed<T>;
2883
- export function Indexed(): Seq.Indexed<unknown>;
2885
+ function Indexed<T>(collection: Iterable<T> | ArrayLike<T>): Seq.Indexed<T>;
2884
2886
 
2885
- export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
2887
+ interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
2886
2888
  /**
2887
2889
  * Deeply converts this Indexed Seq to equivalent native JavaScript Array.
2888
2890
  */
@@ -3016,9 +3018,11 @@ declare module Immutable {
3016
3018
  thirdCollection: Collection<unknown, V>
3017
3019
  ): Seq.Indexed<Z>;
3018
3020
  zipWith<Z>(
3019
- zipper: (...any: Array<unknown>) => Z,
3021
+ zipper: (...values: Array<unknown>) => Z,
3020
3022
  ...collections: Array<Collection<unknown, unknown>>
3021
3023
  ): Seq.Indexed<Z>;
3024
+
3025
+ [Symbol.iterator](): IterableIterator<T>;
3022
3026
  }
3023
3027
 
3024
3028
  /**
@@ -3027,7 +3031,7 @@ declare module Immutable {
3027
3031
  * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee
3028
3032
  * of value uniqueness as the concrete `Set`.
3029
3033
  */
3030
- export module Set {
3034
+ namespace Set {
3031
3035
  /**
3032
3036
  * Returns a Seq.Set of the provided values
3033
3037
  */
@@ -3040,11 +3044,9 @@ declare module Immutable {
3040
3044
  * Note: `Seq.Set` is a conversion function and not a class, and does not
3041
3045
  * use the `new` keyword during construction.
3042
3046
  */
3043
- export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
3044
- export function Set<T>(): Seq.Set<T>;
3045
- export function Set(): Seq.Set<unknown>;
3047
+ function Set<T>(collection: Iterable<T> | ArrayLike<T>): Seq.Set<T>;
3046
3048
 
3047
- export interface Set<T> extends Seq<T, T>, Collection.Set<T> {
3049
+ interface Set<T> extends Seq<T, T>, Collection.Set<T> {
3048
3050
  /**
3049
3051
  * Deeply converts this Set Seq to equivalent native JavaScript Array.
3050
3052
  */
@@ -3115,6 +3117,8 @@ declare module Immutable {
3115
3117
  predicate: (value: T, key: T, iter: this) => unknown,
3116
3118
  context?: unknown
3117
3119
  ): this;
3120
+
3121
+ [Symbol.iterator](): IterableIterator<T>;
3118
3122
  }
3119
3123
  }
3120
3124
 
@@ -3137,17 +3141,16 @@ declare module Immutable {
3137
3141
  * Note: `Seq` is a conversion function and not a class, and does not use the
3138
3142
  * `new` keyword during construction.
3139
3143
  */
3140
- export function Seq<S extends Seq<unknown, unknown>>(seq: S): S;
3141
- export function Seq<K, V>(
3142
- collection: Collection.Keyed<K, V>
3143
- ): Seq.Keyed<K, V>;
3144
- export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
3145
- export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
3146
- export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
3147
- export function Seq<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
3148
- export function Seq(): Seq<unknown, unknown>;
3149
-
3150
- export interface Seq<K, V> extends Collection<K, V> {
3144
+ function Seq<S extends Seq<unknown, unknown>>(seq: S): S;
3145
+ function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
3146
+ function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
3147
+ function Seq<T>(
3148
+ collection: Collection.Indexed<T> | Iterable<T> | ArrayLike<T>
3149
+ ): Seq.Indexed<T>;
3150
+ function Seq<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
3151
+ function Seq(): Seq<unknown, unknown>;
3152
+
3153
+ interface Seq<K, V> extends Collection<K, V> {
3151
3154
  /**
3152
3155
  * Some Seqs can describe their size lazily. When this is the case,
3153
3156
  * size will be an integer. Otherwise it will be undefined.
@@ -3275,7 +3278,7 @@ declare module Immutable {
3275
3278
  * Implementations should extend one of the subclasses, `Collection.Keyed`,
3276
3279
  * `Collection.Indexed`, or `Collection.Set`.
3277
3280
  */
3278
- export module Collection {
3281
+ namespace Collection {
3279
3282
  /**
3280
3283
  * @deprecated use `const { isKeyed } = require('immutable')`
3281
3284
  */
@@ -3311,7 +3314,7 @@ declare module Immutable {
3311
3314
  * tuple, in other words, `Collection#entries` is the default iterator for
3312
3315
  * Keyed Collections.
3313
3316
  */
3314
- export module Keyed {}
3317
+ namespace Keyed {}
3315
3318
 
3316
3319
  /**
3317
3320
  * Creates a Collection.Keyed
@@ -3322,14 +3325,10 @@ declare module Immutable {
3322
3325
  * Note: `Collection.Keyed` is a conversion function and not a class, and
3323
3326
  * does not use the `new` keyword during construction.
3324
3327
  */
3325
- export function Keyed<K, V>(
3326
- collection: Iterable<[K, V]>
3327
- ): Collection.Keyed<K, V>;
3328
- export function Keyed<V>(obj: {
3329
- [key: string]: V;
3330
- }): Collection.Keyed<string, V>;
3328
+ function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
3329
+ function Keyed<V>(obj: { [key: string]: V }): Collection.Keyed<string, V>;
3331
3330
 
3332
- export interface Keyed<K, V> extends Collection<K, V> {
3331
+ interface Keyed<K, V> extends Collection<K, V> {
3333
3332
  /**
3334
3333
  * Deeply converts this Keyed collection to equivalent native JavaScript Object.
3335
3334
  *
@@ -3431,11 +3430,15 @@ declare module Immutable {
3431
3430
  *
3432
3431
  * Note: `mapEntries()` always returns a new instance, even if it produced
3433
3432
  * the same entry at every step.
3434
- *
3433
+ *
3435
3434
  * If the mapper function returns `undefined`, then the entry will be filtered
3436
3435
  */
3437
3436
  mapEntries<KM, VM>(
3438
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined,
3437
+ mapper: (
3438
+ entry: [K, V],
3439
+ index: number,
3440
+ iter: this
3441
+ ) => [KM, VM] | undefined,
3439
3442
  context?: unknown
3440
3443
  ): Collection.Keyed<KM, VM>;
3441
3444
 
@@ -3483,7 +3486,7 @@ declare module Immutable {
3483
3486
  * preserve indices, using them as keys, convert to a Collection.Keyed by
3484
3487
  * calling `toKeyedSeq`.
3485
3488
  */
3486
- export module Indexed {}
3489
+ namespace Indexed {}
3487
3490
 
3488
3491
  /**
3489
3492
  * Creates a new Collection.Indexed.
@@ -3491,9 +3494,11 @@ declare module Immutable {
3491
3494
  * Note: `Collection.Indexed` is a conversion function and not a class, and
3492
3495
  * does not use the `new` keyword during construction.
3493
3496
  */
3494
- export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
3497
+ function Indexed<T>(
3498
+ collection: Iterable<T> | ArrayLike<T>
3499
+ ): Collection.Indexed<T>;
3495
3500
 
3496
- export interface Indexed<T> extends Collection<number, T> {
3501
+ interface Indexed<T> extends Collection<number, T> {
3497
3502
  /**
3498
3503
  * Deeply converts this Indexed collection to equivalent native JavaScript Array.
3499
3504
  */
@@ -3671,7 +3676,7 @@ declare module Immutable {
3671
3676
  thirdCollection: Collection<unknown, V>
3672
3677
  ): Collection.Indexed<Z>;
3673
3678
  zipWith<Z>(
3674
- zipper: (...any: Array<unknown>) => Z,
3679
+ zipper: (...values: Array<unknown>) => Z,
3675
3680
  ...collections: Array<Collection<unknown, unknown>>
3676
3681
  ): Collection.Indexed<Z>;
3677
3682
 
@@ -3780,7 +3785,7 @@ declare module Immutable {
3780
3785
  * )
3781
3786
  * ```
3782
3787
  */
3783
- export module Set {}
3788
+ namespace Set {}
3784
3789
 
3785
3790
  /**
3786
3791
  * Similar to `Collection()`, but always returns a Collection.Set.
@@ -3788,9 +3793,9 @@ declare module Immutable {
3788
3793
  * Note: `Collection.Set` is a factory function and not a class, and does
3789
3794
  * not use the `new` keyword during construction.
3790
3795
  */
3791
- export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
3796
+ function Set<T>(collection: Iterable<T> | ArrayLike<T>): Collection.Set<T>;
3792
3797
 
3793
- export interface Set<T> extends Collection<T, T> {
3798
+ interface Set<T> extends Collection<T, T> {
3794
3799
  /**
3795
3800
  * Deeply converts this Set collection to equivalent native JavaScript Array.
3796
3801
  */
@@ -3888,15 +3893,15 @@ declare module Immutable {
3888
3893
  * Note: `Collection` is a conversion function and not a class, and does not
3889
3894
  * use the `new` keyword during construction.
3890
3895
  */
3891
- export function Collection<I extends Collection<unknown, unknown>>(
3892
- collection: I
3893
- ): I;
3894
- export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
3895
- export function Collection<V>(obj: {
3896
+ function Collection<I extends Collection<unknown, unknown>>(collection: I): I;
3897
+ function Collection<T>(
3898
+ collection: Iterable<T> | ArrayLike<T>
3899
+ ): Collection.Indexed<T>;
3900
+ function Collection<V>(obj: {
3896
3901
  [key: string]: V;
3897
3902
  }): Collection.Keyed<string, V>;
3898
3903
 
3899
- export interface Collection<K, V> extends ValueObject {
3904
+ interface Collection<K, V> extends ValueObject {
3900
3905
  // Value equality
3901
3906
 
3902
3907
  /**
@@ -4200,6 +4205,8 @@ declare module Immutable {
4200
4205
  */
4201
4206
  entries(): IterableIterator<[K, V]>;
4202
4207
 
4208
+ [Symbol.iterator](): IterableIterator<unknown>;
4209
+
4203
4210
  // Collections (Seq)
4204
4211
 
4205
4212
  /**
@@ -4245,7 +4252,7 @@ declare module Immutable {
4245
4252
  *
4246
4253
  * @ignore
4247
4254
  */
4248
- map<M>(...args: never[]): unknown;
4255
+ map(...args: Array<never>): unknown;
4249
4256
 
4250
4257
  /**
4251
4258
  * Returns a new Collection of the same type with only the entries for which
@@ -4549,6 +4556,7 @@ declare module Immutable {
4549
4556
  * returns Collection<K, V>
4550
4557
  */
4551
4558
  flatten(depth?: number): Collection<unknown, unknown>;
4559
+ // tslint:disable-next-line unified-signatures
4552
4560
  flatten(shallow?: boolean): Collection<unknown, unknown>;
4553
4561
 
4554
4562
  /**
@@ -4825,7 +4833,7 @@ declare module Immutable {
4825
4833
  /**
4826
4834
  * The interface to fulfill to qualify as a Value Object.
4827
4835
  */
4828
- export interface ValueObject {
4836
+ interface ValueObject {
4829
4837
  /**
4830
4838
  * True if this and the other Collection have value equality, as defined
4831
4839
  * by `Immutable.is()`.
@@ -4872,6 +4880,10 @@ declare module Immutable {
4872
4880
  /**
4873
4881
  * Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
4874
4882
  *
4883
+ * `fromJS` will convert Arrays and [array-like objects][2] to a List, and
4884
+ * plain objects (without a custom prototype) to a Map. [Iterable objects][3]
4885
+ * may be converted to List, Map, or Set.
4886
+ *
4875
4887
  * If a `reviver` is optionally provided, it will be called with every
4876
4888
  * collection as a Seq (beginning with the most nested collections
4877
4889
  * and proceeding to the top-level collection itself), along with the key
@@ -4894,10 +4906,6 @@ declare module Immutable {
4894
4906
  * }
4895
4907
  * ```
4896
4908
  *
4897
- * `fromJS` is conservative in its conversion. It will only convert
4898
- * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
4899
- * prototype) to Map.
4900
- *
4901
4909
  * Accordingly, this example converts native JS data to OrderedMap and List:
4902
4910
  *
4903
4911
  * <!-- runkit:activate -->
@@ -4934,15 +4942,19 @@ declare module Immutable {
4934
4942
  *
4935
4943
  * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
4936
4944
  * "Using the reviver parameter"
4945
+ * [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#working_with_array-like_objects
4946
+ * "Working with array-like objects"
4947
+ * [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol
4948
+ * "The iterable protocol"
4937
4949
  */
4938
- export function fromJS(
4950
+ function fromJS(
4939
4951
  jsValue: unknown,
4940
4952
  reviver?: (
4941
4953
  key: string | number,
4942
4954
  sequence: Collection.Keyed<string, unknown> | Collection.Indexed<unknown>,
4943
4955
  path?: Array<string | number>
4944
4956
  ) => unknown
4945
- ): unknown;
4957
+ ): Collection<unknown, unknown>;
4946
4958
 
4947
4959
  /**
4948
4960
  * Value equality check with semantics similar to `Object.is`, but treats
@@ -4969,7 +4981,7 @@ declare module Immutable {
4969
4981
  * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
4970
4982
  * value, matching the behavior of ES6 Map key equality.
4971
4983
  */
4972
- export function is(first: unknown, second: unknown): boolean;
4984
+ function is(first: unknown, second: unknown): boolean;
4973
4985
 
4974
4986
  /**
4975
4987
  * The `hash()` function is an important part of how Immutable determines if
@@ -4993,7 +5005,7 @@ declare module Immutable {
4993
5005
  *
4994
5006
  * *New in Version 4.0*
4995
5007
  */
4996
- export function hash(value: unknown): number;
5008
+ function hash(value: unknown): number;
4997
5009
 
4998
5010
  /**
4999
5011
  * True if `maybeImmutable` is an Immutable Collection or Record.
@@ -5011,7 +5023,7 @@ declare module Immutable {
5011
5023
  * isImmutable(Map().asMutable()); // true
5012
5024
  * ```
5013
5025
  */
5014
- export function isImmutable(
5026
+ function isImmutable(
5015
5027
  maybeImmutable: unknown
5016
5028
  ): maybeImmutable is Collection<unknown, unknown>;
5017
5029
 
@@ -5028,7 +5040,7 @@ declare module Immutable {
5028
5040
  * isCollection(Stack()); // true
5029
5041
  * ```
5030
5042
  */
5031
- export function isCollection(
5043
+ function isCollection(
5032
5044
  maybeCollection: unknown
5033
5045
  ): maybeCollection is Collection<unknown, unknown>;
5034
5046
 
@@ -5045,7 +5057,7 @@ declare module Immutable {
5045
5057
  * isKeyed(Stack()); // false
5046
5058
  * ```
5047
5059
  */
5048
- export function isKeyed(
5060
+ function isKeyed(
5049
5061
  maybeKeyed: unknown
5050
5062
  ): maybeKeyed is Collection.Keyed<unknown, unknown>;
5051
5063
 
@@ -5063,7 +5075,7 @@ declare module Immutable {
5063
5075
  * isIndexed(Set()); // false
5064
5076
  * ```
5065
5077
  */
5066
- export function isIndexed(
5078
+ function isIndexed(
5067
5079
  maybeIndexed: unknown
5068
5080
  ): maybeIndexed is Collection.Indexed<unknown>;
5069
5081
 
@@ -5081,7 +5093,7 @@ declare module Immutable {
5081
5093
  * isAssociative(Set()); // false
5082
5094
  * ```
5083
5095
  */
5084
- export function isAssociative(
5096
+ function isAssociative(
5085
5097
  maybeAssociative: unknown
5086
5098
  ): maybeAssociative is
5087
5099
  | Collection.Keyed<unknown, unknown>
@@ -5102,7 +5114,7 @@ declare module Immutable {
5102
5114
  * isOrdered(Set()); // false
5103
5115
  * ```
5104
5116
  */
5105
- export function isOrdered(maybeOrdered: unknown): boolean;
5117
+ function isOrdered(maybeOrdered: unknown): boolean;
5106
5118
 
5107
5119
  /**
5108
5120
  * True if `maybeValue` is a JavaScript Object which has *both* `equals()`
@@ -5111,12 +5123,12 @@ declare module Immutable {
5111
5123
  * Any two instances of *value objects* can be compared for value equality with
5112
5124
  * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
5113
5125
  */
5114
- export function isValueObject(maybeValue: unknown): maybeValue is ValueObject;
5126
+ function isValueObject(maybeValue: unknown): maybeValue is ValueObject;
5115
5127
 
5116
5128
  /**
5117
5129
  * True if `maybeSeq` is a Seq.
5118
5130
  */
5119
- export function isSeq(
5131
+ function isSeq(
5120
5132
  maybeSeq: unknown
5121
5133
  ): maybeSeq is
5122
5134
  | Seq.Indexed<unknown>
@@ -5126,45 +5138,45 @@ declare module Immutable {
5126
5138
  /**
5127
5139
  * True if `maybeList` is a List.
5128
5140
  */
5129
- export function isList(maybeList: unknown): maybeList is List<unknown>;
5141
+ function isList(maybeList: unknown): maybeList is List<unknown>;
5130
5142
 
5131
5143
  /**
5132
5144
  * True if `maybeMap` is a Map.
5133
5145
  *
5134
5146
  * Also true for OrderedMaps.
5135
5147
  */
5136
- export function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
5148
+ function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
5137
5149
 
5138
5150
  /**
5139
5151
  * True if `maybeOrderedMap` is an OrderedMap.
5140
5152
  */
5141
- export function isOrderedMap(
5153
+ function isOrderedMap(
5142
5154
  maybeOrderedMap: unknown
5143
5155
  ): maybeOrderedMap is OrderedMap<unknown, unknown>;
5144
5156
 
5145
5157
  /**
5146
5158
  * True if `maybeStack` is a Stack.
5147
5159
  */
5148
- export function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
5160
+ function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
5149
5161
 
5150
5162
  /**
5151
5163
  * True if `maybeSet` is a Set.
5152
5164
  *
5153
5165
  * Also true for OrderedSets.
5154
5166
  */
5155
- export function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
5167
+ function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
5156
5168
 
5157
5169
  /**
5158
5170
  * True if `maybeOrderedSet` is an OrderedSet.
5159
5171
  */
5160
- export function isOrderedSet(
5172
+ function isOrderedSet(
5161
5173
  maybeOrderedSet: unknown
5162
5174
  ): maybeOrderedSet is OrderedSet<unknown>;
5163
5175
 
5164
5176
  /**
5165
5177
  * True if `maybeRecord` is a Record.
5166
5178
  */
5167
- export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
5179
+ function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
5168
5180
 
5169
5181
  /**
5170
5182
  * Returns the value within the provided collection associated with the
@@ -5181,36 +5193,30 @@ declare module Immutable {
5181
5193
  * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet'
5182
5194
  * ```
5183
5195
  */
5184
- export function get<K, V>(
5185
- collection: Collection<K, V>,
5186
- key: K
5187
- ): V | undefined;
5188
- export function get<K, V, NSV>(
5196
+ function get<K, V>(collection: Collection<K, V>, key: K): V | undefined;
5197
+ function get<K, V, NSV>(
5189
5198
  collection: Collection<K, V>,
5190
5199
  key: K,
5191
5200
  notSetValue: NSV
5192
5201
  ): V | NSV;
5193
- export function get<TProps, K extends keyof TProps>(
5202
+ function get<TProps extends object, K extends keyof TProps>(
5194
5203
  record: Record<TProps>,
5195
5204
  key: K,
5196
5205
  notSetValue: unknown
5197
5206
  ): TProps[K];
5198
- export function get<V>(collection: Array<V>, key: number): V | undefined;
5199
- export function get<V, NSV>(
5207
+ function get<V>(collection: Array<V>, key: number): V | undefined;
5208
+ function get<V, NSV>(
5200
5209
  collection: Array<V>,
5201
5210
  key: number,
5202
5211
  notSetValue: NSV
5203
5212
  ): V | NSV;
5204
- export function get<C extends Object, K extends keyof C>(
5213
+ function get<C extends object, K extends keyof C>(
5205
5214
  object: C,
5206
5215
  key: K,
5207
5216
  notSetValue: unknown
5208
5217
  ): C[K];
5209
- export function get<V>(
5210
- collection: { [key: string]: V },
5211
- key: string
5212
- ): V | undefined;
5213
- export function get<V, NSV>(
5218
+ function get<V>(collection: { [key: string]: V }, key: string): V | undefined;
5219
+ function get<V, NSV>(
5214
5220
  collection: { [key: string]: V },
5215
5221
  key: string,
5216
5222
  notSetValue: NSV
@@ -5232,7 +5238,7 @@ declare module Immutable {
5232
5238
  * has({ x: 123, y: 456 }, 'z') // false
5233
5239
  * ```
5234
5240
  */
5235
- export function has(collection: Object, key: unknown): boolean;
5241
+ function has(collection: object, key: unknown): boolean;
5236
5242
 
5237
5243
  /**
5238
5244
  * Returns a copy of the collection with the value at key removed.
@@ -5252,24 +5258,21 @@ declare module Immutable {
5252
5258
  * console.log(originalObject) // { x: 123, y: 456 }
5253
5259
  * ```
5254
5260
  */
5255
- export function remove<K, C extends Collection<K, unknown>>(
5261
+ function remove<K, C extends Collection<K, unknown>>(
5256
5262
  collection: C,
5257
5263
  key: K
5258
5264
  ): C;
5259
- export function remove<
5260
- TProps,
5265
+ function remove<
5266
+ TProps extends object,
5261
5267
  C extends Record<TProps>,
5262
5268
  K extends keyof TProps
5263
5269
  >(collection: C, key: K): C;
5264
- export function remove<C extends Array<unknown>>(
5270
+ function remove<C extends Array<unknown>>(collection: C, key: number): C;
5271
+ function remove<C, K extends keyof C>(collection: C, key: K): C;
5272
+ function remove<C extends { [key: string]: unknown }, K extends keyof C>(
5265
5273
  collection: C,
5266
- key: number
5274
+ key: K
5267
5275
  ): C;
5268
- export function remove<C, K extends keyof C>(collection: C, key: K): C;
5269
- export function remove<
5270
- C extends { [key: string]: unknown },
5271
- K extends keyof C
5272
- >(collection: C, key: K): C;
5273
5276
 
5274
5277
  /**
5275
5278
  * Returns a copy of the collection with the value at key set to the provided
@@ -5290,23 +5293,19 @@ declare module Immutable {
5290
5293
  * console.log(originalObject) // { x: 123, y: 456 }
5291
5294
  * ```
5292
5295
  */
5293
- export function set<K, V, C extends Collection<K, V>>(
5296
+ function set<K, V, C extends Collection<K, V>>(
5294
5297
  collection: C,
5295
5298
  key: K,
5296
5299
  value: V
5297
5300
  ): C;
5298
- export function set<TProps, C extends Record<TProps>, K extends keyof TProps>(
5299
- record: C,
5300
- key: K,
5301
- value: TProps[K]
5302
- ): C;
5303
- export function set<V, C extends Array<V>>(
5304
- collection: C,
5305
- key: number,
5306
- value: V
5307
- ): C;
5308
- export function set<C, K extends keyof C>(object: C, key: K, value: C[K]): C;
5309
- export function set<V, C extends { [key: string]: V }>(
5301
+ function set<
5302
+ TProps extends object,
5303
+ C extends Record<TProps>,
5304
+ K extends keyof TProps
5305
+ >(record: C, key: K, value: TProps[K]): C;
5306
+ function set<V, C extends Array<V>>(collection: C, key: number, value: V): C;
5307
+ function set<C, K extends keyof C>(object: C, key: K, value: C[K]): C;
5308
+ function set<V, C extends { [key: string]: V }>(
5310
5309
  collection: C,
5311
5310
  key: string,
5312
5311
  value: V
@@ -5331,24 +5330,24 @@ declare module Immutable {
5331
5330
  * console.log(originalObject) // { x: 123, y: 456 }
5332
5331
  * ```
5333
5332
  */
5334
- export function update<K, V, C extends Collection<K, V>>(
5333
+ function update<K, V, C extends Collection<K, V>>(
5335
5334
  collection: C,
5336
5335
  key: K,
5337
5336
  updater: (value: V | undefined) => V
5338
5337
  ): C;
5339
- export function update<K, V, C extends Collection<K, V>, NSV>(
5338
+ function update<K, V, C extends Collection<K, V>, NSV>(
5340
5339
  collection: C,
5341
5340
  key: K,
5342
5341
  notSetValue: NSV,
5343
5342
  updater: (value: V | NSV) => V
5344
5343
  ): C;
5345
- export function update<
5346
- TProps,
5344
+ function update<
5345
+ TProps extends object,
5347
5346
  C extends Record<TProps>,
5348
5347
  K extends keyof TProps
5349
5348
  >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C;
5350
- export function update<
5351
- TProps,
5349
+ function update<
5350
+ TProps extends object,
5352
5351
  C extends Record<TProps>,
5353
5352
  K extends keyof TProps,
5354
5353
  NSV
@@ -5358,39 +5357,34 @@ declare module Immutable {
5358
5357
  notSetValue: NSV,
5359
5358
  updater: (value: TProps[K] | NSV) => TProps[K]
5360
5359
  ): C;
5361
- export function update<V>(
5360
+ function update<V>(
5362
5361
  collection: Array<V>,
5363
5362
  key: number,
5364
5363
  updater: (value: V) => V
5365
5364
  ): Array<V>;
5366
- export function update<V, NSV>(
5365
+ function update<V, NSV>(
5367
5366
  collection: Array<V>,
5368
5367
  key: number,
5369
5368
  notSetValue: NSV,
5370
5369
  updater: (value: V | NSV) => V
5371
5370
  ): Array<V>;
5372
- export function update<C, K extends keyof C>(
5371
+ function update<C, K extends keyof C>(
5373
5372
  object: C,
5374
5373
  key: K,
5375
5374
  updater: (value: C[K]) => C[K]
5376
5375
  ): C;
5377
- export function update<C, K extends keyof C, NSV>(
5376
+ function update<C, K extends keyof C, NSV>(
5378
5377
  object: C,
5379
5378
  key: K,
5380
5379
  notSetValue: NSV,
5381
5380
  updater: (value: C[K] | NSV) => C[K]
5382
5381
  ): C;
5383
- export function update<V, C extends { [key: string]: V }, K extends keyof C>(
5382
+ function update<V, C extends { [key: string]: V }, K extends keyof C>(
5384
5383
  collection: C,
5385
5384
  key: K,
5386
5385
  updater: (value: V) => V
5387
5386
  ): { [key: string]: V };
5388
- export function update<
5389
- V,
5390
- C extends { [key: string]: V },
5391
- K extends keyof C,
5392
- NSV
5393
- >(
5387
+ function update<V, C extends { [key: string]: V }, K extends keyof C, NSV>(
5394
5388
  collection: C,
5395
5389
  key: K,
5396
5390
  notSetValue: NSV,
@@ -5411,10 +5405,10 @@ declare module Immutable {
5411
5405
  * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
5412
5406
  * ```
5413
5407
  */
5414
- export function getIn(
5408
+ function getIn(
5415
5409
  collection: unknown,
5416
5410
  keyPath: Iterable<unknown>,
5417
- notSetValue: unknown
5411
+ notSetValue?: unknown
5418
5412
  ): unknown;
5419
5413
 
5420
5414
  /**
@@ -5430,10 +5424,7 @@ declare module Immutable {
5430
5424
  * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
5431
5425
  * ```
5432
5426
  */
5433
- export function hasIn(
5434
- collection: unknown,
5435
- keyPath: Iterable<unknown>
5436
- ): boolean;
5427
+ function hasIn(collection: unknown, keyPath: Iterable<unknown>): boolean;
5437
5428
 
5438
5429
  /**
5439
5430
  * Returns a copy of the collection with the value at the key path removed.
@@ -5449,7 +5440,7 @@ declare module Immutable {
5449
5440
  * console.log(original) // { x: { y: { z: 123 }}}
5450
5441
  * ```
5451
5442
  */
5452
- export function removeIn<C>(collection: C, keyPath: Iterable<unknown>): C;
5443
+ function removeIn<C>(collection: C, keyPath: Iterable<unknown>): C;
5453
5444
 
5454
5445
  /**
5455
5446
  * Returns a copy of the collection with the value at the key path set to the
@@ -5466,7 +5457,7 @@ declare module Immutable {
5466
5457
  * console.log(original) // { x: { y: { z: 123 }}}
5467
5458
  * ```
5468
5459
  */
5469
- export function setIn<C>(
5460
+ function setIn<C>(
5470
5461
  collection: C,
5471
5462
  keyPath: Iterable<unknown>,
5472
5463
  value: unknown
@@ -5487,12 +5478,12 @@ declare module Immutable {
5487
5478
  * console.log(original) // { x: { y: { z: 123 }}}
5488
5479
  * ```
5489
5480
  */
5490
- export function updateIn<C>(
5481
+ function updateIn<C>(
5491
5482
  collection: C,
5492
5483
  keyPath: Iterable<unknown>,
5493
5484
  updater: (value: unknown) => unknown
5494
5485
  ): C;
5495
- export function updateIn<C>(
5486
+ function updateIn<C>(
5496
5487
  collection: C,
5497
5488
  keyPath: Iterable<unknown>,
5498
5489
  notSetValue: unknown,
@@ -5513,7 +5504,7 @@ declare module Immutable {
5513
5504
  * console.log(original) // { x: 123, y: 456 }
5514
5505
  * ```
5515
5506
  */
5516
- export function merge<C>(
5507
+ function merge<C>(
5517
5508
  collection: C,
5518
5509
  ...collections: Array<
5519
5510
  | Iterable<unknown>
@@ -5541,7 +5532,7 @@ declare module Immutable {
5541
5532
  * console.log(original) // { x: 123, y: 456 }
5542
5533
  * ```
5543
5534
  */
5544
- export function mergeWith<C>(
5535
+ function mergeWith<C>(
5545
5536
  merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
5546
5537
  collection: C,
5547
5538
  ...collections: Array<
@@ -5552,8 +5543,18 @@ declare module Immutable {
5552
5543
  ): C;
5553
5544
 
5554
5545
  /**
5555
- * Returns a copy of the collection with the remaining collections merged in
5556
- * deeply (recursively).
5546
+ * Like `merge()`, but when two compatible collections are encountered with
5547
+ * the same key, it merges them as well, recursing deeply through the nested
5548
+ * data. Two collections are considered to be compatible (and thus will be
5549
+ * merged together) if they both fall into one of three categories: keyed
5550
+ * (e.g., `Map`s, `Record`s, and objects), indexed (e.g., `List`s and
5551
+ * arrays), or set-like (e.g., `Set`s). If they fall into separate
5552
+ * categories, `mergeDeep` will replace the existing collection with the
5553
+ * collection being merged in. This behavior can be customized by using
5554
+ * `mergeDeepWith()`.
5555
+ *
5556
+ * Note: Indexed and set-like collections are merged using
5557
+ * `concat()`/`union()` and therefore do not recurse.
5557
5558
  *
5558
5559
  * A functional alternative to `collection.mergeDeep()` which will also work
5559
5560
  * with plain Objects and Arrays.
@@ -5566,7 +5567,7 @@ declare module Immutable {
5566
5567
  * console.log(original) // { x: { y: 123 }}
5567
5568
  * ```
5568
5569
  */
5569
- export function mergeDeep<C>(
5570
+ function mergeDeep<C>(
5570
5571
  collection: C,
5571
5572
  ...collections: Array<
5572
5573
  | Iterable<unknown>
@@ -5576,9 +5577,10 @@ declare module Immutable {
5576
5577
  ): C;
5577
5578
 
5578
5579
  /**
5579
- * Returns a copy of the collection with the remaining collections merged in
5580
- * deeply (recursively), calling the `merger` function whenever an existing
5581
- * value is encountered.
5580
+ * Like `mergeDeep()`, but when two non-collections or incompatible
5581
+ * collections are encountered at the same key, it uses the `merger` function
5582
+ * to determine the resulting value. Collections are considered incompatible
5583
+ * if they fall into separate categories between keyed, indexed, and set-like.
5582
5584
  *
5583
5585
  * A functional alternative to `collection.mergeDeepWith()` which will also
5584
5586
  * work with plain Objects and Arrays.
@@ -5595,7 +5597,7 @@ declare module Immutable {
5595
5597
  * console.log(original) // { x: { y: 123 }}
5596
5598
  * ```
5597
5599
  */
5598
- export function mergeDeepWith<C>(
5600
+ function mergeDeepWith<C>(
5599
5601
  merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
5600
5602
  collection: C,
5601
5603
  ...collections: Array<
@@ -5606,6 +5608,26 @@ declare module Immutable {
5606
5608
  ): C;
5607
5609
  }
5608
5610
 
5609
- declare module 'immutable' {
5610
- export = Immutable;
5611
- }
5611
+ /**
5612
+ * Defines the main export of the immutable module to be the Immutable namespace
5613
+ * This supports many common module import patterns:
5614
+ *
5615
+ * const Immutable = require("immutable");
5616
+ * const { List } = require("immutable");
5617
+ * import Immutable from "immutable";
5618
+ * import * as Immutable from "immutable";
5619
+ * import { List } from "immutable";
5620
+ *
5621
+ */
5622
+ export = Immutable;
5623
+
5624
+ /**
5625
+ * A global "Immutable" namespace used by UMD modules which allows the use of
5626
+ * the full Immutable API.
5627
+ *
5628
+ * If using Immutable as an imported module, prefer using:
5629
+ *
5630
+ * import Immutable from 'immutable'
5631
+ *
5632
+ */
5633
+ export as namespace Immutable;