immutable 4.0.0-rc.8 → 4.1.0

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.
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2014-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
1
  /**
9
2
  * Immutable data encourages pure functions (data-in, data-out) and lends itself
10
3
  * to much simpler application development and enabling techniques from
@@ -73,14 +66,14 @@
73
66
  * `getIn` which expects an `Iterable` path:
74
67
  *
75
68
  * ```
76
- * getIn(path: Iterable<string | number>): any
69
+ * getIn(path: Iterable<string | number>): unknown
77
70
  * ```
78
71
  *
79
72
  * To use this method, we could pass an array: `data.getIn([ "key", 2 ])`.
80
73
  *
81
74
  *
82
75
  * Note: All examples are presented in the modern [ES2015][] version of
83
- * JavaScript. To run in older browsers, they need to be translated to ES3.
76
+ * JavaScript. Use tools like Babel to support older browsers.
84
77
  *
85
78
  * For example:
86
79
  *
@@ -92,294 +85,12 @@
92
85
  * ```
93
86
  *
94
87
  * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
95
- * [TypeScript]: http://www.typescriptlang.org/
88
+ * [TypeScript]: https://www.typescriptlang.org/
96
89
  * [Flow]: https://flowtype.org/
97
90
  * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
98
91
  */
99
92
 
100
- declare module Immutable {
101
-
102
- /**
103
- * Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
104
- *
105
- * If a `reviver` is optionally provided, it will be called with every
106
- * collection as a Seq (beginning with the most nested collections
107
- * and proceeding to the top-level collection itself), along with the key
108
- * refering to each collection and the parent JS object provided as `this`.
109
- * For the top level, object, the key will be `""`. This `reviver` is expected
110
- * to return a new Immutable Collection, allowing for custom conversions from
111
- * deep JS objects. Finally, a `path` is provided which is the sequence of
112
- * keys to this value from the starting value.
113
- *
114
- * `reviver` acts similarly to the [same parameter in `JSON.parse`][1].
115
- *
116
- * If `reviver` is not provided, the default behavior will convert Objects
117
- * into Maps and Arrays into Lists like so:
118
- *
119
- * <!-- runkit:activate -->
120
- * ```js
121
- * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8')
122
- * function (key, value) {
123
- * return isKeyed(value) ? value.Map() : value.toList()
124
- * }
125
- * ```
126
- *
127
- * `fromJS` is conservative in its conversion. It will only convert
128
- * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom
129
- * prototype) to Map.
130
- *
131
- * Accordingly, this example converts native JS data to OrderedMap and List:
132
- *
133
- * <!-- runkit:activate -->
134
- * ```js
135
- * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8')
136
- * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) {
137
- * console.log(key, value, path)
138
- * return isKeyed(value) ? value.toOrderedMap() : value.toList()
139
- * })
140
- *
141
- * > "b", [ 10, 20, 30 ], [ "a", "b" ]
142
- * > "a", {b: [10, 20, 30]}, [ "a" ]
143
- * > "", {a: {b: [10, 20, 30]}, c: 40}, []
144
- * ```
145
- *
146
- * Keep in mind, when using JS objects to construct Immutable Maps, that
147
- * JavaScript Object properties are always strings, even if written in a
148
- * quote-less shorthand, while Immutable Maps accept keys of any type.
149
- *
150
- * <!-- runkit:activate -->
151
- * ```js
152
- * const { Map } = require('immutable@4.0.0-rc.8')
153
- * let obj = { 1: "one" };
154
- * Object.keys(obj); // [ "1" ]
155
- * assert.equal(obj["1"], obj[1]); // "one" === "one"
156
- *
157
- * let map = Map(obj);
158
- * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined
159
- * ```
160
- *
161
- * Property access for JavaScript Objects first converts the key to a string,
162
- * but since Immutable Map keys can be of any type the argument to `get()` is
163
- * not altered.
164
- *
165
- * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
166
- * "Using the reviver parameter"
167
- */
168
- export function fromJS(
169
- jsValue: any,
170
- reviver?: (
171
- key: string | number,
172
- sequence: Collection.Keyed<string, any> | Collection.Indexed<any>,
173
- path?: Array<string | number>
174
- ) => any
175
- ): any;
176
-
177
-
178
- /**
179
- * Value equality check with semantics similar to `Object.is`, but treats
180
- * Immutable `Collection`s as values, equal if the second `Collection` includes
181
- * equivalent values.
182
- *
183
- * It's used throughout Immutable when checking for equality, including `Map`
184
- * key equality and `Set` membership.
185
- *
186
- * <!-- runkit:activate -->
187
- * ```js
188
- * const { Map, is } = require('immutable@4.0.0-rc.8')
189
- * const map1 = Map({ a: 1, b: 1, c: 1 })
190
- * const map2 = Map({ a: 1, b: 1, c: 1 })
191
- * assert.equal(map1 !== map2, true)
192
- * assert.equal(Object.is(map1, map2), false)
193
- * assert.equal(is(map1, map2), true)
194
- * ```
195
- *
196
- * `is()` compares primitive types like strings and numbers, Immutable.js
197
- * collections like `Map` and `List`, but also any custom object which
198
- * implements `ValueObject` by providing `equals()` and `hashCode()` methods.
199
- *
200
- * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
201
- * value, matching the behavior of ES6 Map key equality.
202
- */
203
- export function is(first: any, second: any): boolean;
204
-
205
-
206
- /**
207
- * The `hash()` function is an important part of how Immutable determines if
208
- * two values are equivalent and is used to determine how to store those
209
- * values. Provided with any value, `hash()` will return a 31-bit integer.
210
- *
211
- * When designing Objects which may be equal, it's important than when a
212
- * `.equals()` method returns true, that both values `.hashCode()` method
213
- * return the same value. `hash()` may be used to produce those values.
214
- *
215
- * For non-Immutable Objects that do not provide a `.hashCode()` functions
216
- * (including plain Objects, plain Arrays, Date objects, etc), a unique hash
217
- * value will be created for each *instance*. That is, the create hash
218
- * represents referential equality, and not value equality for Objects. This
219
- * ensures that if that Object is mutated over time that its hash code will
220
- * remain consistent, allowing Objects to be used as keys and values in
221
- * Immutable.js collections.
222
- *
223
- * Note that `hash()` attempts to balance between speed and avoiding
224
- * collisions, however it makes no attempt to produce secure hashes.
225
- *
226
- * *New in Version 4.0*
227
- */
228
- export function hash(value: any): number;
229
-
230
- /**
231
- * True if `maybeImmutable` is an Immutable Collection or Record.
232
- *
233
- * Note: Still returns true even if the collections is within a `withMutations()`.
234
- *
235
- * <!-- runkit:activate -->
236
- * ```js
237
- * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8');
238
- * isImmutable([]); // false
239
- * isImmutable({}); // false
240
- * isImmutable(Map()); // true
241
- * isImmutable(List()); // true
242
- * isImmutable(Stack()); // true
243
- * isImmutable(Map().asMutable()); // true
244
- * ```
245
- */
246
- export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
247
-
248
- /**
249
- * True if `maybeCollection` is a Collection, or any of its subclasses.
250
- *
251
- * <!-- runkit:activate -->
252
- * ```js
253
- * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8');
254
- * isCollection([]); // false
255
- * isCollection({}); // false
256
- * isCollection(Map()); // true
257
- * isCollection(List()); // true
258
- * isCollection(Stack()); // true
259
- * ```
260
- */
261
- export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
262
-
263
- /**
264
- * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
265
- *
266
- * <!-- runkit:activate -->
267
- * ```js
268
- * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8');
269
- * isKeyed([]); // false
270
- * isKeyed({}); // false
271
- * isKeyed(Map()); // true
272
- * isKeyed(List()); // false
273
- * isKeyed(Stack()); // false
274
- * ```
275
- */
276
- export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
277
-
278
- /**
279
- * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
280
- *
281
- * <!-- runkit:activate -->
282
- * ```js
283
- * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8');
284
- * isIndexed([]); // false
285
- * isIndexed({}); // false
286
- * isIndexed(Map()); // false
287
- * isIndexed(List()); // true
288
- * isIndexed(Stack()); // true
289
- * isIndexed(Set()); // false
290
- * ```
291
- */
292
- export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
293
-
294
- /**
295
- * True if `maybeAssociative` is either a Keyed or Indexed Collection.
296
- *
297
- * <!-- runkit:activate -->
298
- * ```js
299
- * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8');
300
- * isAssociative([]); // false
301
- * isAssociative({}); // false
302
- * isAssociative(Map()); // true
303
- * isAssociative(List()); // true
304
- * isAssociative(Stack()); // true
305
- * isAssociative(Set()); // false
306
- * ```
307
- */
308
- export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
309
-
310
- /**
311
- * True if `maybeOrdered` is a Collection where iteration order is well
312
- * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet.
313
- *
314
- * <!-- runkit:activate -->
315
- * ```js
316
- * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8');
317
- * isOrdered([]); // false
318
- * isOrdered({}); // false
319
- * isOrdered(Map()); // false
320
- * isOrdered(OrderedMap()); // true
321
- * isOrdered(List()); // true
322
- * isOrdered(Set()); // false
323
- * ```
324
- */
325
- export function isOrdered(maybeOrdered: any): boolean;
326
-
327
- /**
328
- * True if `maybeValue` is a JavaScript Object which has *both* `equals()`
329
- * and `hashCode()` methods.
330
- *
331
- * Any two instances of *value objects* can be compared for value equality with
332
- * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
333
- */
334
- export function isValueObject(maybeValue: any): maybeValue is ValueObject;
335
-
336
- /**
337
- * The interface to fulfill to qualify as a Value Object.
338
- */
339
- export interface ValueObject {
340
- /**
341
- * True if this and the other Collection have value equality, as defined
342
- * by `Immutable.is()`.
343
- *
344
- * Note: This is equivalent to `Immutable.is(this, other)`, but provided to
345
- * allow for chained expressions.
346
- */
347
- equals(other: any): boolean;
348
-
349
- /**
350
- * Computes and returns the hashed identity for this Collection.
351
- *
352
- * The `hashCode` of a Collection is used to determine potential equality,
353
- * and is used when adding this to a `Set` or as a key in a `Map`, enabling
354
- * lookup via a different instance.
355
- *
356
- * <!-- runkit:activate -->
357
- * ```js
358
- * const { List, Set } = require('immutable@4.0.0-rc.8');
359
- * const a = List([ 1, 2, 3 ]);
360
- * const b = List([ 1, 2, 3 ]);
361
- * assert.notStrictEqual(a, b); // different instances
362
- * const set = Set([ a ]);
363
- * assert.equal(set.has(b), true);
364
- * ```
365
- *
366
- * Note: hashCode() MUST return a Uint32 number. The easiest way to
367
- * guarantee this is to return `myHash | 0` from a custom implementation.
368
- *
369
- * If two values have the same `hashCode`, they are [not guaranteed
370
- * to be equal][Hash Collision]. If two values have different `hashCode`s,
371
- * they must not be equal.
372
- *
373
- * Note: `hashCode()` is not guaranteed to always be called before
374
- * `equals()`. Most but not all Immutable.js collections use hash codes to
375
- * organize their internal data structures, while all Immutable.js
376
- * collections use equality during lookups.
377
- *
378
- * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science)
379
- */
380
- hashCode(): number;
381
- }
382
-
93
+ declare namespace Immutable {
383
94
  /**
384
95
  * Lists are ordered indexed dense collections, much like a JavaScript
385
96
  * Array.
@@ -394,26 +105,25 @@ declare module Immutable {
394
105
  * "unset" index and an index set to `undefined`. `List#forEach` visits all
395
106
  * indices from 0 to size, regardless of whether they were explicitly defined.
396
107
  */
397
- export module List {
398
-
108
+ namespace List {
399
109
  /**
400
110
  * True if the provided value is a List
401
111
  *
402
112
  * <!-- runkit:activate -->
403
113
  * ```js
404
- * const { List } = require('immutable@4.0.0-rc.8');
114
+ * const { List } = require('immutable');
405
115
  * List.isList([]); // false
406
116
  * List.isList(List()); // true
407
117
  * ```
408
118
  */
409
- function isList(maybeList: any): maybeList is List<any>;
119
+ function isList(maybeList: unknown): maybeList is List<unknown>;
410
120
 
411
121
  /**
412
122
  * Creates a new List containing `values`.
413
123
  *
414
124
  * <!-- runkit:activate -->
415
125
  * ```js
416
- * const { List } = require('immutable@4.0.0-rc.8');
126
+ * const { List } = require('immutable');
417
127
  * List.of(1, 2, 3, 4)
418
128
  * // List [ 1, 2, 3, 4 ]
419
129
  * ```
@@ -422,7 +132,7 @@ declare module Immutable {
422
132
  *
423
133
  * <!-- runkit:activate -->
424
134
  * ```js
425
- * const { List } = require('immutable@4.0.0-rc.8');
135
+ * const { List } = require('immutable');
426
136
  * List.of({x:1}, 2, [3], 4)
427
137
  * // List [ { x: 1 }, 2, [ 3 ], 4 ]
428
138
  * ```
@@ -434,9 +144,12 @@ declare module Immutable {
434
144
  * Create a new immutable List containing the values of the provided
435
145
  * collection-like.
436
146
  *
147
+ * Note: `List` is a factory function and not a class, and does not use the
148
+ * `new` keyword during construction.
149
+ *
437
150
  * <!-- runkit:activate -->
438
151
  * ```js
439
- * const { List, Set } = require('immutable@4.0.0-rc.8')
152
+ * const { List, Set } = require('immutable')
440
153
  *
441
154
  * const emptyList = List()
442
155
  * // List []
@@ -458,12 +171,9 @@ declare module Immutable {
458
171
  * listFromPlainSet.equals(listFromPlainArray) // true
459
172
  * ```
460
173
  */
461
- export function List(): List<any>;
462
- export function List<T>(): List<T>;
463
- export function List<T>(collection: Iterable<T>): List<T>;
464
-
465
- export interface List<T> extends Collection.Indexed<T> {
174
+ function List<T>(collection?: Iterable<T> | ArrayLike<T>): List<T>;
466
175
 
176
+ interface List<T> extends Collection.Indexed<T> {
467
177
  /**
468
178
  * The number of items in this List.
469
179
  */
@@ -482,7 +192,7 @@ declare module Immutable {
482
192
  * enough to include the `index`.
483
193
  *
484
194
  * <!-- runkit:activate
485
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
195
+ * { "preamble": "const { List } = require('immutable');" }
486
196
  * -->
487
197
  * ```js
488
198
  * const originalList = List([ 0 ]);
@@ -515,7 +225,7 @@ declare module Immutable {
515
225
  * Note: `delete` cannot be safely used in IE8
516
226
  *
517
227
  * <!-- runkit:activate
518
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
228
+ * { "preamble": "const { List } = require('immutable');" }
519
229
  * -->
520
230
  * ```js
521
231
  * List([ 0, 1, 2, 3, 4 ]).delete(0);
@@ -539,7 +249,7 @@ declare module Immutable {
539
249
  * This is synonymous with `list.splice(index, 0, value)`.
540
250
  *
541
251
  * <!-- runkit:activate
542
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
252
+ * { "preamble": "const { List } = require('immutable');" }
543
253
  * -->
544
254
  * ```js
545
255
  * List([ 0, 1, 2, 3, 4 ]).insert(6, 5)
@@ -557,7 +267,7 @@ declare module Immutable {
557
267
  * Returns a new List with 0 size and no values in constant time.
558
268
  *
559
269
  * <!-- runkit:activate
560
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
270
+ * { "preamble": "const { List } = require('immutable');" }
561
271
  * -->
562
272
  * ```js
563
273
  * List([ 1, 2, 3, 4 ]).clear()
@@ -573,7 +283,7 @@ declare module Immutable {
573
283
  * List's `size`.
574
284
  *
575
285
  * <!-- runkit:activate
576
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
286
+ * { "preamble": "const { List } = require('immutable');" }
577
287
  * -->
578
288
  * ```js
579
289
  * List([ 1, 2, 3, 4 ]).push(5)
@@ -606,7 +316,7 @@ declare module Immutable {
606
316
  * values ahead to higher indices.
607
317
  *
608
318
  * <!-- runkit:activate
609
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
319
+ * { "preamble": "const { List } = require('immutable');" }
610
320
  * -->
611
321
  * ```js
612
322
  * List([ 2, 3, 4]).unshift(1);
@@ -626,7 +336,7 @@ declare module Immutable {
626
336
  * value in this List.
627
337
  *
628
338
  * <!-- runkit:activate
629
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
339
+ * { "preamble": "const { List } = require('immutable');" }
630
340
  * -->
631
341
  * ```js
632
342
  * List([ 0, 1, 2, 3, 4 ]).shift();
@@ -647,7 +357,7 @@ declare module Immutable {
647
357
  * List. `v.update(-1)` updates the last item in the List.
648
358
  *
649
359
  * <!-- runkit:activate
650
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
360
+ * { "preamble": "const { List } = require('immutable');" }
651
361
  * -->
652
362
  * ```js
653
363
  * const list = List([ 'a', 'b', 'c' ])
@@ -661,7 +371,7 @@ declare module Immutable {
661
371
  * For example, to sum a List after mapping and filtering:
662
372
  *
663
373
  * <!-- runkit:activate
664
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
374
+ * { "preamble": "const { List } = require('immutable');" }
665
375
  * -->
666
376
  * ```js
667
377
  * function sum(collection) {
@@ -680,7 +390,7 @@ declare module Immutable {
680
390
  * @see `Map#update`
681
391
  */
682
392
  update(index: number, notSetValue: T, updater: (value: T) => T): this;
683
- update(index: number, updater: (value: T) => T): this;
393
+ update(index: number, updater: (value: T | undefined) => T): this;
684
394
  update<R>(updater: (value: this) => R): R;
685
395
 
686
396
  /**
@@ -695,7 +405,6 @@ declare module Immutable {
695
405
  */
696
406
  setSize(size: number): List<T>;
697
407
 
698
-
699
408
  // Deep persistent changes
700
409
 
701
410
  /**
@@ -707,7 +416,7 @@ declare module Immutable {
707
416
  *
708
417
  * <!-- runkit:activate -->
709
418
  * ```js
710
- * const { List } = require('immutable@4.0.0-rc.8')
419
+ * const { List } = require('immutable')
711
420
  * const list = List([ 0, 1, 2, List([ 3, 4 ])])
712
421
  * list.setIn([3, 0], 999);
713
422
  * // List [ 0, 1, 2, List [ 999, 4 ] ]
@@ -719,7 +428,7 @@ declare module Immutable {
719
428
  *
720
429
  * <!-- runkit:activate -->
721
430
  * ```js
722
- * const { List } = require('immutable@4.0.0-rc.8')
431
+ * const { List } = require('immutable')
723
432
  * const list = List([ 0, 1, 2, { plain: 'object' }])
724
433
  * list.setIn([3, 'plain'], 'value');
725
434
  * // List([ 0, 1, 2, { plain: 'value' }])
@@ -727,7 +436,7 @@ declare module Immutable {
727
436
  *
728
437
  * Note: `setIn` can be used in `withMutations`.
729
438
  */
730
- setIn(keyPath: Iterable<any>, value: any): this;
439
+ setIn(keyPath: Iterable<unknown>, value: unknown): this;
731
440
 
732
441
  /**
733
442
  * Returns a new List having removed the value at this `keyPath`. If any
@@ -735,7 +444,7 @@ declare module Immutable {
735
444
  *
736
445
  * <!-- runkit:activate -->
737
446
  * ```js
738
- * const { List } = require('immutable@4.0.0-rc.8')
447
+ * const { List } = require('immutable')
739
448
  * const list = List([ 0, 1, 2, List([ 3, 4 ])])
740
449
  * list.deleteIn([3, 0]);
741
450
  * // List [ 0, 1, 2, List [ 4 ] ]
@@ -747,7 +456,7 @@ declare module Immutable {
747
456
  *
748
457
  * <!-- runkit:activate -->
749
458
  * ```js
750
- * const { List } = require('immutable@4.0.0-rc.8')
459
+ * const { List } = require('immutable')
751
460
  * const list = List([ 0, 1, 2, { plain: 'object' }])
752
461
  * list.removeIn([3, 'plain']);
753
462
  * // List([ 0, 1, 2, {}])
@@ -757,30 +466,40 @@ declare module Immutable {
757
466
  *
758
467
  * @alias removeIn
759
468
  */
760
- deleteIn(keyPath: Iterable<any>): this;
761
- removeIn(keyPath: Iterable<any>): this;
469
+ deleteIn(keyPath: Iterable<unknown>): this;
470
+ removeIn(keyPath: Iterable<unknown>): this;
762
471
 
763
472
  /**
764
473
  * Note: `updateIn` can be used in `withMutations`.
765
474
  *
766
475
  * @see `Map#updateIn`
767
476
  */
768
- updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
769
- updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
477
+ updateIn(
478
+ keyPath: Iterable<unknown>,
479
+ notSetValue: unknown,
480
+ updater: (value: unknown) => unknown
481
+ ): this;
482
+ updateIn(
483
+ keyPath: Iterable<unknown>,
484
+ updater: (value: unknown) => unknown
485
+ ): this;
770
486
 
771
487
  /**
772
488
  * Note: `mergeIn` can be used in `withMutations`.
773
489
  *
774
490
  * @see `Map#mergeIn`
775
491
  */
776
- mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
492
+ mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
777
493
 
778
494
  /**
779
495
  * Note: `mergeDeepIn` can be used in `withMutations`.
780
496
  *
781
497
  * @see `Map#mergeDeepIn`
782
498
  */
783
- mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
499
+ mergeDeepIn(
500
+ keyPath: Iterable<unknown>,
501
+ ...collections: Array<unknown>
502
+ ): this;
784
503
 
785
504
  // Transient changes
786
505
 
@@ -791,7 +510,7 @@ declare module Immutable {
791
510
  *
792
511
  * @see `Map#withMutations`
793
512
  */
794
- withMutations(mutator: (mutable: this) => any): this;
513
+ withMutations(mutator: (mutable: this) => unknown): this;
795
514
 
796
515
  /**
797
516
  * An alternative API for withMutations()
@@ -831,19 +550,16 @@ declare module Immutable {
831
550
  * `mapper` function.
832
551
  *
833
552
  * <!-- runkit:activate
834
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
553
+ * { "preamble": "const { List } = require('immutable');" }
835
554
  * -->
836
555
  * ```js
837
556
  * List([ 1, 2 ]).map(x => 10 * x)
838
557
  * // List [ 10, 20 ]
839
558
  * ```
840
- *
841
- * Note: `map()` always returns a new instance, even if it produced the same
842
- * value at every step.
843
559
  */
844
560
  map<M>(
845
561
  mapper: (value: T, key: number, iter: this) => M,
846
- context?: any
562
+ context?: unknown
847
563
  ): List<M>;
848
564
 
849
565
  /**
@@ -853,7 +569,7 @@ declare module Immutable {
853
569
  */
854
570
  flatMap<M>(
855
571
  mapper: (value: T, key: number, iter: this) => Iterable<M>,
856
- context?: any
572
+ context?: unknown
857
573
  ): List<M>;
858
574
 
859
575
  /**
@@ -865,11 +581,11 @@ declare module Immutable {
865
581
  */
866
582
  filter<F extends T>(
867
583
  predicate: (value: T, index: number, iter: this) => value is F,
868
- context?: any
584
+ context?: unknown
869
585
  ): List<F>;
870
586
  filter(
871
- predicate: (value: T, index: number, iter: this) => any,
872
- context?: any
587
+ predicate: (value: T, index: number, iter: this) => unknown,
588
+ context?: unknown
873
589
  ): this;
874
590
 
875
591
  /**
@@ -878,7 +594,7 @@ declare module Immutable {
878
594
  * Like `zipWith`, but using the default `zipper`: creating an `Array`.
879
595
  *
880
596
  * <!-- runkit:activate
881
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
597
+ * { "preamble": "const { List } = require('immutable');" }
882
598
  * -->
883
599
  * ```js
884
600
  * const a = List([ 1, 2, 3 ]);
@@ -886,9 +602,12 @@ declare module Immutable {
886
602
  * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
887
603
  * ```
888
604
  */
889
- zip<U>(other: Collection<any, U>): List<[T,U]>;
890
- zip<U,V>(other: Collection<any, U>, other2: Collection<any,V>): List<[T,U,V]>;
891
- zip(...collections: Array<Collection<any, any>>): List<any>;
605
+ zip<U>(other: Collection<unknown, U>): List<[T, U]>;
606
+ zip<U, V>(
607
+ other: Collection<unknown, U>,
608
+ other2: Collection<unknown, V>
609
+ ): List<[T, U, V]>;
610
+ zip(...collections: Array<Collection<unknown, unknown>>): List<unknown>;
892
611
 
893
612
  /**
894
613
  * Returns a List "zipped" with the provided collections.
@@ -897,7 +616,7 @@ declare module Immutable {
897
616
  * exhausted. Missing values from shorter collections are filled with `undefined`.
898
617
  *
899
618
  * <!-- runkit:activate
900
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
619
+ * { "preamble": "const { List } = require('immutable');" }
901
620
  * -->
902
621
  * ```js
903
622
  * const a = List([ 1, 2 ]);
@@ -909,16 +628,19 @@ declare module Immutable {
909
628
  * input, some results may contain undefined values. TypeScript cannot
910
629
  * account for these without cases (as of v2.5).
911
630
  */
912
- zipAll<U>(other: Collection<any, U>): List<[T,U]>;
913
- zipAll<U,V>(other: Collection<any, U>, other2: Collection<any,V>): List<[T,U,V]>;
914
- zipAll(...collections: Array<Collection<any, any>>): List<any>;
631
+ zipAll<U>(other: Collection<unknown, U>): List<[T, U]>;
632
+ zipAll<U, V>(
633
+ other: Collection<unknown, U>,
634
+ other2: Collection<unknown, V>
635
+ ): List<[T, U, V]>;
636
+ zipAll(...collections: Array<Collection<unknown, unknown>>): List<unknown>;
915
637
 
916
638
  /**
917
639
  * Returns a List "zipped" with the provided collections by using a
918
640
  * custom `zipper` function.
919
641
  *
920
642
  * <!-- runkit:activate
921
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8');" }
643
+ * { "preamble": "const { List } = require('immutable');" }
922
644
  * -->
923
645
  * ```js
924
646
  * const a = List([ 1, 2, 3 ]);
@@ -929,20 +651,19 @@ declare module Immutable {
929
651
  */
930
652
  zipWith<U, Z>(
931
653
  zipper: (value: T, otherValue: U) => Z,
932
- otherCollection: Collection<any, U>
654
+ otherCollection: Collection<unknown, U>
933
655
  ): List<Z>;
934
656
  zipWith<U, V, Z>(
935
657
  zipper: (value: T, otherValue: U, thirdValue: V) => Z,
936
- otherCollection: Collection<any, U>,
937
- thirdCollection: Collection<any, V>
658
+ otherCollection: Collection<unknown, U>,
659
+ thirdCollection: Collection<unknown, V>
938
660
  ): List<Z>;
939
661
  zipWith<Z>(
940
- zipper: (...any: Array<any>) => Z,
941
- ...collections: Array<Collection<any, any>>
662
+ zipper: (...values: Array<unknown>) => Z,
663
+ ...collections: Array<Collection<unknown, unknown>>
942
664
  ): List<Z>;
943
665
  }
944
666
 
945
-
946
667
  /**
947
668
  * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with
948
669
  * `O(log32 N)` gets and `O(log32 N)` persistent sets.
@@ -959,7 +680,7 @@ declare module Immutable {
959
680
  *
960
681
  * <!-- runkit:activate -->
961
682
  * ```js
962
- * const { Map, List } = require('immutable@4.0.0-rc.8');
683
+ * const { Map, List } = require('immutable');
963
684
  * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ]));
964
685
  * // 'listofone'
965
686
  * ```
@@ -970,26 +691,25 @@ declare module Immutable {
970
691
  *
971
692
  * Implemented by a hash-array mapped trie.
972
693
  */
973
- export module Map {
974
-
694
+ namespace Map {
975
695
  /**
976
696
  * True if the provided value is a Map
977
697
  *
978
698
  * <!-- runkit:activate -->
979
699
  * ```js
980
- * const { Map } = require('immutable@4.0.0-rc.8')
700
+ * const { Map } = require('immutable')
981
701
  * Map.isMap({}) // false
982
702
  * Map.isMap(Map()) // true
983
703
  * ```
984
704
  */
985
- function isMap(maybeMap: any): maybeMap is Map<any, any>;
705
+ function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
986
706
 
987
707
  /**
988
708
  * Creates a new Map from alternating keys and values
989
709
  *
990
710
  * <!-- runkit:activate -->
991
711
  * ```js
992
- * const { Map } = require('immutable@4.0.0-rc.8')
712
+ * const { Map } = require('immutable')
993
713
  * Map.of(
994
714
  * 'key', 'value',
995
715
  * 'numerical value', 3,
@@ -1000,7 +720,7 @@ declare module Immutable {
1000
720
  *
1001
721
  * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' })
1002
722
  */
1003
- function of(...keyValues: Array<any>): Map<any, any>;
723
+ function of(...keyValues: Array<unknown>): Map<unknown, unknown>;
1004
724
  }
1005
725
 
1006
726
  /**
@@ -1009,9 +729,12 @@ declare module Immutable {
1009
729
  * Created with the same key value pairs as the provided Collection.Keyed or
1010
730
  * JavaScript Object or expects a Collection of [K, V] tuple entries.
1011
731
  *
732
+ * Note: `Map` is a factory function and not a class, and does not use the
733
+ * `new` keyword during construction.
734
+ *
1012
735
  * <!-- runkit:activate -->
1013
736
  * ```js
1014
- * const { Map } = require('immutable@4.0.0-rc.8')
737
+ * const { Map } = require('immutable')
1015
738
  * Map({ key: "value" })
1016
739
  * Map([ [ "key", "value" ] ])
1017
740
  * ```
@@ -1021,7 +744,7 @@ declare module Immutable {
1021
744
  * quote-less shorthand, while Immutable Maps accept keys of any type.
1022
745
  *
1023
746
  * <!-- runkit:activate
1024
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
747
+ * { "preamble": "const { Map } = require('immutable');" }
1025
748
  * -->
1026
749
  * ```js
1027
750
  * let obj = { 1: "one" }
@@ -1036,14 +759,11 @@ declare module Immutable {
1036
759
  * but since Immutable Map keys can be of any type the argument to `get()` is
1037
760
  * not altered.
1038
761
  */
1039
- export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
1040
- export function Map<T>(collection: Iterable<Iterable<T>>): Map<T, T>;
1041
- export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
1042
- export function Map<K, V>(): Map<K, V>;
1043
- export function Map(): Map<any, any>;
1044
-
1045
- export interface Map<K, V> extends Collection.Keyed<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 | symbol, V>(obj: { [P in K]?: V }): Map<K, V>;
1046
765
 
766
+ interface Map<K, V> extends Collection.Keyed<K, V> {
1047
767
  /**
1048
768
  * The number of entries in this Map.
1049
769
  */
@@ -1057,7 +777,7 @@ declare module Immutable {
1057
777
  *
1058
778
  * <!-- runkit:activate -->
1059
779
  * ```js
1060
- * const { Map } = require('immutable@4.0.0-rc.8')
780
+ * const { Map } = require('immutable')
1061
781
  * const originalMap = Map()
1062
782
  * const newerMap = originalMap.set('key', 'value')
1063
783
  * const newestMap = newerMap.set('key', 'newer value')
@@ -1082,7 +802,7 @@ declare module Immutable {
1082
802
  *
1083
803
  * <!-- runkit:activate -->
1084
804
  * ```js
1085
- * const { Map } = require('immutable@4.0.0-rc.8')
805
+ * const { Map } = require('immutable')
1086
806
  * const originalMap = Map({
1087
807
  * key: 'value',
1088
808
  * otherKey: 'other value'
@@ -1104,7 +824,7 @@ declare module Immutable {
1104
824
  *
1105
825
  * <!-- runkit:activate -->
1106
826
  * ```js
1107
- * const { Map } = require('immutable@4.0.0-rc.8')
827
+ * const { Map } = require('immutable')
1108
828
  * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" })
1109
829
  * names.deleteAll([ 'a', 'c' ])
1110
830
  * // Map { "b": "Barry" }
@@ -1122,7 +842,7 @@ declare module Immutable {
1122
842
  *
1123
843
  * <!-- runkit:activate -->
1124
844
  * ```js
1125
- * const { Map } = require('immutable@4.0.0-rc.8')
845
+ * const { Map } = require('immutable')
1126
846
  * Map({ key: 'value' }).clear()
1127
847
  * // Map {}
1128
848
  * ```
@@ -1139,7 +859,7 @@ declare module Immutable {
1139
859
  *
1140
860
  * <!-- runkit:activate -->
1141
861
  * ```js
1142
- * const { Map } = require('immutable@4.0.0-rc.8')
862
+ * const { Map } = require('immutable')
1143
863
  * const aMap = Map({ key: 'value' })
1144
864
  * const newMap = aMap.update('key', value => value + value)
1145
865
  * // Map { "key": "valuevalue" }
@@ -1150,7 +870,7 @@ declare module Immutable {
1150
870
  * `update` and `push` can be used together:
1151
871
  *
1152
872
  * <!-- runkit:activate
1153
- * { "preamble": "const { Map, List } = require('immutable@4.0.0-rc.8');" }
873
+ * { "preamble": "const { Map, List } = require('immutable');" }
1154
874
  * -->
1155
875
  * ```js
1156
876
  * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) })
@@ -1162,7 +882,7 @@ declare module Immutable {
1162
882
  * function when the value at the key does not exist in the Map.
1163
883
  *
1164
884
  * <!-- runkit:activate
1165
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
885
+ * { "preamble": "const { Map } = require('immutable');" }
1166
886
  * -->
1167
887
  * ```js
1168
888
  * const aMap = Map({ key: 'value' })
@@ -1175,7 +895,7 @@ declare module Immutable {
1175
895
  * is provided.
1176
896
  *
1177
897
  * <!-- runkit:activate
1178
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
898
+ * { "preamble": "const { Map } = require('immutable');" }
1179
899
  * -->
1180
900
  * ```js
1181
901
  * const aMap = Map({ apples: 10 })
@@ -1191,7 +911,7 @@ declare module Immutable {
1191
911
  * The previous example behaves differently when written with default values:
1192
912
  *
1193
913
  * <!-- runkit:activate
1194
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
914
+ * { "preamble": "const { Map } = require('immutable');" }
1195
915
  * -->
1196
916
  * ```js
1197
917
  * const aMap = Map({ apples: 10 })
@@ -1203,7 +923,7 @@ declare module Immutable {
1203
923
  * returned as well.
1204
924
  *
1205
925
  * <!-- runkit:activate
1206
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
926
+ * { "preamble": "const { Map } = require('immutable');" }
1207
927
  * -->
1208
928
  * ```js
1209
929
  * const aMap = Map({ key: 'value' })
@@ -1217,7 +937,7 @@ declare module Immutable {
1217
937
  * For example, to sum the values in a Map
1218
938
  *
1219
939
  * <!-- runkit:activate
1220
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8');" }
940
+ * { "preamble": "const { Map } = require('immutable');" }
1221
941
  * -->
1222
942
  * ```js
1223
943
  * function sum(collection) {
@@ -1234,7 +954,7 @@ declare module Immutable {
1234
954
  * Note: `update(key)` can be used in `withMutations`.
1235
955
  */
1236
956
  update(key: K, notSetValue: V, updater: (value: V) => V): this;
1237
- update(key: K, updater: (value: V) => V): this;
957
+ update(key: K, updater: (value: V | undefined) => V): this;
1238
958
  update<R>(updater: (value: this) => R): R;
1239
959
 
1240
960
  /**
@@ -1247,7 +967,7 @@ declare module Immutable {
1247
967
  *
1248
968
  * <!-- runkit:activate -->
1249
969
  * ```js
1250
- * const { Map } = require('immutable@4.0.0-rc.8')
970
+ * const { Map } = require('immutable')
1251
971
  * const one = Map({ a: 10, b: 20, c: 30 })
1252
972
  * const two = Map({ b: 40, a: 50, d: 60 })
1253
973
  * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 }
@@ -1258,10 +978,18 @@ declare module Immutable {
1258
978
  *
1259
979
  * @alias concat
1260
980
  */
1261
- merge<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Map<K | KC, V | VC>;
1262
- merge<C>(...collections: Array<{[key: string]: C}>): Map<K | string, V | C>;
1263
- concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Map<K | KC, V | VC>;
1264
- concat<C>(...collections: Array<{[key: string]: C}>): Map<K | string, V | C>;
981
+ merge<KC, VC>(
982
+ ...collections: Array<Iterable<[KC, VC]>>
983
+ ): Map<K | KC, V | VC>;
984
+ merge<C>(
985
+ ...collections: Array<{ [key: string]: C }>
986
+ ): Map<K | string, V | C>;
987
+ concat<KC, VC>(
988
+ ...collections: Array<Iterable<[KC, VC]>>
989
+ ): Map<K | KC, V | VC>;
990
+ concat<C>(
991
+ ...collections: Array<{ [key: string]: C }>
992
+ ): Map<K | string, V | C>;
1265
993
 
1266
994
  /**
1267
995
  * Like `merge()`, `mergeWith()` returns a new Map resulting from merging
@@ -1270,7 +998,7 @@ declare module Immutable {
1270
998
  *
1271
999
  * <!-- runkit:activate -->
1272
1000
  * ```js
1273
- * const { Map } = require('immutable@4.0.0-rc.8')
1001
+ * const { Map } = require('immutable')
1274
1002
  * const one = Map({ a: 10, b: 20, c: 30 })
1275
1003
  * const two = Map({ b: 40, a: 50, d: 60 })
1276
1004
  * one.mergeWith((oldVal, newVal) => oldVal / newVal, two)
@@ -1283,20 +1011,26 @@ declare module Immutable {
1283
1011
  */
1284
1012
  mergeWith(
1285
1013
  merger: (oldVal: V, newVal: V, key: K) => V,
1286
- ...collections: Array<Iterable<[K, V]> | {[key: string]: V}>
1014
+ ...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
1287
1015
  ): this;
1288
1016
 
1289
1017
  /**
1290
- * Like `merge()`, but when two Collections conflict, it merges them as well,
1291
- * 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()`.
1292
1027
  *
1293
- * Note: Values provided to `merge` are shallowly converted before being
1294
- * merged. No nested values are altered unless they will also be merged at
1295
- * a deeper level.
1028
+ * Note: Indexed and set-like collections are merged using
1029
+ * `concat()`/`union()` and therefore do not recurse.
1296
1030
  *
1297
1031
  * <!-- runkit:activate -->
1298
1032
  * ```js
1299
- * const { Map } = require('immutable@4.0.0-rc.8')
1033
+ * const { Map } = require('immutable')
1300
1034
  * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) })
1301
1035
  * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) })
1302
1036
  * one.mergeDeep(two)
@@ -1309,15 +1043,20 @@ declare module Immutable {
1309
1043
  *
1310
1044
  * Note: `mergeDeep` can be used in `withMutations`.
1311
1045
  */
1312
- mergeDeep(...collections: Array<Iterable<[K, V]> | {[key: string]: V}>): this;
1046
+ mergeDeep(
1047
+ ...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
1048
+ ): this;
1313
1049
 
1314
1050
  /**
1315
- * Like `mergeDeep()`, but when two non-Collections conflict, it uses the
1316
- * `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.
1317
1056
  *
1318
1057
  * <!-- runkit:activate -->
1319
1058
  * ```js
1320
- * const { Map } = require('immutable@4.0.0-rc.8')
1059
+ * const { Map } = require('immutable')
1321
1060
  * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) })
1322
1061
  * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) })
1323
1062
  * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two)
@@ -1327,15 +1066,14 @@ declare module Immutable {
1327
1066
  * // "c": Map { "z": 3 }
1328
1067
  * // }
1329
1068
  * ```
1330
-
1069
+ *
1331
1070
  * Note: `mergeDeepWith` can be used in `withMutations`.
1332
1071
  */
1333
1072
  mergeDeepWith(
1334
- merger: (oldVal: V, newVal: V, key: K) => V,
1335
- ...collections: Array<Iterable<[K, V]> | {[key: string]: V}>
1073
+ merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
1074
+ ...collections: Array<Iterable<[K, V]> | { [key: string]: V }>
1336
1075
  ): this;
1337
1076
 
1338
-
1339
1077
  // Deep persistent changes
1340
1078
 
1341
1079
  /**
@@ -1344,7 +1082,7 @@ declare module Immutable {
1344
1082
  *
1345
1083
  * <!-- runkit:activate -->
1346
1084
  * ```js
1347
- * const { Map } = require('immutable@4.0.0-rc.8')
1085
+ * const { Map } = require('immutable')
1348
1086
  * const originalMap = Map({
1349
1087
  * subObject: Map({
1350
1088
  * subKey: 'subvalue',
@@ -1380,7 +1118,7 @@ declare module Immutable {
1380
1118
  *
1381
1119
  * <!-- runkit:activate -->
1382
1120
  * ```js
1383
- * const { Map } = require('immutable@4.0.0-rc.8')
1121
+ * const { Map } = require('immutable')
1384
1122
  * const originalMap = Map({
1385
1123
  * subObject: {
1386
1124
  * subKey: 'subvalue',
@@ -1404,7 +1142,7 @@ declare module Immutable {
1404
1142
  *
1405
1143
  * Note: `setIn` can be used in `withMutations`.
1406
1144
  */
1407
- setIn(keyPath: Iterable<any>, value: any): this;
1145
+ setIn(keyPath: Iterable<unknown>, value: unknown): this;
1408
1146
 
1409
1147
  /**
1410
1148
  * Returns a new Map having removed the value at this `keyPath`. If any keys
@@ -1414,8 +1152,8 @@ declare module Immutable {
1414
1152
  *
1415
1153
  * @alias removeIn
1416
1154
  */
1417
- deleteIn(keyPath: Iterable<any>): this;
1418
- removeIn(keyPath: Iterable<any>): this;
1155
+ deleteIn(keyPath: Iterable<unknown>): this;
1156
+ removeIn(keyPath: Iterable<unknown>): this;
1419
1157
 
1420
1158
  /**
1421
1159
  * Returns a new Map having applied the `updater` to the entry found at the
@@ -1427,7 +1165,7 @@ declare module Immutable {
1427
1165
  *
1428
1166
  * <!-- runkit:activate -->
1429
1167
  * ```js
1430
- * const { Map, List } = require('immutable@4.0.0-rc.8')
1168
+ * const { Map, List } = require('immutable')
1431
1169
  * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) })
1432
1170
  * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4))
1433
1171
  * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } }
@@ -1439,7 +1177,7 @@ declare module Immutable {
1439
1177
  * provided, otherwise `undefined`.
1440
1178
  *
1441
1179
  * <!-- runkit:activate
1442
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8')" }
1180
+ * { "preamble": "const { Map } = require('immutable')" }
1443
1181
  * -->
1444
1182
  * ```js
1445
1183
  * const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
@@ -1451,7 +1189,7 @@ declare module Immutable {
1451
1189
  * no change will occur. This is still true if `notSetValue` is provided.
1452
1190
  *
1453
1191
  * <!-- runkit:activate
1454
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8')" }
1192
+ * { "preamble": "const { Map } = require('immutable')" }
1455
1193
  * -->
1456
1194
  * ```js
1457
1195
  * const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
@@ -1467,7 +1205,7 @@ declare module Immutable {
1467
1205
  * The previous example behaves differently when written with default values:
1468
1206
  *
1469
1207
  * <!-- runkit:activate
1470
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8')" }
1208
+ * { "preamble": "const { Map } = require('immutable')" }
1471
1209
  * -->
1472
1210
  * ```js
1473
1211
  * const map = Map({ a: Map({ b: Map({ c: 10 }) }) })
@@ -1480,7 +1218,7 @@ declare module Immutable {
1480
1218
  * immutably by creating new copies of those values with the changes applied.
1481
1219
  *
1482
1220
  * <!-- runkit:activate
1483
- * { "preamble": "const { Map } = require('immutable@4.0.0-rc.8')" }
1221
+ * { "preamble": "const { Map } = require('immutable')" }
1484
1222
  * -->
1485
1223
  * ```js
1486
1224
  * const map = Map({ a: { b: { c: 10 } } })
@@ -1493,8 +1231,15 @@ declare module Immutable {
1493
1231
  *
1494
1232
  * Note: `updateIn` can be used in `withMutations`.
1495
1233
  */
1496
- updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
1497
- updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
1234
+ updateIn(
1235
+ keyPath: Iterable<unknown>,
1236
+ notSetValue: unknown,
1237
+ updater: (value: unknown) => unknown
1238
+ ): this;
1239
+ updateIn(
1240
+ keyPath: Iterable<unknown>,
1241
+ updater: (value: unknown) => unknown
1242
+ ): this;
1498
1243
 
1499
1244
  /**
1500
1245
  * A combination of `updateIn` and `merge`, returning a new Map, but
@@ -1508,7 +1253,7 @@ declare module Immutable {
1508
1253
  *
1509
1254
  * Note: `mergeIn` can be used in `withMutations`.
1510
1255
  */
1511
- mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
1256
+ mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
1512
1257
 
1513
1258
  /**
1514
1259
  * A combination of `updateIn` and `mergeDeep`, returning a new Map, but
@@ -1522,7 +1267,10 @@ declare module Immutable {
1522
1267
  *
1523
1268
  * Note: `mergeDeepIn` can be used in `withMutations`.
1524
1269
  */
1525
- mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
1270
+ mergeDeepIn(
1271
+ keyPath: Iterable<unknown>,
1272
+ ...collections: Array<unknown>
1273
+ ): this;
1526
1274
 
1527
1275
  // Transient changes
1528
1276
 
@@ -1541,7 +1289,7 @@ declare module Immutable {
1541
1289
  *
1542
1290
  * <!-- runkit:activate -->
1543
1291
  * ```js
1544
- * const { Map } = require('immutable@4.0.0-rc.8')
1292
+ * const { Map } = require('immutable')
1545
1293
  * const map1 = Map()
1546
1294
  * const map2 = map1.withMutations(map => {
1547
1295
  * map.set('a', 1).set('b', 2).set('c', 3)
@@ -1554,21 +1302,25 @@ declare module Immutable {
1554
1302
  * `withMutations`! Read the documentation for each method to see if it
1555
1303
  * is safe to use in `withMutations`.
1556
1304
  */
1557
- withMutations(mutator: (mutable: this) => any): this;
1305
+ withMutations(mutator: (mutable: this) => unknown): this;
1558
1306
 
1559
1307
  /**
1560
1308
  * Another way to avoid creation of intermediate Immutable maps is to create
1561
1309
  * a mutable copy of this collection. Mutable copies *always* return `this`,
1562
1310
  * and thus shouldn't be used for equality. Your function should never return
1563
1311
  * a mutable copy of a collection, only use it internally to create a new
1564
- * collection. If possible, use `withMutations` as it provides an easier to
1565
- * use API.
1312
+ * collection.
1313
+ *
1314
+ * If possible, use `withMutations` to work with temporary mutable copies as
1315
+ * it provides an easier to use API and considers many common optimizations.
1566
1316
  *
1567
1317
  * Note: if the collection is already mutable, `asMutable` returns itself.
1568
1318
  *
1569
1319
  * Note: Not all methods can be used on a mutable collection or within
1570
1320
  * `withMutations`! Read the documentation for each method to see if it
1571
1321
  * is safe to use in `withMutations`.
1322
+ *
1323
+ * @see `Map#asImmutable`
1572
1324
  */
1573
1325
  asMutable(): this;
1574
1326
 
@@ -1582,8 +1334,15 @@ declare module Immutable {
1582
1334
 
1583
1335
  /**
1584
1336
  * The yin to `asMutable`'s yang. Because it applies to mutable collections,
1585
- * this operation is *mutable* and returns itself. Once performed, the mutable
1586
- * copy has become immutable and can be safely returned from a function.
1337
+ * this operation is *mutable* and may return itself (though may not
1338
+ * return itself, i.e. if the result is an empty collection). Once
1339
+ * performed, the original mutable copy must no longer be mutated since it
1340
+ * may be the immutable result.
1341
+ *
1342
+ * If possible, use `withMutations` to work with temporary mutable copies as
1343
+ * it provides an easier to use API and considers many common optimizations.
1344
+ *
1345
+ * @see `Map#asMutable`
1587
1346
  */
1588
1347
  asImmutable(): this;
1589
1348
 
@@ -1595,13 +1354,10 @@ declare module Immutable {
1595
1354
  *
1596
1355
  * Map({ a: 1, b: 2 }).map(x => 10 * x)
1597
1356
  * // Map { a: 10, b: 20 }
1598
- *
1599
- * Note: `map()` always returns a new instance, even if it produced the same
1600
- * value at every step.
1601
1357
  */
1602
1358
  map<M>(
1603
1359
  mapper: (value: V, key: K, iter: this) => M,
1604
- context?: any
1360
+ context?: unknown
1605
1361
  ): Map<K, M>;
1606
1362
 
1607
1363
  /**
@@ -1609,15 +1365,19 @@ declare module Immutable {
1609
1365
  */
1610
1366
  mapKeys<M>(
1611
1367
  mapper: (key: K, value: V, iter: this) => M,
1612
- context?: any
1368
+ context?: unknown
1613
1369
  ): Map<M, V>;
1614
1370
 
1615
1371
  /**
1616
1372
  * @see Collection.Keyed.mapEntries
1617
1373
  */
1618
1374
  mapEntries<KM, VM>(
1619
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
1620
- context?: any
1375
+ mapper: (
1376
+ entry: [K, V],
1377
+ index: number,
1378
+ iter: this
1379
+ ) => [KM, VM] | undefined,
1380
+ context?: unknown
1621
1381
  ): Map<KM, VM>;
1622
1382
 
1623
1383
  /**
@@ -1627,7 +1387,7 @@ declare module Immutable {
1627
1387
  */
1628
1388
  flatMap<KM, VM>(
1629
1389
  mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
1630
- context?: any
1390
+ context?: unknown
1631
1391
  ): Map<KM, VM>;
1632
1392
 
1633
1393
  /**
@@ -1639,11 +1399,11 @@ declare module Immutable {
1639
1399
  */
1640
1400
  filter<F extends V>(
1641
1401
  predicate: (value: V, key: K, iter: this) => value is F,
1642
- context?: any
1402
+ context?: unknown
1643
1403
  ): Map<K, F>;
1644
1404
  filter(
1645
- predicate: (value: V, key: K, iter: this) => any,
1646
- context?: any
1405
+ predicate: (value: V, key: K, iter: this) => unknown,
1406
+ context?: unknown
1647
1407
  ): this;
1648
1408
 
1649
1409
  /**
@@ -1652,7 +1412,6 @@ declare module Immutable {
1652
1412
  flip(): Map<V, K>;
1653
1413
  }
1654
1414
 
1655
-
1656
1415
  /**
1657
1416
  * A type of Map that has the additional guarantee that the iteration order of
1658
1417
  * entries will be the order in which they were set().
@@ -1664,13 +1423,13 @@ declare module Immutable {
1664
1423
  * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not
1665
1424
  * stable.
1666
1425
  */
1667
-
1668
- export module OrderedMap {
1669
-
1426
+ namespace OrderedMap {
1670
1427
  /**
1671
1428
  * True if the provided value is an OrderedMap.
1672
1429
  */
1673
- function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap<any, any>;
1430
+ function isOrderedMap(
1431
+ maybeOrderedMap: unknown
1432
+ ): maybeOrderedMap is OrderedMap<unknown, unknown>;
1674
1433
  }
1675
1434
 
1676
1435
  /**
@@ -1685,20 +1444,39 @@ declare module Immutable {
1685
1444
  * let newOrderedMap = OrderedMap({key: "value"})
1686
1445
  * let newOrderedMap = OrderedMap([["key", "value"]])
1687
1446
  *
1447
+ * Note: `OrderedMap` is a factory function and not a class, and does not use
1448
+ * the `new` keyword during construction.
1688
1449
  */
1689
- export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
1690
- export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
1691
- export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
1692
- export function OrderedMap<K, V>(): OrderedMap<K, V>;
1693
- export function OrderedMap(): OrderedMap<any, any>;
1694
-
1695
- export interface OrderedMap<K, V> extends Map<K, V> {
1450
+ function OrderedMap<K, V>(collection?: Iterable<[K, V]>): OrderedMap<K, V>;
1451
+ function OrderedMap<V>(obj: { [key: string]: V }): OrderedMap<string, V>;
1696
1452
 
1453
+ interface OrderedMap<K, V> extends Map<K, V> {
1697
1454
  /**
1698
1455
  * The number of entries in this OrderedMap.
1699
1456
  */
1700
1457
  readonly size: number;
1701
1458
 
1459
+ /**
1460
+ * Returns a new OrderedMap also containing the new key, value pair. If an
1461
+ * equivalent key already exists in this OrderedMap, it will be replaced
1462
+ * while maintaining the existing order.
1463
+ *
1464
+ * <!-- runkit:activate -->
1465
+ * ```js
1466
+ * const { OrderedMap } = require('immutable')
1467
+ * const originalMap = OrderedMap({a:1, b:1, c:1})
1468
+ * const updatedMap = originalMap.set('b', 2)
1469
+ *
1470
+ * originalMap
1471
+ * // OrderedMap {a: 1, b: 1, c: 1}
1472
+ * updatedMap
1473
+ * // OrderedMap {a: 1, b: 2, c: 1}
1474
+ * ```
1475
+ *
1476
+ * Note: `set` can be used in `withMutations`.
1477
+ */
1478
+ set(key: K, value: V): this;
1479
+
1702
1480
  /**
1703
1481
  * Returns a new OrderedMap resulting from merging the provided Collections
1704
1482
  * (or JS objects) into this OrderedMap. In other words, this takes each
@@ -1709,7 +1487,7 @@ declare module Immutable {
1709
1487
  *
1710
1488
  * <!-- runkit:activate -->
1711
1489
  * ```js
1712
- * const { OrderedMap } = require('immutable@4.0.0-rc.8')
1490
+ * const { OrderedMap } = require('immutable')
1713
1491
  * const one = OrderedMap({ a: 10, b: 20, c: 30 })
1714
1492
  * const two = OrderedMap({ b: 40, a: 50, d: 60 })
1715
1493
  * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 }
@@ -1720,10 +1498,18 @@ declare module Immutable {
1720
1498
  *
1721
1499
  * @alias concat
1722
1500
  */
1723
- merge<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): OrderedMap<K | KC, V | VC>;
1724
- merge<C>(...collections: Array<{[key: string]: C}>): OrderedMap<K | string, V | C>;
1725
- concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): OrderedMap<K | KC, V | VC>;
1726
- concat<C>(...collections: Array<{[key: string]: C}>): OrderedMap<K | string, V | C>;
1501
+ merge<KC, VC>(
1502
+ ...collections: Array<Iterable<[KC, VC]>>
1503
+ ): OrderedMap<K | KC, V | VC>;
1504
+ merge<C>(
1505
+ ...collections: Array<{ [key: string]: C }>
1506
+ ): OrderedMap<K | string, V | C>;
1507
+ concat<KC, VC>(
1508
+ ...collections: Array<Iterable<[KC, VC]>>
1509
+ ): OrderedMap<K | KC, V | VC>;
1510
+ concat<C>(
1511
+ ...collections: Array<{ [key: string]: C }>
1512
+ ): OrderedMap<K | string, V | C>;
1727
1513
 
1728
1514
  // Sequence algorithms
1729
1515
 
@@ -1739,7 +1525,7 @@ declare module Immutable {
1739
1525
  */
1740
1526
  map<M>(
1741
1527
  mapper: (value: V, key: K, iter: this) => M,
1742
- context?: any
1528
+ context?: unknown
1743
1529
  ): OrderedMap<K, M>;
1744
1530
 
1745
1531
  /**
@@ -1747,15 +1533,19 @@ declare module Immutable {
1747
1533
  */
1748
1534
  mapKeys<M>(
1749
1535
  mapper: (key: K, value: V, iter: this) => M,
1750
- context?: any
1536
+ context?: unknown
1751
1537
  ): OrderedMap<M, V>;
1752
1538
 
1753
1539
  /**
1754
1540
  * @see Collection.Keyed.mapEntries
1755
1541
  */
1756
1542
  mapEntries<KM, VM>(
1757
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
1758
- context?: any
1543
+ mapper: (
1544
+ entry: [K, V],
1545
+ index: number,
1546
+ iter: this
1547
+ ) => [KM, VM] | undefined,
1548
+ context?: unknown
1759
1549
  ): OrderedMap<KM, VM>;
1760
1550
 
1761
1551
  /**
@@ -1765,7 +1555,7 @@ declare module Immutable {
1765
1555
  */
1766
1556
  flatMap<KM, VM>(
1767
1557
  mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
1768
- context?: any
1558
+ context?: unknown
1769
1559
  ): OrderedMap<KM, VM>;
1770
1560
 
1771
1561
  /**
@@ -1777,11 +1567,11 @@ declare module Immutable {
1777
1567
  */
1778
1568
  filter<F extends V>(
1779
1569
  predicate: (value: V, key: K, iter: this) => value is F,
1780
- context?: any
1570
+ context?: unknown
1781
1571
  ): OrderedMap<K, F>;
1782
1572
  filter(
1783
- predicate: (value: V, key: K, iter: this) => any,
1784
- context?: any
1573
+ predicate: (value: V, key: K, iter: this) => unknown,
1574
+ context?: unknown
1785
1575
  ): this;
1786
1576
 
1787
1577
  /**
@@ -1790,7 +1580,6 @@ declare module Immutable {
1790
1580
  flip(): OrderedMap<V, K>;
1791
1581
  }
1792
1582
 
1793
-
1794
1583
  /**
1795
1584
  * A Collection of unique values with `O(log32 N)` adds and has.
1796
1585
  *
@@ -1802,12 +1591,11 @@ declare module Immutable {
1802
1591
  * `Immutable.is`, enabling Sets to uniquely include other Immutable
1803
1592
  * collections, custom value types, and NaN.
1804
1593
  */
1805
- export module Set {
1806
-
1594
+ namespace Set {
1807
1595
  /**
1808
1596
  * True if the provided value is a Set
1809
1597
  */
1810
- function isSet(maybeSet: any): maybeSet is Set<any>;
1598
+ function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
1811
1599
 
1812
1600
  /**
1813
1601
  * Creates a new Set containing `values`.
@@ -1818,20 +1606,20 @@ declare module Immutable {
1818
1606
  * `Set.fromKeys()` creates a new immutable Set containing the keys from
1819
1607
  * this Collection or JavaScript Object.
1820
1608
  */
1821
- function fromKeys<T>(iter: Collection<T, any>): Set<T>;
1822
- function fromKeys(obj: {[key: string]: any}): Set<string>;
1609
+ function fromKeys<T>(iter: Collection<T, unknown>): Set<T>;
1610
+ function fromKeys(obj: { [key: string]: unknown }): Set<string>;
1823
1611
 
1824
1612
  /**
1825
1613
  * `Set.intersect()` creates a new immutable Set that is the intersection of
1826
1614
  * a collection of other sets.
1827
1615
  *
1828
1616
  * ```js
1829
- * const { Set } = require('immutable@4.0.0-rc.8')
1617
+ * const { Set } = require('immutable')
1830
1618
  * const intersected = Set.intersect([
1831
1619
  * Set([ 'a', 'b', 'c' ])
1832
1620
  * Set([ 'c', 'a', 't' ])
1833
1621
  * ])
1834
- * // Set [ "a", "c"" ]
1622
+ * // Set [ "a", "c" ]
1835
1623
  * ```
1836
1624
  */
1837
1625
  function intersect<T>(sets: Iterable<Iterable<T>>): Set<T>;
@@ -1841,12 +1629,12 @@ declare module Immutable {
1841
1629
  * collection of other sets.
1842
1630
  *
1843
1631
  * ```js
1844
- * const { Set } = require('immutable@4.0.0-rc.8')
1632
+ * const { Set } = require('immutable')
1845
1633
  * const unioned = Set.union([
1846
1634
  * Set([ 'a', 'b', 'c' ])
1847
1635
  * Set([ 'c', 'a', 't' ])
1848
1636
  * ])
1849
- * // Set [ "a", "b", "c", "t"" ]
1637
+ * // Set [ "a", "b", "c", "t" ]
1850
1638
  * ```
1851
1639
  */
1852
1640
  function union<T>(sets: Iterable<Iterable<T>>): Set<T>;
@@ -1855,13 +1643,13 @@ declare module Immutable {
1855
1643
  /**
1856
1644
  * Create a new immutable Set containing the values of the provided
1857
1645
  * collection-like.
1646
+ *
1647
+ * Note: `Set` is a factory function and not a class, and does not use the
1648
+ * `new` keyword during construction.
1858
1649
  */
1859
- export function Set(): Set<any>;
1860
- export function Set<T>(): Set<T>;
1861
- export function Set<T>(collection: Iterable<T>): Set<T>;
1862
-
1863
- export interface Set<T> extends Collection.Set<T> {
1650
+ function Set<T>(collection?: Iterable<T> | ArrayLike<T>): Set<T>;
1864
1651
 
1652
+ interface Set<T> extends Collection.Set<T> {
1865
1653
  /**
1866
1654
  * The number of items in this Set.
1867
1655
  */
@@ -1919,11 +1707,17 @@ declare module Immutable {
1919
1707
  /**
1920
1708
  * Returns a Set excluding any values contained within `collections`.
1921
1709
  *
1710
+ * <!-- runkit:activate -->
1711
+ * ```js
1712
+ * const { OrderedSet } = require('immutable')
1713
+ * OrderedSet([ 1, 2, 3 ]).subtract([1, 3])
1714
+ * // OrderedSet [2]
1715
+ * ```
1716
+ *
1922
1717
  * Note: `subtract` can be used in `withMutations`.
1923
1718
  */
1924
1719
  subtract(...collections: Array<Iterable<T>>): this;
1925
1720
 
1926
-
1927
1721
  // Transient changes
1928
1722
 
1929
1723
  /**
@@ -1933,7 +1727,7 @@ declare module Immutable {
1933
1727
  *
1934
1728
  * @see `Map#withMutations`
1935
1729
  */
1936
- withMutations(mutator: (mutable: this) => any): this;
1730
+ withMutations(mutator: (mutable: this) => unknown): this;
1937
1731
 
1938
1732
  /**
1939
1733
  * Note: Not all methods can be used on a mutable collection or within
@@ -1962,13 +1756,10 @@ declare module Immutable {
1962
1756
  *
1963
1757
  * Set([1,2]).map(x => 10 * x)
1964
1758
  * // Set [10,20]
1965
- *
1966
- * Note: `map()` always returns a new instance, even if it produced the same
1967
- * value at every step.
1968
1759
  */
1969
1760
  map<M>(
1970
1761
  mapper: (value: T, key: T, iter: this) => M,
1971
- context?: any
1762
+ context?: unknown
1972
1763
  ): Set<M>;
1973
1764
 
1974
1765
  /**
@@ -1978,7 +1769,7 @@ declare module Immutable {
1978
1769
  */
1979
1770
  flatMap<M>(
1980
1771
  mapper: (value: T, key: T, iter: this) => Iterable<M>,
1981
- context?: any
1772
+ context?: unknown
1982
1773
  ): Set<M>;
1983
1774
 
1984
1775
  /**
@@ -1990,15 +1781,14 @@ declare module Immutable {
1990
1781
  */
1991
1782
  filter<F extends T>(
1992
1783
  predicate: (value: T, key: T, iter: this) => value is F,
1993
- context?: any
1784
+ context?: unknown
1994
1785
  ): Set<F>;
1995
1786
  filter(
1996
- predicate: (value: T, key: T, iter: this) => any,
1997
- context?: any
1787
+ predicate: (value: T, key: T, iter: this) => unknown,
1788
+ context?: unknown
1998
1789
  ): this;
1999
1790
  }
2000
1791
 
2001
-
2002
1792
  /**
2003
1793
  * A type of Set that has the additional guarantee that the iteration order of
2004
1794
  * values will be the order in which they were `add`ed.
@@ -2009,12 +1799,11 @@ declare module Immutable {
2009
1799
  * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not
2010
1800
  * stable.
2011
1801
  */
2012
- export module OrderedSet {
2013
-
1802
+ namespace OrderedSet {
2014
1803
  /**
2015
1804
  * True if the provided value is an OrderedSet.
2016
1805
  */
2017
- function isOrderedSet(maybeOrderedSet: any): boolean;
1806
+ function isOrderedSet(maybeOrderedSet: unknown): boolean;
2018
1807
 
2019
1808
  /**
2020
1809
  * Creates a new OrderedSet containing `values`.
@@ -2025,20 +1814,22 @@ declare module Immutable {
2025
1814
  * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing
2026
1815
  * the keys from this Collection or JavaScript Object.
2027
1816
  */
2028
- function fromKeys<T>(iter: Collection<T, any>): OrderedSet<T>;
2029
- function fromKeys(obj: {[key: string]: any}): OrderedSet<string>;
1817
+ function fromKeys<T>(iter: Collection<T, unknown>): OrderedSet<T>;
1818
+ function fromKeys(obj: { [key: string]: unknown }): OrderedSet<string>;
2030
1819
  }
2031
1820
 
2032
1821
  /**
2033
1822
  * Create a new immutable OrderedSet containing the values of the provided
2034
1823
  * collection-like.
1824
+ *
1825
+ * Note: `OrderedSet` is a factory function and not a class, and does not use
1826
+ * the `new` keyword during construction.
2035
1827
  */
2036
- export function OrderedSet(): OrderedSet<any>;
2037
- export function OrderedSet<T>(): OrderedSet<T>;
2038
- export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
2039
-
2040
- export interface OrderedSet<T> extends Set<T> {
1828
+ function OrderedSet<T>(
1829
+ collection?: Iterable<T> | ArrayLike<T>
1830
+ ): OrderedSet<T>;
2041
1831
 
1832
+ interface OrderedSet<T> extends Set<T> {
2042
1833
  /**
2043
1834
  * The number of items in this OrderedSet.
2044
1835
  */
@@ -2064,13 +1855,10 @@ declare module Immutable {
2064
1855
  *
2065
1856
  * OrderedSet([ 1, 2 ]).map(x => 10 * x)
2066
1857
  * // OrderedSet [10, 20]
2067
- *
2068
- * Note: `map()` always returns a new instance, even if it produced the same
2069
- * value at every step.
2070
1858
  */
2071
1859
  map<M>(
2072
1860
  mapper: (value: T, key: T, iter: this) => M,
2073
- context?: any
1861
+ context?: unknown
2074
1862
  ): OrderedSet<M>;
2075
1863
 
2076
1864
  /**
@@ -2080,7 +1868,7 @@ declare module Immutable {
2080
1868
  */
2081
1869
  flatMap<M>(
2082
1870
  mapper: (value: T, key: T, iter: this) => Iterable<M>,
2083
- context?: any
1871
+ context?: unknown
2084
1872
  ): OrderedSet<M>;
2085
1873
 
2086
1874
  /**
@@ -2092,11 +1880,11 @@ declare module Immutable {
2092
1880
  */
2093
1881
  filter<F extends T>(
2094
1882
  predicate: (value: T, key: T, iter: this) => value is F,
2095
- context?: any
1883
+ context?: unknown
2096
1884
  ): OrderedSet<F>;
2097
1885
  filter(
2098
- predicate: (value: T, key: T, iter: this) => any,
2099
- context?: any
1886
+ predicate: (value: T, key: T, iter: this) => unknown,
1887
+ context?: unknown
2100
1888
  ): this;
2101
1889
 
2102
1890
  /**
@@ -2112,9 +1900,14 @@ declare module Immutable {
2112
1900
  * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2113
1901
  * ```
2114
1902
  */
2115
- zip<U>(other: Collection<any, U>): OrderedSet<[T,U]>;
2116
- zip<U,V>(other1: Collection<any, U>, other2: Collection<any, V>): OrderedSet<[T,U,V]>;
2117
- zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
1903
+ zip<U>(other: Collection<unknown, U>): OrderedSet<[T, U]>;
1904
+ zip<U, V>(
1905
+ other1: Collection<unknown, U>,
1906
+ other2: Collection<unknown, V>
1907
+ ): OrderedSet<[T, U, V]>;
1908
+ zip(
1909
+ ...collections: Array<Collection<unknown, unknown>>
1910
+ ): OrderedSet<unknown>;
2118
1911
 
2119
1912
  /**
2120
1913
  * Returns a OrderedSet of the same type "zipped" with the provided
@@ -2133,9 +1926,14 @@ declare module Immutable {
2133
1926
  * input, some results may contain undefined values. TypeScript cannot
2134
1927
  * account for these without cases (as of v2.5).
2135
1928
  */
2136
- zipAll<U>(other: Collection<any, U>): OrderedSet<[T,U]>;
2137
- zipAll<U,V>(other1: Collection<any, U>, other2: Collection<any, V>): OrderedSet<[T,U,V]>;
2138
- zipAll(...collections: Array<Collection<any, any>>): OrderedSet<any>;
1929
+ zipAll<U>(other: Collection<unknown, U>): OrderedSet<[T, U]>;
1930
+ zipAll<U, V>(
1931
+ other1: Collection<unknown, U>,
1932
+ other2: Collection<unknown, V>
1933
+ ): OrderedSet<[T, U, V]>;
1934
+ zipAll(
1935
+ ...collections: Array<Collection<unknown, unknown>>
1936
+ ): OrderedSet<unknown>;
2139
1937
 
2140
1938
  /**
2141
1939
  * Returns an OrderedSet of the same type "zipped" with the provided
@@ -2145,21 +1943,19 @@ declare module Immutable {
2145
1943
  */
2146
1944
  zipWith<U, Z>(
2147
1945
  zipper: (value: T, otherValue: U) => Z,
2148
- otherCollection: Collection<any, U>
1946
+ otherCollection: Collection<unknown, U>
2149
1947
  ): OrderedSet<Z>;
2150
1948
  zipWith<U, V, Z>(
2151
1949
  zipper: (value: T, otherValue: U, thirdValue: V) => Z,
2152
- otherCollection: Collection<any, U>,
2153
- thirdCollection: Collection<any, V>
1950
+ otherCollection: Collection<unknown, U>,
1951
+ thirdCollection: Collection<unknown, V>
2154
1952
  ): OrderedSet<Z>;
2155
1953
  zipWith<Z>(
2156
- zipper: (...any: Array<any>) => Z,
2157
- ...collections: Array<Collection<any, any>>
1954
+ zipper: (...values: Array<unknown>) => Z,
1955
+ ...collections: Array<Collection<unknown, unknown>>
2158
1956
  ): OrderedSet<Z>;
2159
-
2160
1957
  }
2161
1958
 
2162
-
2163
1959
  /**
2164
1960
  * Stacks are indexed collections which support very efficient O(1) addition
2165
1961
  * and removal from the front using `unshift(v)` and `shift()`.
@@ -2173,12 +1969,11 @@ declare module Immutable {
2173
1969
  *
2174
1970
  * Stack is implemented with a Single-Linked List.
2175
1971
  */
2176
- export module Stack {
2177
-
1972
+ namespace Stack {
2178
1973
  /**
2179
1974
  * True if the provided value is a Stack
2180
1975
  */
2181
- function isStack(maybeStack: any): maybeStack is Stack<any>;
1976
+ function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
2182
1977
 
2183
1978
  /**
2184
1979
  * Creates a new Stack containing `values`.
@@ -2192,13 +1987,13 @@ declare module Immutable {
2192
1987
  *
2193
1988
  * The iteration order of the provided collection is preserved in the
2194
1989
  * resulting `Stack`.
1990
+ *
1991
+ * Note: `Stack` is a factory function and not a class, and does not use the
1992
+ * `new` keyword during construction.
2195
1993
  */
2196
- export function Stack(): Stack<any>;
2197
- export function Stack<T>(): Stack<T>;
2198
- export function Stack<T>(collection: Iterable<T>): Stack<T>;
2199
-
2200
- export interface Stack<T> extends Collection.Indexed<T> {
1994
+ function Stack<T>(collection?: Iterable<T> | ArrayLike<T>): Stack<T>;
2201
1995
 
1996
+ interface Stack<T> extends Collection.Indexed<T> {
2202
1997
  /**
2203
1998
  * The number of items in this Stack.
2204
1999
  */
@@ -2211,7 +2006,6 @@ declare module Immutable {
2211
2006
  */
2212
2007
  peek(): T | undefined;
2213
2008
 
2214
-
2215
2009
  // Persistent changes
2216
2010
 
2217
2011
  /**
@@ -2265,7 +2059,6 @@ declare module Immutable {
2265
2059
  */
2266
2060
  pop(): Stack<T>;
2267
2061
 
2268
-
2269
2062
  // Transient changes
2270
2063
 
2271
2064
  /**
@@ -2275,7 +2068,7 @@ declare module Immutable {
2275
2068
  *
2276
2069
  * @see `Map#withMutations`
2277
2070
  */
2278
- withMutations(mutator: (mutable: this) => any): this;
2071
+ withMutations(mutator: (mutable: this) => unknown): this;
2279
2072
 
2280
2073
  /**
2281
2074
  * Note: Not all methods can be used on a mutable collection or within
@@ -2315,7 +2108,7 @@ declare module Immutable {
2315
2108
  */
2316
2109
  map<M>(
2317
2110
  mapper: (value: T, key: number, iter: this) => M,
2318
- context?: any
2111
+ context?: unknown
2319
2112
  ): Stack<M>;
2320
2113
 
2321
2114
  /**
@@ -2325,7 +2118,7 @@ declare module Immutable {
2325
2118
  */
2326
2119
  flatMap<M>(
2327
2120
  mapper: (value: T, key: number, iter: this) => Iterable<M>,
2328
- context?: any
2121
+ context?: unknown
2329
2122
  ): Stack<M>;
2330
2123
 
2331
2124
  /**
@@ -2337,11 +2130,11 @@ declare module Immutable {
2337
2130
  */
2338
2131
  filter<F extends T>(
2339
2132
  predicate: (value: T, index: number, iter: this) => value is F,
2340
- context?: any
2133
+ context?: unknown
2341
2134
  ): Set<F>;
2342
2135
  filter(
2343
- predicate: (value: T, index: number, iter: this) => any,
2344
- context?: any
2136
+ predicate: (value: T, index: number, iter: this) => unknown,
2137
+ context?: unknown
2345
2138
  ): this;
2346
2139
 
2347
2140
  /**
@@ -2355,9 +2148,12 @@ declare module Immutable {
2355
2148
  * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2356
2149
  * ```
2357
2150
  */
2358
- zip<U>(other: Collection<any, U>): Stack<[T,U]>;
2359
- zip<U,V>(other: Collection<any, U>, other2: Collection<any,V>): Stack<[T,U,V]>;
2360
- zip(...collections: Array<Collection<any, any>>): Stack<any>;
2151
+ zip<U>(other: Collection<unknown, U>): Stack<[T, U]>;
2152
+ zip<U, V>(
2153
+ other: Collection<unknown, U>,
2154
+ other2: Collection<unknown, V>
2155
+ ): Stack<[T, U, V]>;
2156
+ zip(...collections: Array<Collection<unknown, unknown>>): Stack<unknown>;
2361
2157
 
2362
2158
  /**
2363
2159
  * Returns a Stack "zipped" with the provided collections.
@@ -2375,9 +2171,12 @@ declare module Immutable {
2375
2171
  * input, some results may contain undefined values. TypeScript cannot
2376
2172
  * account for these without cases (as of v2.5).
2377
2173
  */
2378
- zipAll<U>(other: Collection<any, U>): Stack<[T,U]>;
2379
- zipAll<U,V>(other: Collection<any, U>, other2: Collection<any,V>): Stack<[T,U,V]>;
2380
- zipAll(...collections: Array<Collection<any, any>>): Stack<any>;
2174
+ zipAll<U>(other: Collection<unknown, U>): Stack<[T, U]>;
2175
+ zipAll<U, V>(
2176
+ other: Collection<unknown, U>,
2177
+ other2: Collection<unknown, V>
2178
+ ): Stack<[T, U, V]>;
2179
+ zipAll(...collections: Array<Collection<unknown, unknown>>): Stack<unknown>;
2381
2180
 
2382
2181
  /**
2383
2182
  * Returns a Stack "zipped" with the provided collections by using a
@@ -2392,27 +2191,29 @@ declare module Immutable {
2392
2191
  */
2393
2192
  zipWith<U, Z>(
2394
2193
  zipper: (value: T, otherValue: U) => Z,
2395
- otherCollection: Collection<any, U>
2194
+ otherCollection: Collection<unknown, U>
2396
2195
  ): Stack<Z>;
2397
2196
  zipWith<U, V, Z>(
2398
2197
  zipper: (value: T, otherValue: U, thirdValue: V) => Z,
2399
- otherCollection: Collection<any, U>,
2400
- thirdCollection: Collection<any, V>
2198
+ otherCollection: Collection<unknown, U>,
2199
+ thirdCollection: Collection<unknown, V>
2401
2200
  ): Stack<Z>;
2402
2201
  zipWith<Z>(
2403
- zipper: (...any: Array<any>) => Z,
2404
- ...collections: Array<Collection<any, any>>
2202
+ zipper: (...values: Array<unknown>) => Z,
2203
+ ...collections: Array<Collection<unknown, unknown>>
2405
2204
  ): Stack<Z>;
2406
2205
  }
2407
2206
 
2408
-
2409
2207
  /**
2410
2208
  * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end`
2411
2209
  * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to
2412
2210
  * infinity. When `start` is equal to `end`, returns empty range.
2413
2211
  *
2212
+ * Note: `Range` is a factory function and not a class, and does not use the
2213
+ * `new` keyword during construction.
2214
+ *
2414
2215
  * ```js
2415
- * const { Range } = require('immutable@4.0.0-rc.8')
2216
+ * const { Range } = require('immutable')
2416
2217
  * Range() // [ 0, 1, 2, 3, ... ]
2417
2218
  * Range(10) // [ 10, 11, 12, 13, ... ]
2418
2219
  * Range(10, 15) // [ 10, 11, 12, 13, 14 ]
@@ -2421,21 +2222,26 @@ declare module Immutable {
2421
2222
  * Range(30, 30, 5) // []
2422
2223
  * ```
2423
2224
  */
2424
- export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
2425
-
2225
+ function Range(
2226
+ start?: number,
2227
+ end?: number,
2228
+ step?: number
2229
+ ): Seq.Indexed<number>;
2426
2230
 
2427
2231
  /**
2428
2232
  * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is
2429
2233
  * not defined, returns an infinite `Seq` of `value`.
2430
2234
  *
2235
+ * Note: `Repeat` is a factory function and not a class, and does not use the
2236
+ * `new` keyword during construction.
2237
+ *
2431
2238
  * ```js
2432
- * const { Repeat } = require('immutable@4.0.0-rc.8')
2239
+ * const { Repeat } = require('immutable')
2433
2240
  * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ]
2434
2241
  * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ]
2435
2242
  * ```
2436
2243
  */
2437
- export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
2438
-
2244
+ function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
2439
2245
 
2440
2246
  /**
2441
2247
  * A record is similar to a JS object, but enforces a specific set of allowed
@@ -2445,21 +2251,19 @@ declare module Immutable {
2445
2251
  * create Record instances.
2446
2252
  *
2447
2253
  * ```js
2448
- * const { Record } = require('immutable@4.0.0-rc.8')
2254
+ * const { Record } = require('immutable')
2449
2255
  * const ABRecord = Record({ a: 1, b: 2 })
2450
- * const myRecord = new ABRecord({ b: 3 })
2256
+ * const myRecord = ABRecord({ b: 3 })
2451
2257
  * ```
2452
2258
  *
2453
2259
  * Records always have a value for the keys they define. `remove`ing a key
2454
2260
  * from a record simply resets it to the default value for that key.
2455
2261
  *
2456
2262
  * ```js
2457
- * myRecord.size // 2
2458
2263
  * myRecord.get('a') // 1
2459
2264
  * myRecord.get('b') // 3
2460
2265
  * const myRecordWithoutB = myRecord.remove('b')
2461
2266
  * myRecordWithoutB.get('b') // 2
2462
- * myRecordWithoutB.size // 2
2463
2267
  * ```
2464
2268
  *
2465
2269
  * Values provided to the constructor not found in the Record type will
@@ -2468,7 +2272,7 @@ declare module Immutable {
2468
2272
  * ignored for this record.
2469
2273
  *
2470
2274
  * ```js
2471
- * const myRecord = new ABRecord({ b: 3, x: 10 })
2275
+ * const myRecord = ABRecord({ b: 3, x: 10 })
2472
2276
  * myRecord.get('x') // undefined
2473
2277
  * ```
2474
2278
  *
@@ -2483,10 +2287,20 @@ declare module Immutable {
2483
2287
  * myRecord.b = 5 // throws Error
2484
2288
  * ```
2485
2289
  *
2486
- * Record Classes can be extended as well, allowing for custom methods on your
2290
+ * Record Types can be extended as well, allowing for custom methods on your
2487
2291
  * Record. This is not a common pattern in functional environments, but is in
2488
2292
  * many JS programs.
2489
2293
  *
2294
+ * However Record Types are more restricted than typical JavaScript classes.
2295
+ * They do not use a class constructor, which also means they cannot use
2296
+ * class properties (since those are technically part of a constructor).
2297
+ *
2298
+ * While Record Types can be syntactically created with the JavaScript `class`
2299
+ * form, the resulting Record function is actually a factory function, not a
2300
+ * class constructor. Even though Record Types are not classes, JavaScript
2301
+ * currently requires the use of `new` when creating new Record instances if
2302
+ * they are defined as a `class`.
2303
+ *
2490
2304
  * ```
2491
2305
  * class ABRecord extends Record({ a: 1, b: 2 }) {
2492
2306
  * getAB() {
@@ -2502,12 +2316,12 @@ declare module Immutable {
2502
2316
  * **Flow Typing Records:**
2503
2317
  *
2504
2318
  * Immutable.js exports two Flow types designed to make it easier to use
2505
- * Records with flow typed code, `RecordOf<T>` and `RecordFactory<TProps>`.
2319
+ * Records with flow typed code, `RecordOf<TProps>` and `RecordFactory<TProps>`.
2506
2320
  *
2507
2321
  * When defining a new kind of Record factory function, use a flow type that
2508
2322
  * describes the values the record contains along with `RecordFactory<TProps>`.
2509
2323
  * To type instances of the Record (which the factory function returns),
2510
- * use `RecordOf<T>`.
2324
+ * use `RecordOf<TProps>`.
2511
2325
  *
2512
2326
  * Typically, new Record definitions will export both the Record factory
2513
2327
  * function as well as the Record instance type for use in other code.
@@ -2517,7 +2331,8 @@ declare module Immutable {
2517
2331
  *
2518
2332
  * // Use RecordFactory<TProps> for defining new Record factory functions.
2519
2333
  * type Point3DProps = { x: number, y: number, z: number };
2520
- * const makePoint3D: RecordFactory<Point3DProps> = Record({ x: 0, y: 0, z: 0 });
2334
+ * const defaultValues: Point3DProps = { x: 0, y: 0, z: 0 };
2335
+ * const makePoint3D: RecordFactory<Point3DProps> = Record(defaultValues);
2521
2336
  * export makePoint3D;
2522
2337
  *
2523
2338
  * // Use RecordOf<T> for defining new instances of that Record.
@@ -2525,10 +2340,34 @@ declare module Immutable {
2525
2340
  * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 });
2526
2341
  * ```
2527
2342
  *
2343
+ * **Flow Typing Record Subclasses:**
2344
+ *
2345
+ * Records can be subclassed as a means to add additional methods to Record
2346
+ * instances. This is generally discouraged in favor of a more functional API,
2347
+ * since Subclasses have some minor overhead. However the ability to create
2348
+ * a rich API on Record types can be quite valuable.
2349
+ *
2350
+ * When using Flow to type Subclasses, do not use `RecordFactory<TProps>`,
2351
+ * instead apply the props type when subclassing:
2352
+ *
2353
+ * ```js
2354
+ * type PersonProps = {name: string, age: number};
2355
+ * const defaultValues: PersonProps = {name: 'Aristotle', age: 2400};
2356
+ * const PersonRecord = Record(defaultValues);
2357
+ * class Person extends PersonRecord<PersonProps> {
2358
+ * getName(): string {
2359
+ * return this.get('name')
2360
+ * }
2361
+ *
2362
+ * setName(name: string): this {
2363
+ * return this.set('name', name);
2364
+ * }
2365
+ * }
2366
+ * ```
2528
2367
  *
2529
2368
  * **Choosing Records vs plain JavaScript objects**
2530
2369
  *
2531
- * Records ofters a persistently immutable alternative to plain JavaScript
2370
+ * Records offer a persistently immutable alternative to plain JavaScript
2532
2371
  * objects, however they're not required to be used within Immutable.js
2533
2372
  * collections. In fact, the deep-access and deep-updating functions
2534
2373
  * like `getIn()` and `setIn()` work with plain JavaScript Objects as well.
@@ -2563,12 +2402,11 @@ declare module Immutable {
2563
2402
  * form isn't free. If converting Records to plain objects is common,
2564
2403
  * consider sticking with plain objects to begin with.
2565
2404
  */
2566
- export module Record {
2567
-
2405
+ namespace Record {
2568
2406
  /**
2569
2407
  * True if `maybeRecord` is an instance of a Record.
2570
2408
  */
2571
- export function isRecord(maybeRecord: any): maybeRecord is Record<any>;
2409
+ function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
2572
2410
 
2573
2411
  /**
2574
2412
  * Records allow passing a second parameter to supply a descriptive name
@@ -2577,7 +2415,7 @@ declare module Immutable {
2577
2415
  * method. If one was not provided, the string "Record" is returned.
2578
2416
  *
2579
2417
  * ```js
2580
- * const { Record } = require('immutable@4.0.0-rc.8')
2418
+ * const { Record } = require('immutable')
2581
2419
  * const Person = Record({
2582
2420
  * name: null
2583
2421
  * }, 'Person')
@@ -2587,7 +2425,7 @@ declare module Immutable {
2587
2425
  * Record.getDescriptiveName(me) // "Person"
2588
2426
  * ```
2589
2427
  */
2590
- export function getDescriptiveName(record: Record<any>): string;
2428
+ function getDescriptiveName(record: Record<any>): string;
2591
2429
 
2592
2430
  /**
2593
2431
  * A Record.Factory is created by the `Record()` function. Record instances
@@ -2595,7 +2433,7 @@ declare module Immutable {
2595
2433
  * type:
2596
2434
  *
2597
2435
  * <!-- runkit:activate
2598
- * { "preamble": "const { Record } = require('immutable@4.0.0-rc.8')" }
2436
+ * { "preamble": "const { Record } = require('immutable')" }
2599
2437
  * -->
2600
2438
  * ```js
2601
2439
  * // makePerson is a Record Factory function
@@ -2610,7 +2448,7 @@ declare module Immutable {
2610
2448
  * access on the resulting instances:
2611
2449
  *
2612
2450
  * <!-- runkit:activate
2613
- * { "preamble": "const { Record } = require('immutable@4.0.0-rc.8');const makePerson = Record({ name: null, favoriteColor: 'unknown' });const alan = makePerson({ name: 'Alan' });" }
2451
+ * { "preamble": "const { Record } = require('immutable');const makePerson = Record({ name: null, favoriteColor: 'unknown' });const alan = makePerson({ name: 'Alan' });" }
2614
2452
  * -->
2615
2453
  * ```js
2616
2454
  * // Use the Record API
@@ -2637,14 +2475,25 @@ declare module Immutable {
2637
2475
  * const alan: Person = makePerson({ name: 'Alan' });
2638
2476
  * ```
2639
2477
  */
2640
- export module Factory {}
2478
+ namespace Factory {}
2641
2479
 
2642
- export interface Factory<TProps extends Object> {
2643
- (values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>;
2644
- new (values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>;
2480
+ interface Factory<TProps extends object> {
2481
+ (values?: Partial<TProps> | Iterable<[string, unknown]>): Record<TProps> &
2482
+ Readonly<TProps>;
2483
+ new (
2484
+ values?: Partial<TProps> | Iterable<[string, unknown]>
2485
+ ): Record<TProps> & Readonly<TProps>;
2486
+
2487
+ /**
2488
+ * The name provided to `Record(values, name)` can be accessed with
2489
+ * `displayName`.
2490
+ */
2491
+ displayName: string;
2645
2492
  }
2646
2493
 
2647
- export function Factory<TProps extends Object>(values?: Partial<TProps> | Iterable<[string, any]>): Record<TProps> & Readonly<TProps>;
2494
+ function Factory<TProps extends object>(
2495
+ values?: Partial<TProps> | Iterable<[string, unknown]>
2496
+ ): Record<TProps> & Readonly<TProps>;
2648
2497
  }
2649
2498
 
2650
2499
  /**
@@ -2652,14 +2501,19 @@ declare module Immutable {
2652
2501
  * Record Factory, which is a function that creates Record instances.
2653
2502
  *
2654
2503
  * See above for examples of using `Record()`.
2504
+ *
2505
+ * Note: `Record` is a factory function and not a class, and does not use the
2506
+ * `new` keyword during construction.
2655
2507
  */
2656
- export function Record<TProps>(defaultValues: TProps, name?: string): Record.Factory<TProps>;
2657
-
2658
- export interface Record<TProps extends Object> {
2508
+ function Record<TProps extends object>(
2509
+ defaultValues: TProps,
2510
+ name?: string
2511
+ ): Record.Factory<TProps>;
2659
2512
 
2513
+ interface Record<TProps extends object> {
2660
2514
  // Reading values
2661
2515
 
2662
- has(key: string): key is keyof TProps;
2516
+ has(key: string): key is keyof TProps & string;
2663
2517
 
2664
2518
  /**
2665
2519
  * Returns the value associated with the provided key, which may be the
@@ -2669,32 +2523,40 @@ declare module Immutable {
2669
2523
  * notSetValue will be returned if provided. Note that this scenario would
2670
2524
  * produce an error when using Flow or TypeScript.
2671
2525
  */
2672
- get<K extends keyof TProps>(key: K, notSetValue: any): TProps[K];
2526
+ get<K extends keyof TProps>(key: K, notSetValue?: unknown): TProps[K];
2527
+ get<T>(key: string, notSetValue: T): T;
2673
2528
 
2674
2529
  // Reading deep values
2675
2530
 
2676
- hasIn(keyPath: Iterable<any>): boolean;
2677
- getIn(keyPath: Iterable<any>): any;
2531
+ hasIn(keyPath: Iterable<unknown>): boolean;
2532
+ getIn(keyPath: Iterable<unknown>): unknown;
2678
2533
 
2679
2534
  // Value equality
2680
2535
 
2681
- equals(other: any): boolean;
2536
+ equals(other: unknown): boolean;
2682
2537
  hashCode(): number;
2683
2538
 
2684
2539
  // Persistent changes
2685
2540
 
2686
2541
  set<K extends keyof TProps>(key: K, value: TProps[K]): this;
2687
- update<K extends keyof TProps>(key: K, updater: (value: TProps[K]) => TProps[K]): this;
2688
- merge(...collections: Array<Partial<TProps> | Iterable<[string, any]>>): this;
2689
- mergeDeep(...collections: Array<Partial<TProps> | Iterable<[string, any]>>): this;
2542
+ update<K extends keyof TProps>(
2543
+ key: K,
2544
+ updater: (value: TProps[K]) => TProps[K]
2545
+ ): this;
2546
+ merge(
2547
+ ...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
2548
+ ): this;
2549
+ mergeDeep(
2550
+ ...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
2551
+ ): this;
2690
2552
 
2691
2553
  mergeWith(
2692
- merger: (oldVal: any, newVal: any, key: keyof TProps) => any,
2693
- ...collections: Array<Partial<TProps> | Iterable<[string, any]>>
2554
+ merger: (oldVal: unknown, newVal: unknown, key: keyof TProps) => unknown,
2555
+ ...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
2694
2556
  ): this;
2695
2557
  mergeDeepWith(
2696
- merger: (oldVal: any, newVal: any, key: any) => any,
2697
- ...collections: Array<Partial<TProps> | Iterable<[string, any]>>
2558
+ merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
2559
+ ...collections: Array<Partial<TProps> | Iterable<[string, unknown]>>
2698
2560
  ): this;
2699
2561
 
2700
2562
  /**
@@ -2714,23 +2576,32 @@ declare module Immutable {
2714
2576
 
2715
2577
  // Deep persistent changes
2716
2578
 
2717
- setIn(keyPath: Iterable<any>, value: any): this;
2718
- updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
2719
- mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
2720
- mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
2579
+ setIn(keyPath: Iterable<unknown>, value: unknown): this;
2580
+ updateIn(
2581
+ keyPath: Iterable<unknown>,
2582
+ updater: (value: unknown) => unknown
2583
+ ): this;
2584
+ mergeIn(keyPath: Iterable<unknown>, ...collections: Array<unknown>): this;
2585
+ mergeDeepIn(
2586
+ keyPath: Iterable<unknown>,
2587
+ ...collections: Array<unknown>
2588
+ ): this;
2721
2589
 
2722
2590
  /**
2723
2591
  * @alias removeIn
2724
2592
  */
2725
- deleteIn(keyPath: Iterable<any>): this;
2726
- removeIn(keyPath: Iterable<any>): this;
2593
+ deleteIn(keyPath: Iterable<unknown>): this;
2594
+ removeIn(keyPath: Iterable<unknown>): this;
2727
2595
 
2728
2596
  // Conversion to JavaScript types
2729
2597
 
2730
2598
  /**
2731
2599
  * Deeply converts this Record to equivalent native JavaScript Object.
2600
+ *
2601
+ * Note: This method may not be overridden. Objects with custom
2602
+ * serialization to plain JS may override toJSON() instead.
2732
2603
  */
2733
- toJS(): { [K in keyof TProps]: any };
2604
+ toJS(): { [K in keyof TProps]: unknown };
2734
2605
 
2735
2606
  /**
2736
2607
  * Shallowly converts this Record to equivalent native JavaScript Object.
@@ -2750,7 +2621,7 @@ declare module Immutable {
2750
2621
  *
2751
2622
  * @see `Map#withMutations`
2752
2623
  */
2753
- withMutations(mutator: (mutable: this) => any): this;
2624
+ withMutations(mutator: (mutable: this) => unknown): this;
2754
2625
 
2755
2626
  /**
2756
2627
  * @see `Map#asMutable`
@@ -2774,6 +2645,14 @@ declare module Immutable {
2774
2645
  [Symbol.iterator](): IterableIterator<[keyof TProps, TProps[keyof TProps]]>;
2775
2646
  }
2776
2647
 
2648
+ /**
2649
+ * RecordOf<T> is used in TypeScript to define interfaces expecting an
2650
+ * instance of record with type T.
2651
+ *
2652
+ * This is equivalent to an instance of a record created by a Record Factory.
2653
+ */
2654
+ type RecordOf<TProps extends object> = Record<TProps> & Readonly<TProps>;
2655
+
2777
2656
  /**
2778
2657
  * `Seq` describes a lazy operation, allowing them to efficiently chain
2779
2658
  * use of all the higher-order collection methods (such as `map` and `filter`)
@@ -2792,7 +2671,7 @@ declare module Immutable {
2792
2671
  * `Seq`'s values are never iterated:
2793
2672
  *
2794
2673
  * ```js
2795
- * const { Seq } = require('immutable@4.0.0-rc.8')
2674
+ * const { Seq } = require('immutable')
2796
2675
  * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ])
2797
2676
  * .filter(x => x % 2 !== 0)
2798
2677
  * .map(x => x * x)
@@ -2811,7 +2690,7 @@ declare module Immutable {
2811
2690
  * <!-- runkit:activate -->
2812
2691
  * ```js
2813
2692
  * const { Map } = require('immutable')
2814
- * const map = Map({ a: 1, b: 2, c: 3 }
2693
+ * const map = Map({ a: 1, b: 2, c: 3 })
2815
2694
  * const lazySeq = Seq(map)
2816
2695
  * ```
2817
2696
  *
@@ -2831,7 +2710,7 @@ declare module Immutable {
2831
2710
  *
2832
2711
  * <!-- runkit:activate -->
2833
2712
  * ```js
2834
- * const { Range } = require('immutable@4.0.0-rc.8')
2713
+ * const { Range } = require('immutable')
2835
2714
  * Range(1, Infinity)
2836
2715
  * .skip(1000)
2837
2716
  * .map(n => -n)
@@ -2849,35 +2728,40 @@ declare module Immutable {
2849
2728
  * ```
2850
2729
  */
2851
2730
 
2852
- export module Seq {
2731
+ namespace Seq {
2853
2732
  /**
2854
2733
  * True if `maybeSeq` is a Seq, it is not backed by a concrete
2855
2734
  * structure such as Map, List, or Set.
2856
2735
  */
2857
- function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed<any> | Seq.Keyed<any, any>;
2858
-
2736
+ function isSeq(
2737
+ maybeSeq: unknown
2738
+ ): maybeSeq is
2739
+ | Seq.Indexed<unknown>
2740
+ | Seq.Keyed<unknown, unknown>
2741
+ | Seq.Set<unknown>;
2859
2742
 
2860
2743
  /**
2861
2744
  * `Seq` which represents key-value pairs.
2862
2745
  */
2863
- export module Keyed {}
2746
+ namespace Keyed {}
2864
2747
 
2865
2748
  /**
2866
2749
  * Always returns a Seq.Keyed, if input is not keyed, expects an
2867
2750
  * collection of [K, V] tuples.
2751
+ *
2752
+ * Note: `Seq.Keyed` is a conversion function and not a class, and does not
2753
+ * use the `new` keyword during construction.
2868
2754
  */
2869
- export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
2870
- export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
2871
- export function Keyed<K, V>(): Seq.Keyed<K, V>;
2872
- export function Keyed(): Seq.Keyed<any, any>;
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>;
2873
2757
 
2874
- 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> {
2875
2759
  /**
2876
2760
  * Deeply converts this Keyed Seq to equivalent native JavaScript Object.
2877
2761
  *
2878
2762
  * Converts keys to Strings.
2879
2763
  */
2880
- toJS(): Object;
2764
+ toJS(): { [key: string]: unknown };
2881
2765
 
2882
2766
  /**
2883
2767
  * Shallowly converts this Keyed Seq to equivalent native JavaScript Object.
@@ -2902,15 +2786,19 @@ declare module Immutable {
2902
2786
  * All entries will be present in the resulting Seq, even if they
2903
2787
  * have the same key.
2904
2788
  */
2905
- concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Seq.Keyed<K | KC, V | VC>;
2906
- concat<C>(...collections: Array<{[key: string]: C}>): Seq.Keyed<K | string, V | C>;
2789
+ concat<KC, VC>(
2790
+ ...collections: Array<Iterable<[KC, VC]>>
2791
+ ): Seq.Keyed<K | KC, V | VC>;
2792
+ concat<C>(
2793
+ ...collections: Array<{ [key: string]: C }>
2794
+ ): Seq.Keyed<K | string, V | C>;
2907
2795
 
2908
2796
  /**
2909
2797
  * Returns a new Seq.Keyed with values passed through a
2910
2798
  * `mapper` function.
2911
2799
  *
2912
2800
  * ```js
2913
- * const { Seq } = require('immutable@4.0.0-rc.8')
2801
+ * const { Seq } = require('immutable')
2914
2802
  * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x)
2915
2803
  * // Seq { "a": 10, "b": 20 }
2916
2804
  * ```
@@ -2920,7 +2808,7 @@ declare module Immutable {
2920
2808
  */
2921
2809
  map<M>(
2922
2810
  mapper: (value: V, key: K, iter: this) => M,
2923
- context?: any
2811
+ context?: unknown
2924
2812
  ): Seq.Keyed<K, M>;
2925
2813
 
2926
2814
  /**
@@ -2928,15 +2816,19 @@ declare module Immutable {
2928
2816
  */
2929
2817
  mapKeys<M>(
2930
2818
  mapper: (key: K, value: V, iter: this) => M,
2931
- context?: any
2819
+ context?: unknown
2932
2820
  ): Seq.Keyed<M, V>;
2933
2821
 
2934
2822
  /**
2935
2823
  * @see Collection.Keyed.mapEntries
2936
2824
  */
2937
2825
  mapEntries<KM, VM>(
2938
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
2939
- context?: any
2826
+ mapper: (
2827
+ entry: [K, V],
2828
+ index: number,
2829
+ iter: this
2830
+ ) => [KM, VM] | undefined,
2831
+ context?: unknown
2940
2832
  ): Seq.Keyed<KM, VM>;
2941
2833
 
2942
2834
  /**
@@ -2946,7 +2838,7 @@ declare module Immutable {
2946
2838
  */
2947
2839
  flatMap<KM, VM>(
2948
2840
  mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
2949
- context?: any
2841
+ context?: unknown
2950
2842
  ): Seq.Keyed<KM, VM>;
2951
2843
 
2952
2844
  /**
@@ -2958,25 +2850,25 @@ declare module Immutable {
2958
2850
  */
2959
2851
  filter<F extends V>(
2960
2852
  predicate: (value: V, key: K, iter: this) => value is F,
2961
- context?: any
2853
+ context?: unknown
2962
2854
  ): Seq.Keyed<K, F>;
2963
2855
  filter(
2964
- predicate: (value: V, key: K, iter: this) => any,
2965
- context?: any
2856
+ predicate: (value: V, key: K, iter: this) => unknown,
2857
+ context?: unknown
2966
2858
  ): this;
2967
2859
 
2968
2860
  /**
2969
2861
  * @see Collection.Keyed.flip
2970
2862
  */
2971
2863
  flip(): Seq.Keyed<V, K>;
2972
- }
2973
2864
 
2865
+ [Symbol.iterator](): IterableIterator<[K, V]>;
2866
+ }
2974
2867
 
2975
2868
  /**
2976
2869
  * `Seq` which represents an ordered indexed list of values.
2977
2870
  */
2978
- module Indexed {
2979
-
2871
+ namespace Indexed {
2980
2872
  /**
2981
2873
  * Provides an Seq.Indexed of the values provided.
2982
2874
  */
@@ -2986,16 +2878,19 @@ declare module Immutable {
2986
2878
  /**
2987
2879
  * Always returns Seq.Indexed, discarding associated keys and
2988
2880
  * supplying incrementing indices.
2881
+ *
2882
+ * Note: `Seq.Indexed` is a conversion function and not a class, and does
2883
+ * not use the `new` keyword during construction.
2989
2884
  */
2990
- export function Indexed(): Seq.Indexed<any>;
2991
- export function Indexed<T>(): Seq.Indexed<T>;
2992
- export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
2885
+ function Indexed<T>(
2886
+ collection?: Iterable<T> | ArrayLike<T>
2887
+ ): Seq.Indexed<T>;
2993
2888
 
2994
- export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
2889
+ interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
2995
2890
  /**
2996
2891
  * Deeply converts this Indexed Seq to equivalent native JavaScript Array.
2997
2892
  */
2998
- toJS(): Array<any>;
2893
+ toJS(): Array<unknown>;
2999
2894
 
3000
2895
  /**
3001
2896
  * Shallowly converts this Indexed Seq to equivalent native JavaScript Array.
@@ -3010,19 +2905,21 @@ declare module Immutable {
3010
2905
  /**
3011
2906
  * Returns itself
3012
2907
  */
3013
- toSeq(): this
2908
+ toSeq(): this;
3014
2909
 
3015
2910
  /**
3016
2911
  * Returns a new Seq with other collections concatenated to this one.
3017
2912
  */
3018
- concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Indexed<T | C>;
2913
+ concat<C>(
2914
+ ...valuesOrCollections: Array<Iterable<C> | C>
2915
+ ): Seq.Indexed<T | C>;
3019
2916
 
3020
2917
  /**
3021
2918
  * Returns a new Seq.Indexed with values passed through a
3022
2919
  * `mapper` function.
3023
2920
  *
3024
2921
  * ```js
3025
- * const { Seq } = require('immutable@4.0.0-rc.8')
2922
+ * const { Seq } = require('immutable')
3026
2923
  * Seq.Indexed([ 1, 2 ]).map(x => 10 * x)
3027
2924
  * // Seq [ 10, 20 ]
3028
2925
  * ```
@@ -3032,7 +2929,7 @@ declare module Immutable {
3032
2929
  */
3033
2930
  map<M>(
3034
2931
  mapper: (value: T, key: number, iter: this) => M,
3035
- context?: any
2932
+ context?: unknown
3036
2933
  ): Seq.Indexed<M>;
3037
2934
 
3038
2935
  /**
@@ -3042,7 +2939,7 @@ declare module Immutable {
3042
2939
  */
3043
2940
  flatMap<M>(
3044
2941
  mapper: (value: T, key: number, iter: this) => Iterable<M>,
3045
- context?: any
2942
+ context?: unknown
3046
2943
  ): Seq.Indexed<M>;
3047
2944
 
3048
2945
  /**
@@ -3054,11 +2951,11 @@ declare module Immutable {
3054
2951
  */
3055
2952
  filter<F extends T>(
3056
2953
  predicate: (value: T, index: number, iter: this) => value is F,
3057
- context?: any
2954
+ context?: unknown
3058
2955
  ): Seq.Indexed<F>;
3059
2956
  filter(
3060
- predicate: (value: T, index: number, iter: this) => any,
3061
- context?: any
2957
+ predicate: (value: T, index: number, iter: this) => unknown,
2958
+ context?: unknown
3062
2959
  ): this;
3063
2960
 
3064
2961
  /**
@@ -3072,9 +2969,14 @@ declare module Immutable {
3072
2969
  * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
3073
2970
  * ```
3074
2971
  */
3075
- zip<U>(other: Collection<any, U>): Seq.Indexed<[T,U]>;
3076
- zip<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Seq.Indexed<[T,U,V]>;
3077
- zip(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
2972
+ zip<U>(other: Collection<unknown, U>): Seq.Indexed<[T, U]>;
2973
+ zip<U, V>(
2974
+ other: Collection<unknown, U>,
2975
+ other2: Collection<unknown, V>
2976
+ ): Seq.Indexed<[T, U, V]>;
2977
+ zip(
2978
+ ...collections: Array<Collection<unknown, unknown>>
2979
+ ): Seq.Indexed<unknown>;
3078
2980
 
3079
2981
  /**
3080
2982
  * Returns a Seq "zipped" with the provided collections.
@@ -3088,9 +2990,14 @@ declare module Immutable {
3088
2990
  * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
3089
2991
  * ```
3090
2992
  */
3091
- zipAll<U>(other: Collection<any, U>): Seq.Indexed<[T,U]>;
3092
- zipAll<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Seq.Indexed<[T,U,V]>;
3093
- zipAll(...collections: Array<Collection<any, any>>): Seq.Indexed<any>;
2993
+ zipAll<U>(other: Collection<unknown, U>): Seq.Indexed<[T, U]>;
2994
+ zipAll<U, V>(
2995
+ other: Collection<unknown, U>,
2996
+ other2: Collection<unknown, V>
2997
+ ): Seq.Indexed<[T, U, V]>;
2998
+ zipAll(
2999
+ ...collections: Array<Collection<unknown, unknown>>
3000
+ ): Seq.Indexed<unknown>;
3094
3001
 
3095
3002
  /**
3096
3003
  * Returns a Seq "zipped" with the provided collections by using a
@@ -3105,19 +3012,20 @@ declare module Immutable {
3105
3012
  */
3106
3013
  zipWith<U, Z>(
3107
3014
  zipper: (value: T, otherValue: U) => Z,
3108
- otherCollection: Collection<any, U>
3015
+ otherCollection: Collection<unknown, U>
3109
3016
  ): Seq.Indexed<Z>;
3110
3017
  zipWith<U, V, Z>(
3111
3018
  zipper: (value: T, otherValue: U, thirdValue: V) => Z,
3112
- otherCollection: Collection<any, U>,
3113
- thirdCollection: Collection<any, V>
3019
+ otherCollection: Collection<unknown, U>,
3020
+ thirdCollection: Collection<unknown, V>
3114
3021
  ): Seq.Indexed<Z>;
3115
3022
  zipWith<Z>(
3116
- zipper: (...any: Array<any>) => Z,
3117
- ...collections: Array<Collection<any, any>>
3023
+ zipper: (...values: Array<unknown>) => Z,
3024
+ ...collections: Array<Collection<unknown, unknown>>
3118
3025
  ): Seq.Indexed<Z>;
3119
- }
3120
3026
 
3027
+ [Symbol.iterator](): IterableIterator<T>;
3028
+ }
3121
3029
 
3122
3030
  /**
3123
3031
  * `Seq` which represents a set of values.
@@ -3125,8 +3033,7 @@ declare module Immutable {
3125
3033
  * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee
3126
3034
  * of value uniqueness as the concrete `Set`.
3127
3035
  */
3128
- export module Set {
3129
-
3036
+ namespace Set {
3130
3037
  /**
3131
3038
  * Returns a Seq.Set of the provided values
3132
3039
  */
@@ -3135,16 +3042,17 @@ declare module Immutable {
3135
3042
 
3136
3043
  /**
3137
3044
  * Always returns a Seq.Set, discarding associated indices or keys.
3045
+ *
3046
+ * Note: `Seq.Set` is a conversion function and not a class, and does not
3047
+ * use the `new` keyword during construction.
3138
3048
  */
3139
- export function Set(): Seq.Set<any>;
3140
- export function Set<T>(): Seq.Set<T>;
3141
- export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
3049
+ function Set<T>(collection?: Iterable<T> | ArrayLike<T>): Seq.Set<T>;
3142
3050
 
3143
- export interface Set<T> extends Seq<T, T>, Collection.Set<T> {
3051
+ interface Set<T> extends Seq<T, T>, Collection.Set<T> {
3144
3052
  /**
3145
3053
  * Deeply converts this Set Seq to equivalent native JavaScript Array.
3146
3054
  */
3147
- toJS(): Array<any>;
3055
+ toJS(): Array<unknown>;
3148
3056
 
3149
3057
  /**
3150
3058
  * Shallowly converts this Set Seq to equivalent native JavaScript Array.
@@ -3159,7 +3067,7 @@ declare module Immutable {
3159
3067
  /**
3160
3068
  * Returns itself
3161
3069
  */
3162
- toSeq(): this
3070
+ toSeq(): this;
3163
3071
 
3164
3072
  /**
3165
3073
  * Returns a new Seq with other collections concatenated to this one.
@@ -3183,7 +3091,7 @@ declare module Immutable {
3183
3091
  */
3184
3092
  map<M>(
3185
3093
  mapper: (value: T, key: T, iter: this) => M,
3186
- context?: any
3094
+ context?: unknown
3187
3095
  ): Seq.Set<M>;
3188
3096
 
3189
3097
  /**
@@ -3193,7 +3101,7 @@ declare module Immutable {
3193
3101
  */
3194
3102
  flatMap<M>(
3195
3103
  mapper: (value: T, key: T, iter: this) => Iterable<M>,
3196
- context?: any
3104
+ context?: unknown
3197
3105
  ): Seq.Set<M>;
3198
3106
 
3199
3107
  /**
@@ -3205,14 +3113,15 @@ declare module Immutable {
3205
3113
  */
3206
3114
  filter<F extends T>(
3207
3115
  predicate: (value: T, key: T, iter: this) => value is F,
3208
- context?: any
3116
+ context?: unknown
3209
3117
  ): Seq.Set<F>;
3210
3118
  filter(
3211
- predicate: (value: T, key: T, iter: this) => any,
3212
- context?: any
3119
+ predicate: (value: T, key: T, iter: this) => unknown,
3120
+ context?: unknown
3213
3121
  ): this;
3214
- }
3215
3122
 
3123
+ [Symbol.iterator](): IterableIterator<T>;
3124
+ }
3216
3125
  }
3217
3126
 
3218
3127
  /**
@@ -3223,21 +3132,27 @@ declare module Immutable {
3223
3132
  * * If a `Seq`, that same `Seq`.
3224
3133
  * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set).
3225
3134
  * * If an Array-like, an `Seq.Indexed`.
3226
- * * If an Object with an Iterator, an `Seq.Indexed`.
3227
- * * If an Iterator, an `Seq.Indexed`.
3135
+ * * If an Iterable Object, an `Seq.Indexed`.
3228
3136
  * * If an Object, a `Seq.Keyed`.
3229
3137
  *
3138
+ * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`,
3139
+ * which is usually not what you want. You should turn your Iterator Object into
3140
+ * an iterable object by defining a Symbol.iterator (or @@iterator) method which
3141
+ * returns `this`.
3142
+ *
3143
+ * Note: `Seq` is a conversion function and not a class, and does not use the
3144
+ * `new` keyword during construction.
3230
3145
  */
3231
- export function Seq<S extends Seq<any, any>>(seq: S): S;
3232
- export function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
3233
- export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
3234
- export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
3235
- export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
3236
- export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
3237
- export function Seq(): Seq<any, any>;
3238
-
3239
- export interface Seq<K, V> extends Collection<K, V> {
3146
+ function Seq<S extends Seq<unknown, unknown>>(seq: S): S;
3147
+ function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
3148
+ function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
3149
+ function Seq<T>(
3150
+ collection: Collection.Indexed<T> | Iterable<T> | ArrayLike<T>
3151
+ ): Seq.Indexed<T>;
3152
+ function Seq<V>(obj: { [key: string]: V }): Seq.Keyed<string, V>;
3153
+ function Seq<K = unknown, V = unknown>(): Seq<K, V>;
3240
3154
 
3155
+ interface Seq<K, V> extends Collection<K, V> {
3241
3156
  /**
3242
3157
  * Some Seqs can describe their size lazily. When this is the case,
3243
3158
  * size will be an integer. Otherwise it will be undefined.
@@ -3250,7 +3165,6 @@ declare module Immutable {
3250
3165
  */
3251
3166
  readonly size: number | undefined;
3252
3167
 
3253
-
3254
3168
  // Force evaluation
3255
3169
 
3256
3170
  /**
@@ -3282,7 +3196,7 @@ declare module Immutable {
3282
3196
  * `mapper` function.
3283
3197
  *
3284
3198
  * ```js
3285
- * const { Seq } = require('immutable@4.0.0-rc.8')
3199
+ * const { Seq } = require('immutable')
3286
3200
  * Seq([ 1, 2 ]).map(x => 10 * x)
3287
3201
  * // Seq [ 10, 20 ]
3288
3202
  * ```
@@ -3292,7 +3206,7 @@ declare module Immutable {
3292
3206
  */
3293
3207
  map<M>(
3294
3208
  mapper: (value: V, key: K, iter: this) => M,
3295
- context?: any
3209
+ context?: unknown
3296
3210
  ): Seq<K, M>;
3297
3211
 
3298
3212
  /**
@@ -3300,7 +3214,7 @@ declare module Immutable {
3300
3214
  * `mapper` function.
3301
3215
  *
3302
3216
  * ```js
3303
- * const { Seq } = require('immutable@4.0.0-rc.8')
3217
+ * const { Seq } = require('immutable')
3304
3218
  * Seq([ 1, 2 ]).map(x => 10 * x)
3305
3219
  * // Seq [ 10, 20 ]
3306
3220
  * ```
@@ -3311,7 +3225,7 @@ declare module Immutable {
3311
3225
  */
3312
3226
  map<M>(
3313
3227
  mapper: (value: V, key: K, iter: this) => M,
3314
- context?: any
3228
+ context?: unknown
3315
3229
  ): Seq<M, M>;
3316
3230
 
3317
3231
  /**
@@ -3321,7 +3235,7 @@ declare module Immutable {
3321
3235
  */
3322
3236
  flatMap<M>(
3323
3237
  mapper: (value: V, key: K, iter: this) => Iterable<M>,
3324
- context?: any
3238
+ context?: unknown
3325
3239
  ): Seq<K, M>;
3326
3240
 
3327
3241
  /**
@@ -3332,7 +3246,7 @@ declare module Immutable {
3332
3246
  */
3333
3247
  flatMap<M>(
3334
3248
  mapper: (value: V, key: K, iter: this) => Iterable<M>,
3335
- context?: any
3249
+ context?: unknown
3336
3250
  ): Seq<M, M>;
3337
3251
 
3338
3252
  /**
@@ -3344,11 +3258,11 @@ declare module Immutable {
3344
3258
  */
3345
3259
  filter<F extends V>(
3346
3260
  predicate: (value: V, key: K, iter: this) => value is F,
3347
- context?: any
3261
+ context?: unknown
3348
3262
  ): Seq<K, F>;
3349
3263
  filter(
3350
- predicate: (value: V, key: K, iter: this) => any,
3351
- context?: any
3264
+ predicate: (value: V, key: K, iter: this) => unknown,
3265
+ context?: unknown
3352
3266
  ): this;
3353
3267
  }
3354
3268
 
@@ -3366,28 +3280,34 @@ declare module Immutable {
3366
3280
  * Implementations should extend one of the subclasses, `Collection.Keyed`,
3367
3281
  * `Collection.Indexed`, or `Collection.Set`.
3368
3282
  */
3369
- export module Collection {
3370
-
3283
+ namespace Collection {
3371
3284
  /**
3372
- * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.8')`
3285
+ * @deprecated use `const { isKeyed } = require('immutable')`
3373
3286
  */
3374
- function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
3287
+ function isKeyed(
3288
+ maybeKeyed: unknown
3289
+ ): maybeKeyed is Collection.Keyed<unknown, unknown>;
3375
3290
 
3376
3291
  /**
3377
- * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.8')`
3292
+ * @deprecated use `const { isIndexed } = require('immutable')`
3378
3293
  */
3379
- function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
3294
+ function isIndexed(
3295
+ maybeIndexed: unknown
3296
+ ): maybeIndexed is Collection.Indexed<unknown>;
3380
3297
 
3381
3298
  /**
3382
- * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.8')`
3299
+ * @deprecated use `const { isAssociative } = require('immutable')`
3383
3300
  */
3384
- function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
3301
+ function isAssociative(
3302
+ maybeAssociative: unknown
3303
+ ): maybeAssociative is
3304
+ | Collection.Keyed<unknown, unknown>
3305
+ | Collection.Indexed<unknown>;
3385
3306
 
3386
3307
  /**
3387
- * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.8')`
3308
+ * @deprecated use `const { isOrdered } = require('immutable')`
3388
3309
  */
3389
- function isOrdered(maybeOrdered: any): boolean;
3390
-
3310
+ function isOrdered(maybeOrdered: unknown): boolean;
3391
3311
 
3392
3312
  /**
3393
3313
  * Keyed Collections have discrete keys tied to each value.
@@ -3396,24 +3316,27 @@ declare module Immutable {
3396
3316
  * tuple, in other words, `Collection#entries` is the default iterator for
3397
3317
  * Keyed Collections.
3398
3318
  */
3399
- export module Keyed {}
3319
+ namespace Keyed {}
3400
3320
 
3401
3321
  /**
3402
3322
  * Creates a Collection.Keyed
3403
3323
  *
3404
3324
  * Similar to `Collection()`, however it expects collection-likes of [K, V]
3405
3325
  * tuples if not constructed from a Collection.Keyed or JS Object.
3326
+ *
3327
+ * Note: `Collection.Keyed` is a conversion function and not a class, and
3328
+ * does not use the `new` keyword during construction.
3406
3329
  */
3407
- export function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
3408
- export function Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
3330
+ function Keyed<K, V>(collection?: Iterable<[K, V]>): Collection.Keyed<K, V>;
3331
+ function Keyed<V>(obj: { [key: string]: V }): Collection.Keyed<string, V>;
3409
3332
 
3410
- export interface Keyed<K, V> extends Collection<K, V> {
3333
+ interface Keyed<K, V> extends Collection<K, V> {
3411
3334
  /**
3412
3335
  * Deeply converts this Keyed collection to equivalent native JavaScript Object.
3413
3336
  *
3414
3337
  * Converts keys to Strings.
3415
3338
  */
3416
- toJS(): Object;
3339
+ toJS(): { [key: string]: unknown };
3417
3340
 
3418
3341
  /**
3419
3342
  * Shallowly converts this Keyed collection to equivalent native JavaScript Object.
@@ -3433,7 +3356,6 @@ declare module Immutable {
3433
3356
  */
3434
3357
  toSeq(): Seq.Keyed<K, V>;
3435
3358
 
3436
-
3437
3359
  // Sequence functions
3438
3360
 
3439
3361
  /**
@@ -3442,7 +3364,7 @@ declare module Immutable {
3442
3364
  *
3443
3365
  * <!-- runkit:activate -->
3444
3366
  * ```js
3445
- * const { Map } = require('immutable@4.0.0-rc.8')
3367
+ * const { Map } = require('immutable')
3446
3368
  * Map({ a: 'z', b: 'y' }).flip()
3447
3369
  * // Map { "z": "a", "y": "b" }
3448
3370
  * ```
@@ -3452,15 +3374,19 @@ declare module Immutable {
3452
3374
  /**
3453
3375
  * Returns a new Collection with other collections concatenated to this one.
3454
3376
  */
3455
- concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Collection.Keyed<K | KC, V | VC>;
3456
- concat<C>(...collections: Array<{[key: string]: C}>): Collection.Keyed<K | string, V | C>;
3377
+ concat<KC, VC>(
3378
+ ...collections: Array<Iterable<[KC, VC]>>
3379
+ ): Collection.Keyed<K | KC, V | VC>;
3380
+ concat<C>(
3381
+ ...collections: Array<{ [key: string]: C }>
3382
+ ): Collection.Keyed<K | string, V | C>;
3457
3383
 
3458
3384
  /**
3459
3385
  * Returns a new Collection.Keyed with values passed through a
3460
3386
  * `mapper` function.
3461
3387
  *
3462
3388
  * ```js
3463
- * const { Collection } = require('immutable@4.0.0-rc.8')
3389
+ * const { Collection } = require('immutable')
3464
3390
  * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x)
3465
3391
  * // Seq { "a": 10, "b": 20 }
3466
3392
  * ```
@@ -3470,7 +3396,7 @@ declare module Immutable {
3470
3396
  */
3471
3397
  map<M>(
3472
3398
  mapper: (value: V, key: K, iter: this) => M,
3473
- context?: any
3399
+ context?: unknown
3474
3400
  ): Collection.Keyed<K, M>;
3475
3401
 
3476
3402
  /**
@@ -3479,7 +3405,7 @@ declare module Immutable {
3479
3405
  *
3480
3406
  * <!-- runkit:activate -->
3481
3407
  * ```js
3482
- * const { Map } = require('immutable@4.0.0-rc.8')
3408
+ * const { Map } = require('immutable')
3483
3409
  * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase())
3484
3410
  * // Map { "A": 1, "B": 2 }
3485
3411
  * ```
@@ -3489,7 +3415,7 @@ declare module Immutable {
3489
3415
  */
3490
3416
  mapKeys<M>(
3491
3417
  mapper: (key: K, value: V, iter: this) => M,
3492
- context?: any
3418
+ context?: unknown
3493
3419
  ): Collection.Keyed<M, V>;
3494
3420
 
3495
3421
  /**
@@ -3498,7 +3424,7 @@ declare module Immutable {
3498
3424
  *
3499
3425
  * <!-- runkit:activate -->
3500
3426
  * ```js
3501
- * const { Map } = require('immutable@4.0.0-rc.8')
3427
+ * const { Map } = require('immutable')
3502
3428
  * Map({ a: 1, b: 2 })
3503
3429
  * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ])
3504
3430
  * // Map { "A": 2, "B": 4 }
@@ -3506,10 +3432,16 @@ declare module Immutable {
3506
3432
  *
3507
3433
  * Note: `mapEntries()` always returns a new instance, even if it produced
3508
3434
  * the same entry at every step.
3435
+ *
3436
+ * If the mapper function returns `undefined`, then the entry will be filtered
3509
3437
  */
3510
3438
  mapEntries<KM, VM>(
3511
- mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
3512
- context?: any
3439
+ mapper: (
3440
+ entry: [K, V],
3441
+ index: number,
3442
+ iter: this
3443
+ ) => [KM, VM] | undefined,
3444
+ context?: unknown
3513
3445
  ): Collection.Keyed<KM, VM>;
3514
3446
 
3515
3447
  /**
@@ -3519,7 +3451,7 @@ declare module Immutable {
3519
3451
  */
3520
3452
  flatMap<KM, VM>(
3521
3453
  mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
3522
- context?: any
3454
+ context?: unknown
3523
3455
  ): Collection.Keyed<KM, VM>;
3524
3456
 
3525
3457
  /**
@@ -3531,17 +3463,16 @@ declare module Immutable {
3531
3463
  */
3532
3464
  filter<F extends V>(
3533
3465
  predicate: (value: V, key: K, iter: this) => value is F,
3534
- context?: any
3466
+ context?: unknown
3535
3467
  ): Collection.Keyed<K, F>;
3536
3468
  filter(
3537
- predicate: (value: V, key: K, iter: this) => any,
3538
- context?: any
3469
+ predicate: (value: V, key: K, iter: this) => unknown,
3470
+ context?: unknown
3539
3471
  ): this;
3540
3472
 
3541
3473
  [Symbol.iterator](): IterableIterator<[K, V]>;
3542
3474
  }
3543
3475
 
3544
-
3545
3476
  /**
3546
3477
  * Indexed Collections have incrementing numeric keys. They exhibit
3547
3478
  * slightly different behavior than `Collection.Keyed` for some methods in order
@@ -3557,18 +3488,23 @@ declare module Immutable {
3557
3488
  * preserve indices, using them as keys, convert to a Collection.Keyed by
3558
3489
  * calling `toKeyedSeq`.
3559
3490
  */
3560
- export module Indexed {}
3491
+ namespace Indexed {}
3561
3492
 
3562
3493
  /**
3563
3494
  * Creates a new Collection.Indexed.
3495
+ *
3496
+ * Note: `Collection.Indexed` is a conversion function and not a class, and
3497
+ * does not use the `new` keyword during construction.
3564
3498
  */
3565
- export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
3499
+ function Indexed<T>(
3500
+ collection?: Iterable<T> | ArrayLike<T>
3501
+ ): Collection.Indexed<T>;
3566
3502
 
3567
- export interface Indexed<T> extends Collection<number, T> {
3503
+ interface Indexed<T> extends Collection<number, T> {
3568
3504
  /**
3569
3505
  * Deeply converts this Indexed collection to equivalent native JavaScript Array.
3570
3506
  */
3571
- toJS(): Array<any>;
3507
+ toJS(): Array<unknown>;
3572
3508
 
3573
3509
  /**
3574
3510
  * Shallowly converts this Indexed collection to equivalent native JavaScript Array.
@@ -3592,7 +3528,6 @@ declare module Immutable {
3592
3528
  get<NSV>(index: number, notSetValue: NSV): T | NSV;
3593
3529
  get(index: number): T | undefined;
3594
3530
 
3595
-
3596
3531
  // Conversion to Seq
3597
3532
 
3598
3533
  /**
@@ -3605,8 +3540,7 @@ declare module Immutable {
3605
3540
  * If this is a collection of [key, value] entry tuples, it will return a
3606
3541
  * Seq.Keyed of those entries.
3607
3542
  */
3608
- fromEntrySeq(): Seq.Keyed<any, any>;
3609
-
3543
+ fromEntrySeq(): Seq.Keyed<unknown, unknown>;
3610
3544
 
3611
3545
  // Combination
3612
3546
 
@@ -3624,25 +3558,25 @@ declare module Immutable {
3624
3558
  * second from each, etc.
3625
3559
  *
3626
3560
  * <!-- runkit:activate
3627
- * { "preamble": "require('immutable@4.0.0-rc.8')"}
3561
+ * { "preamble": "require('immutable')"}
3628
3562
  * -->
3629
3563
  * ```js
3630
- * const { List } = require('immutable@4.0.0-rc.8')
3564
+ * const { List } = require('immutable')
3631
3565
  * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ]))
3632
- * // List [ 1, "A", 2, "B", 3, "C"" ]
3566
+ * // List [ 1, "A", 2, "B", 3, "C" ]
3633
3567
  * ```
3634
3568
  *
3635
3569
  * The shortest Collection stops interleave.
3636
3570
  *
3637
3571
  * <!-- runkit:activate
3638
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8')" }
3572
+ * { "preamble": "const { List } = require('immutable')" }
3639
3573
  * -->
3640
3574
  * ```js
3641
3575
  * List([ 1, 2, 3 ]).interleave(
3642
3576
  * List([ 'A', 'B' ]),
3643
3577
  * List([ 'X', 'Y', 'Z' ])
3644
3578
  * )
3645
- * // List [ 1, "A", "X", 2, "B", "Y"" ]
3579
+ * // List [ 1, "A", "X", 2, "B", "Y" ]
3646
3580
  * ```
3647
3581
  *
3648
3582
  * Since `interleave()` re-indexes values, it produces a complete copy,
@@ -3650,7 +3584,7 @@ declare module Immutable {
3650
3584
  *
3651
3585
  * Note: `interleave` *cannot* be used in `withMutations`.
3652
3586
  */
3653
- interleave(...collections: Array<Collection<any, T>>): this;
3587
+ interleave(...collections: Array<Collection<unknown, T>>): this;
3654
3588
 
3655
3589
  /**
3656
3590
  * Splice returns a new indexed Collection by replacing a region of this
@@ -3662,7 +3596,7 @@ declare module Immutable {
3662
3596
  *
3663
3597
  * <!-- runkit:activate -->
3664
3598
  * ```js
3665
- * const { List } = require('immutable@4.0.0-rc.8')
3599
+ * const { List } = require('immutable')
3666
3600
  * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's')
3667
3601
  * // List [ "a", "q", "r", "s", "d" ]
3668
3602
  * ```
@@ -3672,11 +3606,7 @@ declare module Immutable {
3672
3606
  *
3673
3607
  * Note: `splice` *cannot* be used in `withMutations`.
3674
3608
  */
3675
- splice(
3676
- index: number,
3677
- removeNum: number,
3678
- ...values: Array<T>
3679
- ): this;
3609
+ splice(index: number, removeNum: number, ...values: Array<T>): this;
3680
3610
 
3681
3611
  /**
3682
3612
  * Returns a Collection of the same type "zipped" with the provided
@@ -3686,7 +3616,7 @@ declare module Immutable {
3686
3616
  *
3687
3617
  *
3688
3618
  * <!-- runkit:activate
3689
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8')" }
3619
+ * { "preamble": "const { List } = require('immutable')" }
3690
3620
  * -->
3691
3621
  * ```js
3692
3622
  * const a = List([ 1, 2, 3 ]);
@@ -3694,9 +3624,14 @@ declare module Immutable {
3694
3624
  * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
3695
3625
  * ```
3696
3626
  */
3697
- zip<U>(other: Collection<any, U>): Collection.Indexed<[T,U]>;
3698
- zip<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Collection.Indexed<[T,U,V]>;
3699
- zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
3627
+ zip<U>(other: Collection<unknown, U>): Collection.Indexed<[T, U]>;
3628
+ zip<U, V>(
3629
+ other: Collection<unknown, U>,
3630
+ other2: Collection<unknown, V>
3631
+ ): Collection.Indexed<[T, U, V]>;
3632
+ zip(
3633
+ ...collections: Array<Collection<unknown, unknown>>
3634
+ ): Collection.Indexed<unknown>;
3700
3635
 
3701
3636
  /**
3702
3637
  * Returns a Collection "zipped" with the provided collections.
@@ -3710,16 +3645,21 @@ declare module Immutable {
3710
3645
  * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ]
3711
3646
  * ```
3712
3647
  */
3713
- zipAll<U>(other: Collection<any, U>): Collection.Indexed<[T,U]>;
3714
- zipAll<U,V>(other: Collection<any, U>, other2: Collection<any, V>): Collection.Indexed<[T,U,V]>;
3715
- zipAll(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
3648
+ zipAll<U>(other: Collection<unknown, U>): Collection.Indexed<[T, U]>;
3649
+ zipAll<U, V>(
3650
+ other: Collection<unknown, U>,
3651
+ other2: Collection<unknown, V>
3652
+ ): Collection.Indexed<[T, U, V]>;
3653
+ zipAll(
3654
+ ...collections: Array<Collection<unknown, unknown>>
3655
+ ): Collection.Indexed<unknown>;
3716
3656
 
3717
3657
  /**
3718
3658
  * Returns a Collection of the same type "zipped" with the provided
3719
3659
  * collections by using a custom `zipper` function.
3720
3660
  *
3721
3661
  * <!-- runkit:activate
3722
- * { "preamble": "const { List } = require('immutable@4.0.0-rc.8')" }
3662
+ * { "preamble": "const { List } = require('immutable')" }
3723
3663
  * -->
3724
3664
  * ```js
3725
3665
  * const a = List([ 1, 2, 3 ]);
@@ -3730,19 +3670,18 @@ declare module Immutable {
3730
3670
  */
3731
3671
  zipWith<U, Z>(
3732
3672
  zipper: (value: T, otherValue: U) => Z,
3733
- otherCollection: Collection<any, U>
3673
+ otherCollection: Collection<unknown, U>
3734
3674
  ): Collection.Indexed<Z>;
3735
3675
  zipWith<U, V, Z>(
3736
3676
  zipper: (value: T, otherValue: U, thirdValue: V) => Z,
3737
- otherCollection: Collection<any, U>,
3738
- thirdCollection: Collection<any, V>
3677
+ otherCollection: Collection<unknown, U>,
3678
+ thirdCollection: Collection<unknown, V>
3739
3679
  ): Collection.Indexed<Z>;
3740
3680
  zipWith<Z>(
3741
- zipper: (...any: Array<any>) => Z,
3742
- ...collections: Array<Collection<any, any>>
3681
+ zipper: (...values: Array<unknown>) => Z,
3682
+ ...collections: Array<Collection<unknown, unknown>>
3743
3683
  ): Collection.Indexed<Z>;
3744
3684
 
3745
-
3746
3685
  // Search for value
3747
3686
 
3748
3687
  /**
@@ -3763,7 +3702,7 @@ declare module Immutable {
3763
3702
  */
3764
3703
  findIndex(
3765
3704
  predicate: (value: T, index: number, iter: this) => boolean,
3766
- context?: any
3705
+ context?: unknown
3767
3706
  ): number;
3768
3707
 
3769
3708
  /**
@@ -3772,7 +3711,7 @@ declare module Immutable {
3772
3711
  */
3773
3712
  findLastIndex(
3774
3713
  predicate: (value: T, index: number, iter: this) => boolean,
3775
- context?: any
3714
+ context?: unknown
3776
3715
  ): number;
3777
3716
 
3778
3717
  // Sequence algorithms
@@ -3780,14 +3719,16 @@ declare module Immutable {
3780
3719
  /**
3781
3720
  * Returns a new Collection with other collections concatenated to this one.
3782
3721
  */
3783
- concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Indexed<T | C>;
3722
+ concat<C>(
3723
+ ...valuesOrCollections: Array<Iterable<C> | C>
3724
+ ): Collection.Indexed<T | C>;
3784
3725
 
3785
3726
  /**
3786
3727
  * Returns a new Collection.Indexed with values passed through a
3787
3728
  * `mapper` function.
3788
3729
  *
3789
3730
  * ```js
3790
- * const { Collection } = require('immutable@4.0.0-rc.8')
3731
+ * const { Collection } = require('immutable')
3791
3732
  * Collection.Indexed([1,2]).map(x => 10 * x)
3792
3733
  * // Seq [ 1, 2 ]
3793
3734
  * ```
@@ -3797,7 +3738,7 @@ declare module Immutable {
3797
3738
  */
3798
3739
  map<M>(
3799
3740
  mapper: (value: T, key: number, iter: this) => M,
3800
- context?: any
3741
+ context?: unknown
3801
3742
  ): Collection.Indexed<M>;
3802
3743
 
3803
3744
  /**
@@ -3807,7 +3748,7 @@ declare module Immutable {
3807
3748
  */
3808
3749
  flatMap<M>(
3809
3750
  mapper: (value: T, key: number, iter: this) => Iterable<M>,
3810
- context?: any
3751
+ context?: unknown
3811
3752
  ): Collection.Indexed<M>;
3812
3753
 
3813
3754
  /**
@@ -3819,17 +3760,16 @@ declare module Immutable {
3819
3760
  */
3820
3761
  filter<F extends T>(
3821
3762
  predicate: (value: T, index: number, iter: this) => value is F,
3822
- context?: any
3763
+ context?: unknown
3823
3764
  ): Collection.Indexed<F>;
3824
3765
  filter(
3825
- predicate: (value: T, index: number, iter: this) => any,
3826
- context?: any
3766
+ predicate: (value: T, index: number, iter: this) => unknown,
3767
+ context?: unknown
3827
3768
  ): this;
3828
3769
 
3829
3770
  [Symbol.iterator](): IterableIterator<T>;
3830
3771
  }
3831
3772
 
3832
-
3833
3773
  /**
3834
3774
  * Set Collections only represent values. They have no associated keys or
3835
3775
  * indices. Duplicate values are possible in the lazy `Seq.Set`s, however
@@ -3839,7 +3779,7 @@ declare module Immutable {
3839
3779
  * the value as both the first and second arguments to the provided function.
3840
3780
  *
3841
3781
  * ```js
3842
- * const { Collection } = require('immutable@4.0.0-rc.8')
3782
+ * const { Collection } = require('immutable')
3843
3783
  * const seq = Collection.Set([ 'A', 'B', 'C' ])
3844
3784
  * // Seq { "A", "B", "C" }
3845
3785
  * seq.forEach((v, k) =>
@@ -3847,18 +3787,21 @@ declare module Immutable {
3847
3787
  * )
3848
3788
  * ```
3849
3789
  */
3850
- export module Set {}
3790
+ namespace Set {}
3851
3791
 
3852
3792
  /**
3853
3793
  * Similar to `Collection()`, but always returns a Collection.Set.
3794
+ *
3795
+ * Note: `Collection.Set` is a factory function and not a class, and does
3796
+ * not use the `new` keyword during construction.
3854
3797
  */
3855
- export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
3798
+ function Set<T>(collection?: Iterable<T> | ArrayLike<T>): Collection.Set<T>;
3856
3799
 
3857
- export interface Set<T> extends Collection<T, T> {
3800
+ interface Set<T> extends Collection<T, T> {
3858
3801
  /**
3859
3802
  * Deeply converts this Set collection to equivalent native JavaScript Array.
3860
3803
  */
3861
- toJS(): Array<any>;
3804
+ toJS(): Array<unknown>;
3862
3805
 
3863
3806
  /**
3864
3807
  * Shallowly converts this Set collection to equivalent native JavaScript Array.
@@ -3897,7 +3840,7 @@ declare module Immutable {
3897
3840
  */
3898
3841
  map<M>(
3899
3842
  mapper: (value: T, key: T, iter: this) => M,
3900
- context?: any
3843
+ context?: unknown
3901
3844
  ): Collection.Set<M>;
3902
3845
 
3903
3846
  /**
@@ -3907,7 +3850,7 @@ declare module Immutable {
3907
3850
  */
3908
3851
  flatMap<M>(
3909
3852
  mapper: (value: T, key: T, iter: this) => Iterable<M>,
3910
- context?: any
3853
+ context?: unknown
3911
3854
  ): Collection.Set<M>;
3912
3855
 
3913
3856
  /**
@@ -3919,16 +3862,15 @@ declare module Immutable {
3919
3862
  */
3920
3863
  filter<F extends T>(
3921
3864
  predicate: (value: T, key: T, iter: this) => value is F,
3922
- context?: any
3865
+ context?: unknown
3923
3866
  ): Collection.Set<F>;
3924
3867
  filter(
3925
- predicate: (value: T, key: T, iter: this) => any,
3926
- context?: any
3868
+ predicate: (value: T, key: T, iter: this) => unknown,
3869
+ context?: unknown
3927
3870
  ): this;
3928
3871
 
3929
3872
  [Symbol.iterator](): IterableIterator<T>;
3930
3873
  }
3931
-
3932
3874
  }
3933
3875
 
3934
3876
  /**
@@ -3938,20 +3880,31 @@ declare module Immutable {
3938
3880
  *
3939
3881
  * * If an `Collection`, that same `Collection`.
3940
3882
  * * If an Array-like, an `Collection.Indexed`.
3941
- * * If an Object with an Iterator, an `Collection.Indexed`.
3942
- * * If an Iterator, an `Collection.Indexed`.
3883
+ * * If an Object with an Iterator defined, an `Collection.Indexed`.
3943
3884
  * * If an Object, an `Collection.Keyed`.
3944
3885
  *
3945
3886
  * This methods forces the conversion of Objects and Strings to Collections.
3946
3887
  * If you want to ensure that a Collection of one item is returned, use
3947
3888
  * `Seq.of`.
3889
+ *
3890
+ * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`,
3891
+ * which is usually not what you want. You should turn your Iterator Object into
3892
+ * an iterable object by defining a Symbol.iterator (or @@iterator) method which
3893
+ * returns `this`.
3894
+ *
3895
+ * Note: `Collection` is a conversion function and not a class, and does not
3896
+ * use the `new` keyword during construction.
3948
3897
  */
3949
- export function Collection<I extends Collection<any, any>>(collection: I): I;
3950
- export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
3951
- export function Collection<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
3952
-
3953
- export interface Collection<K, V> extends ValueObject {
3954
-
3898
+ function Collection<I extends Collection<unknown, unknown>>(collection: I): I;
3899
+ function Collection<T>(
3900
+ collection: Iterable<T> | ArrayLike<T>
3901
+ ): Collection.Indexed<T>;
3902
+ function Collection<V>(obj: {
3903
+ [key: string]: V;
3904
+ }): Collection.Keyed<string, V>;
3905
+ function Collection<K = unknown, V = unknown>(): Collection<K, V>;
3906
+
3907
+ interface Collection<K, V> extends ValueObject {
3955
3908
  // Value equality
3956
3909
 
3957
3910
  /**
@@ -3961,7 +3914,7 @@ declare module Immutable {
3961
3914
  * Note: This is equivalent to `Immutable.is(this, other)`, but provided to
3962
3915
  * allow for chained expressions.
3963
3916
  */
3964
- equals(other: any): boolean;
3917
+ equals(other: unknown): boolean;
3965
3918
 
3966
3919
  /**
3967
3920
  * Computes and returns the hashed identity for this Collection.
@@ -3971,7 +3924,7 @@ declare module Immutable {
3971
3924
  * lookup via a different instance.
3972
3925
  *
3973
3926
  * <!-- runkit:activate
3974
- * { "preamble": "const { Set, List } = require('immutable@4.0.0-rc.8')" }
3927
+ * { "preamble": "const { Set, List } = require('immutable')" }
3975
3928
  * -->
3976
3929
  * ```js
3977
3930
  * const a = List([ 1, 2, 3 ]);
@@ -3985,11 +3938,10 @@ declare module Immutable {
3985
3938
  * to be equal][Hash Collision]. If two values have different `hashCode`s,
3986
3939
  * they must not be equal.
3987
3940
  *
3988
- * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science)
3941
+ * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science)
3989
3942
  */
3990
3943
  hashCode(): number;
3991
3944
 
3992
-
3993
3945
  // Reading values
3994
3946
 
3995
3947
  /**
@@ -4018,15 +3970,20 @@ declare module Immutable {
4018
3970
  contains(value: V): boolean;
4019
3971
 
4020
3972
  /**
4021
- * The first value in the Collection.
3973
+ * In case the `Collection` is not empty returns the first element of the
3974
+ * `Collection`.
3975
+ * In case the `Collection` is empty returns the optional default
3976
+ * value if provided, if no default value is provided returns undefined.
4022
3977
  */
4023
- first(): V | undefined;
3978
+ first<NSV = undefined>(notSetValue?: NSV): V | NSV;
4024
3979
 
4025
3980
  /**
4026
- * The last value in the Collection.
3981
+ * In case the `Collection` is not empty returns the last element of the
3982
+ * `Collection`.
3983
+ * In case the `Collection` is empty returns the optional default
3984
+ * value if provided, if no default value is provided returns undefined.
4027
3985
  */
4028
- last(): V | undefined;
4029
-
3986
+ last<NSV = undefined>(notSetValue?: NSV): V | NSV;
4030
3987
 
4031
3988
  // Reading deep values
4032
3989
 
@@ -4036,9 +3993,9 @@ declare module Immutable {
4036
3993
  *
4037
3994
  * <!-- runkit:activate -->
4038
3995
  * ```js
4039
- * const { Map, List } = require('immutable@4.0.0-rc.8')
3996
+ * const { Map, List } = require('immutable')
4040
3997
  * const deepData = Map({ x: List([ Map({ y: 123 }) ]) });
4041
- * getIn(deepData, ['x', 0, 'y']) // 123
3998
+ * deepData.getIn(['x', 0, 'y']) // 123
4042
3999
  * ```
4043
4000
  *
4044
4001
  * Plain JavaScript Object or Arrays may be nested within an Immutable.js
@@ -4046,18 +4003,18 @@ declare module Immutable {
4046
4003
  *
4047
4004
  * <!-- runkit:activate -->
4048
4005
  * ```js
4049
- * const { Map, List } = require('immutable@4.0.0-rc.8')
4006
+ * const { Map, List } = require('immutable')
4050
4007
  * const deepData = Map({ x: [ { y: 123 } ] });
4051
- * getIn(deepData, ['x', 0, 'y']) // 123
4008
+ * deepData.getIn(['x', 0, 'y']) // 123
4052
4009
  * ```
4053
4010
  */
4054
- getIn(searchKeyPath: Iterable<any>, notSetValue?: any): any;
4011
+ getIn(searchKeyPath: Iterable<unknown>, notSetValue?: unknown): unknown;
4055
4012
 
4056
4013
  /**
4057
4014
  * True if the result of following a path of keys or indices through nested
4058
4015
  * Collections results in a set value.
4059
4016
  */
4060
- hasIn(searchKeyPath: Iterable<any>): boolean;
4017
+ hasIn(searchKeyPath: Iterable<unknown>): boolean;
4061
4018
 
4062
4019
  // Persistent changes
4063
4020
 
@@ -4069,7 +4026,7 @@ declare module Immutable {
4069
4026
  *
4070
4027
  * <!-- runkit:activate -->
4071
4028
  * ```js
4072
- * const { Seq } = require('immutable@4.0.0-rc.8')
4029
+ * const { Seq } = require('immutable')
4073
4030
  *
4074
4031
  * function sum(collection) {
4075
4032
  * return collection.reduce((sum, x) => sum + x, 0)
@@ -4084,7 +4041,6 @@ declare module Immutable {
4084
4041
  */
4085
4042
  update<R>(updater: (value: this) => R): R;
4086
4043
 
4087
-
4088
4044
  // Conversion to JavaScript types
4089
4045
 
4090
4046
  /**
@@ -4093,7 +4049,7 @@ declare module Immutable {
4093
4049
  * `Collection.Indexed`, and `Collection.Set` become `Array`, while
4094
4050
  * `Collection.Keyed` become `Object`, converting keys to Strings.
4095
4051
  */
4096
- toJS(): Array<any> | { [key: string]: any };
4052
+ toJS(): Array<unknown> | { [key: string]: unknown };
4097
4053
 
4098
4054
  /**
4099
4055
  * Shallowly converts this Collection to equivalent native JavaScript Array or Object.
@@ -4118,7 +4074,6 @@ declare module Immutable {
4118
4074
  */
4119
4075
  toObject(): { [key: string]: V };
4120
4076
 
4121
-
4122
4077
  // Conversion to Collections
4123
4078
 
4124
4079
  /**
@@ -4165,7 +4120,7 @@ declare module Immutable {
4165
4120
  *
4166
4121
  * <!-- runkit:activate -->
4167
4122
  * ```js
4168
- * const { Map, List } = require('immutable@4.0.0-rc.8')
4123
+ * const { Map, List } = require('immutable')
4169
4124
  * var myMap = Map({ a: 'Apple', b: 'Banana' })
4170
4125
  * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ]
4171
4126
  * myMap.toList() // List [ "Apple", "Banana" ]
@@ -4182,7 +4137,6 @@ declare module Immutable {
4182
4137
  */
4183
4138
  toStack(): Stack<V>;
4184
4139
 
4185
-
4186
4140
  // Conversion to Seq
4187
4141
 
4188
4142
  /**
@@ -4202,7 +4156,7 @@ declare module Immutable {
4202
4156
  *
4203
4157
  * <!-- runkit:activate -->
4204
4158
  * ```js
4205
- * const { Seq } = require('immutable@4.0.0-rc.8')
4159
+ * const { Seq } = require('immutable')
4206
4160
  * const indexedSeq = Seq([ 'A', 'B', 'C' ])
4207
4161
  * // Seq [ "A", "B", "C" ]
4208
4162
  * indexedSeq.filter(v => v === 'B')
@@ -4225,7 +4179,6 @@ declare module Immutable {
4225
4179
  */
4226
4180
  toSetSeq(): Seq.Set<V>;
4227
4181
 
4228
-
4229
4182
  // Iterators
4230
4183
 
4231
4184
  /**
@@ -4255,6 +4208,7 @@ declare module Immutable {
4255
4208
  */
4256
4209
  entries(): IterableIterator<[K, V]>;
4257
4210
 
4211
+ [Symbol.iterator](): IterableIterator<unknown>;
4258
4212
 
4259
4213
  // Collections (Seq)
4260
4214
 
@@ -4274,7 +4228,6 @@ declare module Immutable {
4274
4228
  */
4275
4229
  entrySeq(): Seq.Indexed<[K, V]>;
4276
4230
 
4277
-
4278
4231
  // Sequence algorithms
4279
4232
 
4280
4233
  /**
@@ -4283,7 +4236,7 @@ declare module Immutable {
4283
4236
  *
4284
4237
  * <!-- runkit:activate -->
4285
4238
  * ```js
4286
- * const { Collection } = require('immutable@4.0.0-rc.8')
4239
+ * const { Collection } = require('immutable')
4287
4240
  * Collection({ a: 1, b: 2 }).map(x => 10 * x)
4288
4241
  * // Seq { "a": 10, "b": 20 }
4289
4242
  * ```
@@ -4293,7 +4246,7 @@ declare module Immutable {
4293
4246
  */
4294
4247
  map<M>(
4295
4248
  mapper: (value: V, key: K, iter: this) => M,
4296
- context?: any
4249
+ context?: unknown
4297
4250
  ): Collection<K, M>;
4298
4251
 
4299
4252
  /**
@@ -4302,7 +4255,7 @@ declare module Immutable {
4302
4255
  *
4303
4256
  * @ignore
4304
4257
  */
4305
- map<M>(...args: never[]): any;
4258
+ map(...args: Array<never>): unknown;
4306
4259
 
4307
4260
  /**
4308
4261
  * Returns a new Collection of the same type with only the entries for which
@@ -4310,7 +4263,7 @@ declare module Immutable {
4310
4263
  *
4311
4264
  * <!-- runkit:activate -->
4312
4265
  * ```js
4313
- * const { Map } = require('immutable@4.0.0-rc.8')
4266
+ * const { Map } = require('immutable')
4314
4267
  * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0)
4315
4268
  * // Map { "b": 2, "d": 4 }
4316
4269
  * ```
@@ -4320,11 +4273,11 @@ declare module Immutable {
4320
4273
  */
4321
4274
  filter<F extends V>(
4322
4275
  predicate: (value: V, key: K, iter: this) => value is F,
4323
- context?: any
4276
+ context?: unknown
4324
4277
  ): Collection<K, F>;
4325
4278
  filter(
4326
- predicate: (value: V, key: K, iter: this) => any,
4327
- context?: any
4279
+ predicate: (value: V, key: K, iter: this) => unknown,
4280
+ context?: unknown
4328
4281
  ): this;
4329
4282
 
4330
4283
  /**
@@ -4333,7 +4286,7 @@ declare module Immutable {
4333
4286
  *
4334
4287
  * <!-- runkit:activate -->
4335
4288
  * ```js
4336
- * const { Map } = require('immutable@4.0.0-rc.8')
4289
+ * const { Map } = require('immutable')
4337
4290
  * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0)
4338
4291
  * // Map { "a": 1, "c": 3 }
4339
4292
  * ```
@@ -4343,7 +4296,7 @@ declare module Immutable {
4343
4296
  */
4344
4297
  filterNot(
4345
4298
  predicate: (value: V, key: K, iter: this) => boolean,
4346
- context?: any
4299
+ context?: unknown
4347
4300
  ): this;
4348
4301
 
4349
4302
  /**
@@ -4370,7 +4323,7 @@ declare module Immutable {
4370
4323
  *
4371
4324
  * <!-- runkit:activate -->
4372
4325
  * ```js
4373
- * const { Map } = require('immutable@4.0.0-rc.8')
4326
+ * const { Map } = require('immutable')
4374
4327
  * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => {
4375
4328
  * if (a < b) { return -1; }
4376
4329
  * if (a > b) { return 1; }
@@ -4390,7 +4343,17 @@ declare module Immutable {
4390
4343
  * Like `sort`, but also accepts a `comparatorValueMapper` which allows for
4391
4344
  * sorting by more sophisticated means:
4392
4345
  *
4393
- * hitters.sortBy(hitter => hitter.avgHits)
4346
+ * <!-- runkit:activate -->
4347
+ * ```js
4348
+ * const { Map } = require('immutable')
4349
+ * const beattles = Map({
4350
+ * John: { name: "Lennon" },
4351
+ * Paul: { name: "McCartney" },
4352
+ * George: { name: "Harrison" },
4353
+ * Ringo: { name: "Starr" },
4354
+ * });
4355
+ * beattles.sortBy(member => member.name);
4356
+ * ```
4394
4357
  *
4395
4358
  * Note: `sortBy()` Always returns a new instance, even if the original was
4396
4359
  * already sorted.
@@ -4410,7 +4373,7 @@ declare module Immutable {
4410
4373
  *
4411
4374
  * <!-- runkit:activate -->
4412
4375
  * ```js
4413
- * const { List, Map } = require('immutable@4.0.0-rc.8')
4376
+ * const { List, Map } = require('immutable')
4414
4377
  * const listOfMaps = List([
4415
4378
  * Map({ v: 0 }),
4416
4379
  * Map({ v: 1 }),
@@ -4428,9 +4391,8 @@ declare module Immutable {
4428
4391
  */
4429
4392
  groupBy<G>(
4430
4393
  grouper: (value: V, key: K, iter: this) => G,
4431
- context?: any
4432
- ): /*Map*/Seq.Keyed<G, /*this*/Collection<K, V>>;
4433
-
4394
+ context?: unknown
4395
+ ): /*Map*/ Seq.Keyed<G, /*this*/ Collection<K, V>>;
4434
4396
 
4435
4397
  // Side effects
4436
4398
 
@@ -4442,11 +4404,10 @@ declare module Immutable {
4442
4404
  * (including the last iteration which returned false).
4443
4405
  */
4444
4406
  forEach(
4445
- sideEffect: (value: V, key: K, iter: this) => any,
4446
- context?: any
4407
+ sideEffect: (value: V, key: K, iter: this) => unknown,
4408
+ context?: unknown
4447
4409
  ): number;
4448
4410
 
4449
-
4450
4411
  // Creating subsets
4451
4412
 
4452
4413
  /**
@@ -4497,15 +4458,15 @@ declare module Immutable {
4497
4458
  *
4498
4459
  * <!-- runkit:activate -->
4499
4460
  * ```js
4500
- * const { List } = require('immutable@4.0.0-rc.8')
4461
+ * const { List } = require('immutable')
4501
4462
  * List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
4502
4463
  * .skipWhile(x => x.match(/g/))
4503
- * // List [ "cat", "hat", "god"" ]
4464
+ * // List [ "cat", "hat", "god" ]
4504
4465
  * ```
4505
4466
  */
4506
4467
  skipWhile(
4507
4468
  predicate: (value: V, key: K, iter: this) => boolean,
4508
- context?: any
4469
+ context?: unknown
4509
4470
  ): this;
4510
4471
 
4511
4472
  /**
@@ -4514,15 +4475,15 @@ declare module Immutable {
4514
4475
  *
4515
4476
  * <!-- runkit:activate -->
4516
4477
  * ```js
4517
- * const { List } = require('immutable@4.0.0-rc.8')
4478
+ * const { List } = require('immutable')
4518
4479
  * List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
4519
4480
  * .skipUntil(x => x.match(/hat/))
4520
- * // List [ "hat", "god"" ]
4481
+ * // List [ "hat", "god" ]
4521
4482
  * ```
4522
4483
  */
4523
4484
  skipUntil(
4524
4485
  predicate: (value: V, key: K, iter: this) => boolean,
4525
- context?: any
4486
+ context?: unknown
4526
4487
  ): this;
4527
4488
 
4528
4489
  /**
@@ -4543,7 +4504,7 @@ declare module Immutable {
4543
4504
  *
4544
4505
  * <!-- runkit:activate -->
4545
4506
  * ```js
4546
- * const { List } = require('immutable@4.0.0-rc.8')
4507
+ * const { List } = require('immutable')
4547
4508
  * List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
4548
4509
  * .takeWhile(x => x.match(/o/))
4549
4510
  * // List [ "dog", "frog" ]
@@ -4551,7 +4512,7 @@ declare module Immutable {
4551
4512
  */
4552
4513
  takeWhile(
4553
4514
  predicate: (value: V, key: K, iter: this) => boolean,
4554
- context?: any
4515
+ context?: unknown
4555
4516
  ): this;
4556
4517
 
4557
4518
  /**
@@ -4560,7 +4521,7 @@ declare module Immutable {
4560
4521
  *
4561
4522
  * <!-- runkit:activate -->
4562
4523
  * ```js
4563
- * const { List } = require('immutable@4.0.0-rc.8')
4524
+ * const { List } = require('immutable')
4564
4525
  * List([ 'dog', 'frog', 'cat', 'hat', 'god' ])
4565
4526
  * .takeUntil(x => x.match(/at/))
4566
4527
  * // List [ "dog", "frog" ]
@@ -4568,10 +4529,9 @@ declare module Immutable {
4568
4529
  */
4569
4530
  takeUntil(
4570
4531
  predicate: (value: V, key: K, iter: this) => boolean,
4571
- context?: any
4532
+ context?: unknown
4572
4533
  ): this;
4573
4534
 
4574
-
4575
4535
  // Combination
4576
4536
 
4577
4537
  /**
@@ -4581,7 +4541,9 @@ declare module Immutable {
4581
4541
  * For Seqs, all entries will be present in the resulting Seq, even if they
4582
4542
  * have the same key.
4583
4543
  */
4584
- concat(...valuesOrCollections: Array<any>): Collection<any, any>;
4544
+ concat(
4545
+ ...valuesOrCollections: Array<unknown>
4546
+ ): Collection<unknown, unknown>;
4585
4547
 
4586
4548
  /**
4587
4549
  * Flattens nested Collections.
@@ -4593,11 +4555,12 @@ declare module Immutable {
4593
4555
  *
4594
4556
  * Flattens only others Collection, not Arrays or Objects.
4595
4557
  *
4596
- * Note: `flatten(true)` operates on Collection<any, Collection<K, V>> and
4558
+ * Note: `flatten(true)` operates on Collection<unknown, Collection<K, V>> and
4597
4559
  * returns Collection<K, V>
4598
4560
  */
4599
- flatten(depth?: number): Collection<any, any>;
4600
- flatten(shallow?: boolean): Collection<any, any>;
4561
+ flatten(depth?: number): Collection<unknown, unknown>;
4562
+ // tslint:disable-next-line unified-signatures
4563
+ flatten(shallow?: boolean): Collection<unknown, unknown>;
4601
4564
 
4602
4565
  /**
4603
4566
  * Flat-maps the Collection, returning a Collection of the same type.
@@ -4606,7 +4569,7 @@ declare module Immutable {
4606
4569
  */
4607
4570
  flatMap<M>(
4608
4571
  mapper: (value: V, key: K, iter: this) => Iterable<M>,
4609
- context?: any
4572
+ context?: unknown
4610
4573
  ): Collection<K, M>;
4611
4574
 
4612
4575
  /**
@@ -4617,7 +4580,7 @@ declare module Immutable {
4617
4580
  */
4618
4581
  flatMap<KM, VM>(
4619
4582
  mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
4620
- context?: any
4583
+ context?: unknown
4621
4584
  ): Collection<KM, VM>;
4622
4585
 
4623
4586
  // Reducing a value
@@ -4634,7 +4597,7 @@ declare module Immutable {
4634
4597
  reduce<R>(
4635
4598
  reducer: (reduction: R, value: V, key: K, iter: this) => R,
4636
4599
  initialReduction: R,
4637
- context?: any
4600
+ context?: unknown
4638
4601
  ): R;
4639
4602
  reduce<R>(
4640
4603
  reducer: (reduction: V | R, value: V, key: K, iter: this) => R
@@ -4649,7 +4612,7 @@ declare module Immutable {
4649
4612
  reduceRight<R>(
4650
4613
  reducer: (reduction: R, value: V, key: K, iter: this) => R,
4651
4614
  initialReduction: R,
4652
- context?: any
4615
+ context?: unknown
4653
4616
  ): R;
4654
4617
  reduceRight<R>(
4655
4618
  reducer: (reduction: V | R, value: V, key: K, iter: this) => R
@@ -4660,7 +4623,7 @@ declare module Immutable {
4660
4623
  */
4661
4624
  every(
4662
4625
  predicate: (value: V, key: K, iter: this) => boolean,
4663
- context?: any
4626
+ context?: unknown
4664
4627
  ): boolean;
4665
4628
 
4666
4629
  /**
@@ -4668,7 +4631,7 @@ declare module Immutable {
4668
4631
  */
4669
4632
  some(
4670
4633
  predicate: (value: V, key: K, iter: this) => boolean,
4671
- context?: any
4634
+ context?: unknown
4672
4635
  ): boolean;
4673
4636
 
4674
4637
  /**
@@ -4698,7 +4661,7 @@ declare module Immutable {
4698
4661
  count(): number;
4699
4662
  count(
4700
4663
  predicate: (value: V, key: K, iter: this) => boolean,
4701
- context?: any
4664
+ context?: unknown
4702
4665
  ): number;
4703
4666
 
4704
4667
  /**
@@ -4709,10 +4672,9 @@ declare module Immutable {
4709
4672
  */
4710
4673
  countBy<G>(
4711
4674
  grouper: (value: V, key: K, iter: this) => G,
4712
- context?: any
4675
+ context?: unknown
4713
4676
  ): Map<G, number>;
4714
4677
 
4715
-
4716
4678
  // Search for value
4717
4679
 
4718
4680
  /**
@@ -4720,7 +4682,7 @@ declare module Immutable {
4720
4682
  */
4721
4683
  find(
4722
4684
  predicate: (value: V, key: K, iter: this) => boolean,
4723
- context?: any,
4685
+ context?: unknown,
4724
4686
  notSetValue?: V
4725
4687
  ): V | undefined;
4726
4688
 
@@ -4731,7 +4693,7 @@ declare module Immutable {
4731
4693
  */
4732
4694
  findLast(
4733
4695
  predicate: (value: V, key: K, iter: this) => boolean,
4734
- context?: any,
4696
+ context?: unknown,
4735
4697
  notSetValue?: V
4736
4698
  ): V | undefined;
4737
4699
 
@@ -4740,7 +4702,7 @@ declare module Immutable {
4740
4702
  */
4741
4703
  findEntry(
4742
4704
  predicate: (value: V, key: K, iter: this) => boolean,
4743
- context?: any,
4705
+ context?: unknown,
4744
4706
  notSetValue?: V
4745
4707
  ): [K, V] | undefined;
4746
4708
 
@@ -4752,7 +4714,7 @@ declare module Immutable {
4752
4714
  */
4753
4715
  findLastEntry(
4754
4716
  predicate: (value: V, key: K, iter: this) => boolean,
4755
- context?: any,
4717
+ context?: unknown,
4756
4718
  notSetValue?: V
4757
4719
  ): [K, V] | undefined;
4758
4720
 
@@ -4761,7 +4723,7 @@ declare module Immutable {
4761
4723
  */
4762
4724
  findKey(
4763
4725
  predicate: (value: V, key: K, iter: this) => boolean,
4764
- context?: any
4726
+ context?: unknown
4765
4727
  ): K | undefined;
4766
4728
 
4767
4729
  /**
@@ -4771,7 +4733,7 @@ declare module Immutable {
4771
4733
  */
4772
4734
  findLastKey(
4773
4735
  predicate: (value: V, key: K, iter: this) => boolean,
4774
- context?: any
4736
+ context?: unknown
4775
4737
  ): K | undefined;
4776
4738
 
4777
4739
  /**
@@ -4805,8 +4767,16 @@ declare module Immutable {
4805
4767
  * Like `max`, but also accepts a `comparatorValueMapper` which allows for
4806
4768
  * comparing by more sophisticated means:
4807
4769
  *
4808
- * hitters.maxBy(hitter => hitter.avgHits);
4809
- *
4770
+ * <!-- runkit:activate -->
4771
+ * ```js
4772
+ * const { List, } = require('immutable');
4773
+ * const l = List([
4774
+ * { name: 'Bob', avgHit: 1 },
4775
+ * { name: 'Max', avgHit: 3 },
4776
+ * { name: 'Lili', avgHit: 2 } ,
4777
+ * ]);
4778
+ * l.maxBy(i => i.avgHit); // will output { name: 'Max', avgHit: 3 }
4779
+ * ```
4810
4780
  */
4811
4781
  maxBy<C>(
4812
4782
  comparatorValueMapper: (value: V, key: K, iter: this) => C,
@@ -4834,15 +4804,22 @@ declare module Immutable {
4834
4804
  * Like `min`, but also accepts a `comparatorValueMapper` which allows for
4835
4805
  * comparing by more sophisticated means:
4836
4806
  *
4837
- * hitters.minBy(hitter => hitter.avgHits);
4838
- *
4807
+ * <!-- runkit:activate -->
4808
+ * ```js
4809
+ * const { List, } = require('immutable');
4810
+ * const l = List([
4811
+ * { name: 'Bob', avgHit: 1 },
4812
+ * { name: 'Max', avgHit: 3 },
4813
+ * { name: 'Lili', avgHit: 2 } ,
4814
+ * ]);
4815
+ * l.minBy(i => i.avgHit); // will output { name: 'Bob', avgHit: 1 }
4816
+ * ```
4839
4817
  */
4840
4818
  minBy<C>(
4841
4819
  comparatorValueMapper: (value: V, key: K, iter: this) => C,
4842
4820
  comparator?: (valueA: C, valueB: C) => number
4843
4821
  ): V | undefined;
4844
4822
 
4845
-
4846
4823
  // Comparison
4847
4824
 
4848
4825
  /**
@@ -4856,6 +4833,354 @@ declare module Immutable {
4856
4833
  isSuperset(iter: Iterable<V>): boolean;
4857
4834
  }
4858
4835
 
4836
+ /**
4837
+ * The interface to fulfill to qualify as a Value Object.
4838
+ */
4839
+ interface ValueObject {
4840
+ /**
4841
+ * True if this and the other Collection have value equality, as defined
4842
+ * by `Immutable.is()`.
4843
+ *
4844
+ * Note: This is equivalent to `Immutable.is(this, other)`, but provided to
4845
+ * allow for chained expressions.
4846
+ */
4847
+ equals(other: unknown): boolean;
4848
+
4849
+ /**
4850
+ * Computes and returns the hashed identity for this Collection.
4851
+ *
4852
+ * The `hashCode` of a Collection is used to determine potential equality,
4853
+ * and is used when adding this to a `Set` or as a key in a `Map`, enabling
4854
+ * lookup via a different instance.
4855
+ *
4856
+ * <!-- runkit:activate -->
4857
+ * ```js
4858
+ * const { List, Set } = require('immutable');
4859
+ * const a = List([ 1, 2, 3 ]);
4860
+ * const b = List([ 1, 2, 3 ]);
4861
+ * assert.notStrictEqual(a, b); // different instances
4862
+ * const set = Set([ a ]);
4863
+ * assert.equal(set.has(b), true);
4864
+ * ```
4865
+ *
4866
+ * Note: hashCode() MUST return a Uint32 number. The easiest way to
4867
+ * guarantee this is to return `myHash | 0` from a custom implementation.
4868
+ *
4869
+ * If two values have the same `hashCode`, they are [not guaranteed
4870
+ * to be equal][Hash Collision]. If two values have different `hashCode`s,
4871
+ * they must not be equal.
4872
+ *
4873
+ * Note: `hashCode()` is not guaranteed to always be called before
4874
+ * `equals()`. Most but not all Immutable.js collections use hash codes to
4875
+ * organize their internal data structures, while all Immutable.js
4876
+ * collections use equality during lookups.
4877
+ *
4878
+ * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science)
4879
+ */
4880
+ hashCode(): number;
4881
+ }
4882
+
4883
+ /**
4884
+ * Deeply converts plain JS objects and arrays to Immutable Maps and Lists.
4885
+ *
4886
+ * `fromJS` will convert Arrays and [array-like objects][2] to a List, and
4887
+ * plain objects (without a custom prototype) to a Map. [Iterable objects][3]
4888
+ * may be converted to List, Map, or Set.
4889
+ *
4890
+ * If a `reviver` is optionally provided, it will be called with every
4891
+ * collection as a Seq (beginning with the most nested collections
4892
+ * and proceeding to the top-level collection itself), along with the key
4893
+ * referring to each collection and the parent JS object provided as `this`.
4894
+ * For the top level, object, the key will be `""`. This `reviver` is expected
4895
+ * to return a new Immutable Collection, allowing for custom conversions from
4896
+ * deep JS objects. Finally, a `path` is provided which is the sequence of
4897
+ * keys to this value from the starting value.
4898
+ *
4899
+ * `reviver` acts similarly to the [same parameter in `JSON.parse`][1].
4900
+ *
4901
+ * If `reviver` is not provided, the default behavior will convert Objects
4902
+ * into Maps and Arrays into Lists like so:
4903
+ *
4904
+ * <!-- runkit:activate -->
4905
+ * ```js
4906
+ * const { fromJS, isKeyed } = require('immutable')
4907
+ * function (key, value) {
4908
+ * return isKeyed(value) ? value.toMap() : value.toList()
4909
+ * }
4910
+ * ```
4911
+ *
4912
+ * Accordingly, this example converts native JS data to OrderedMap and List:
4913
+ *
4914
+ * <!-- runkit:activate -->
4915
+ * ```js
4916
+ * const { fromJS, isKeyed } = require('immutable')
4917
+ * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) {
4918
+ * console.log(key, value, path)
4919
+ * return isKeyed(value) ? value.toOrderedMap() : value.toList()
4920
+ * })
4921
+ *
4922
+ * > "b", [ 10, 20, 30 ], [ "a", "b" ]
4923
+ * > "a", {b: [10, 20, 30]}, [ "a" ]
4924
+ * > "", {a: {b: [10, 20, 30]}, c: 40}, []
4925
+ * ```
4926
+ *
4927
+ * Keep in mind, when using JS objects to construct Immutable Maps, that
4928
+ * JavaScript Object properties are always strings, even if written in a
4929
+ * quote-less shorthand, while Immutable Maps accept keys of any type.
4930
+ *
4931
+ * <!-- runkit:activate -->
4932
+ * ```js
4933
+ * const { Map } = require('immutable')
4934
+ * let obj = { 1: "one" };
4935
+ * Object.keys(obj); // [ "1" ]
4936
+ * assert.equal(obj["1"], obj[1]); // "one" === "one"
4937
+ *
4938
+ * let map = Map(obj);
4939
+ * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined
4940
+ * ```
4941
+ *
4942
+ * Property access for JavaScript Objects first converts the key to a string,
4943
+ * but since Immutable Map keys can be of any type the argument to `get()` is
4944
+ * not altered.
4945
+ *
4946
+ * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter
4947
+ * "Using the reviver parameter"
4948
+ * [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#working_with_array-like_objects
4949
+ * "Working with array-like objects"
4950
+ * [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol
4951
+ * "The iterable protocol"
4952
+ */
4953
+ function fromJS(
4954
+ jsValue: unknown,
4955
+ reviver?: (
4956
+ key: string | number,
4957
+ sequence: Collection.Keyed<string, unknown> | Collection.Indexed<unknown>,
4958
+ path?: Array<string | number>
4959
+ ) => unknown
4960
+ ): Collection<unknown, unknown>;
4961
+
4962
+ /**
4963
+ * Value equality check with semantics similar to `Object.is`, but treats
4964
+ * Immutable `Collection`s as values, equal if the second `Collection` includes
4965
+ * equivalent values.
4966
+ *
4967
+ * It's used throughout Immutable when checking for equality, including `Map`
4968
+ * key equality and `Set` membership.
4969
+ *
4970
+ * <!-- runkit:activate -->
4971
+ * ```js
4972
+ * const { Map, is } = require('immutable')
4973
+ * const map1 = Map({ a: 1, b: 1, c: 1 })
4974
+ * const map2 = Map({ a: 1, b: 1, c: 1 })
4975
+ * assert.equal(map1 !== map2, true)
4976
+ * assert.equal(Object.is(map1, map2), false)
4977
+ * assert.equal(is(map1, map2), true)
4978
+ * ```
4979
+ *
4980
+ * `is()` compares primitive types like strings and numbers, Immutable.js
4981
+ * collections like `Map` and `List`, but also any custom object which
4982
+ * implements `ValueObject` by providing `equals()` and `hashCode()` methods.
4983
+ *
4984
+ * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same
4985
+ * value, matching the behavior of ES6 Map key equality.
4986
+ */
4987
+ function is(first: unknown, second: unknown): boolean;
4988
+
4989
+ /**
4990
+ * The `hash()` function is an important part of how Immutable determines if
4991
+ * two values are equivalent and is used to determine how to store those
4992
+ * values. Provided with any value, `hash()` will return a 31-bit integer.
4993
+ *
4994
+ * When designing Objects which may be equal, it's important that when a
4995
+ * `.equals()` method returns true, that both values `.hashCode()` method
4996
+ * return the same value. `hash()` may be used to produce those values.
4997
+ *
4998
+ * For non-Immutable Objects that do not provide a `.hashCode()` functions
4999
+ * (including plain Objects, plain Arrays, Date objects, etc), a unique hash
5000
+ * value will be created for each *instance*. That is, the create hash
5001
+ * represents referential equality, and not value equality for Objects. This
5002
+ * ensures that if that Object is mutated over time that its hash code will
5003
+ * remain consistent, allowing Objects to be used as keys and values in
5004
+ * Immutable.js collections.
5005
+ *
5006
+ * Note that `hash()` attempts to balance between speed and avoiding
5007
+ * collisions, however it makes no attempt to produce secure hashes.
5008
+ *
5009
+ * *New in Version 4.0*
5010
+ */
5011
+ function hash(value: unknown): number;
5012
+
5013
+ /**
5014
+ * True if `maybeImmutable` is an Immutable Collection or Record.
5015
+ *
5016
+ * Note: Still returns true even if the collections is within a `withMutations()`.
5017
+ *
5018
+ * <!-- runkit:activate -->
5019
+ * ```js
5020
+ * const { isImmutable, Map, List, Stack } = require('immutable');
5021
+ * isImmutable([]); // false
5022
+ * isImmutable({}); // false
5023
+ * isImmutable(Map()); // true
5024
+ * isImmutable(List()); // true
5025
+ * isImmutable(Stack()); // true
5026
+ * isImmutable(Map().asMutable()); // true
5027
+ * ```
5028
+ */
5029
+ function isImmutable(
5030
+ maybeImmutable: unknown
5031
+ ): maybeImmutable is Collection<unknown, unknown>;
5032
+
5033
+ /**
5034
+ * True if `maybeCollection` is a Collection, or any of its subclasses.
5035
+ *
5036
+ * <!-- runkit:activate -->
5037
+ * ```js
5038
+ * const { isCollection, Map, List, Stack } = require('immutable');
5039
+ * isCollection([]); // false
5040
+ * isCollection({}); // false
5041
+ * isCollection(Map()); // true
5042
+ * isCollection(List()); // true
5043
+ * isCollection(Stack()); // true
5044
+ * ```
5045
+ */
5046
+ function isCollection(
5047
+ maybeCollection: unknown
5048
+ ): maybeCollection is Collection<unknown, unknown>;
5049
+
5050
+ /**
5051
+ * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.
5052
+ *
5053
+ * <!-- runkit:activate -->
5054
+ * ```js
5055
+ * const { isKeyed, Map, List, Stack } = require('immutable');
5056
+ * isKeyed([]); // false
5057
+ * isKeyed({}); // false
5058
+ * isKeyed(Map()); // true
5059
+ * isKeyed(List()); // false
5060
+ * isKeyed(Stack()); // false
5061
+ * ```
5062
+ */
5063
+ function isKeyed(
5064
+ maybeKeyed: unknown
5065
+ ): maybeKeyed is Collection.Keyed<unknown, unknown>;
5066
+
5067
+ /**
5068
+ * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.
5069
+ *
5070
+ * <!-- runkit:activate -->
5071
+ * ```js
5072
+ * const { isIndexed, Map, List, Stack, Set } = require('immutable');
5073
+ * isIndexed([]); // false
5074
+ * isIndexed({}); // false
5075
+ * isIndexed(Map()); // false
5076
+ * isIndexed(List()); // true
5077
+ * isIndexed(Stack()); // true
5078
+ * isIndexed(Set()); // false
5079
+ * ```
5080
+ */
5081
+ function isIndexed(
5082
+ maybeIndexed: unknown
5083
+ ): maybeIndexed is Collection.Indexed<unknown>;
5084
+
5085
+ /**
5086
+ * True if `maybeAssociative` is either a Keyed or Indexed Collection.
5087
+ *
5088
+ * <!-- runkit:activate -->
5089
+ * ```js
5090
+ * const { isAssociative, Map, List, Stack, Set } = require('immutable');
5091
+ * isAssociative([]); // false
5092
+ * isAssociative({}); // false
5093
+ * isAssociative(Map()); // true
5094
+ * isAssociative(List()); // true
5095
+ * isAssociative(Stack()); // true
5096
+ * isAssociative(Set()); // false
5097
+ * ```
5098
+ */
5099
+ function isAssociative(
5100
+ maybeAssociative: unknown
5101
+ ): maybeAssociative is
5102
+ | Collection.Keyed<unknown, unknown>
5103
+ | Collection.Indexed<unknown>;
5104
+
5105
+ /**
5106
+ * True if `maybeOrdered` is a Collection where iteration order is well
5107
+ * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet.
5108
+ *
5109
+ * <!-- runkit:activate -->
5110
+ * ```js
5111
+ * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable');
5112
+ * isOrdered([]); // false
5113
+ * isOrdered({}); // false
5114
+ * isOrdered(Map()); // false
5115
+ * isOrdered(OrderedMap()); // true
5116
+ * isOrdered(List()); // true
5117
+ * isOrdered(Set()); // false
5118
+ * ```
5119
+ */
5120
+ function isOrdered(maybeOrdered: unknown): boolean;
5121
+
5122
+ /**
5123
+ * True if `maybeValue` is a JavaScript Object which has *both* `equals()`
5124
+ * and `hashCode()` methods.
5125
+ *
5126
+ * Any two instances of *value objects* can be compared for value equality with
5127
+ * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`.
5128
+ */
5129
+ function isValueObject(maybeValue: unknown): maybeValue is ValueObject;
5130
+
5131
+ /**
5132
+ * True if `maybeSeq` is a Seq.
5133
+ */
5134
+ function isSeq(
5135
+ maybeSeq: unknown
5136
+ ): maybeSeq is
5137
+ | Seq.Indexed<unknown>
5138
+ | Seq.Keyed<unknown, unknown>
5139
+ | Seq.Set<unknown>;
5140
+
5141
+ /**
5142
+ * True if `maybeList` is a List.
5143
+ */
5144
+ function isList(maybeList: unknown): maybeList is List<unknown>;
5145
+
5146
+ /**
5147
+ * True if `maybeMap` is a Map.
5148
+ *
5149
+ * Also true for OrderedMaps.
5150
+ */
5151
+ function isMap(maybeMap: unknown): maybeMap is Map<unknown, unknown>;
5152
+
5153
+ /**
5154
+ * True if `maybeOrderedMap` is an OrderedMap.
5155
+ */
5156
+ function isOrderedMap(
5157
+ maybeOrderedMap: unknown
5158
+ ): maybeOrderedMap is OrderedMap<unknown, unknown>;
5159
+
5160
+ /**
5161
+ * True if `maybeStack` is a Stack.
5162
+ */
5163
+ function isStack(maybeStack: unknown): maybeStack is Stack<unknown>;
5164
+
5165
+ /**
5166
+ * True if `maybeSet` is a Set.
5167
+ *
5168
+ * Also true for OrderedSets.
5169
+ */
5170
+ function isSet(maybeSet: unknown): maybeSet is Set<unknown>;
5171
+
5172
+ /**
5173
+ * True if `maybeOrderedSet` is an OrderedSet.
5174
+ */
5175
+ function isOrderedSet(
5176
+ maybeOrderedSet: unknown
5177
+ ): maybeOrderedSet is OrderedSet<unknown>;
5178
+
5179
+ /**
5180
+ * True if `maybeRecord` is a Record.
5181
+ */
5182
+ function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>;
5183
+
4859
5184
  /**
4860
5185
  * Returns the value within the provided collection associated with the
4861
5186
  * provided key, or notSetValue if the key is not defined in the collection.
@@ -4865,20 +5190,40 @@ declare module Immutable {
4865
5190
  *
4866
5191
  * <!-- runkit:activate -->
4867
5192
  * ```js
4868
- * const { get } = require('immutable@4.0.0-rc.8')
5193
+ * const { get } = require('immutable')
4869
5194
  * get([ 'dog', 'frog', 'cat' ], 2) // 'frog'
4870
5195
  * get({ x: 123, y: 456 }, 'x') // 123
4871
5196
  * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet'
4872
5197
  * ```
4873
5198
  */
4874
- export function get<K, V>(collection: Collection<K, V>, key: K): V | undefined;
4875
- export function get<K, V, NSV>(collection: Collection<K, V>, key: K, notSetValue: NSV): V | NSV;
4876
- export function get<TProps, K extends keyof TProps>(record: Record<TProps>, key: K, notSetValue: any): TProps[K];
4877
- export function get<V>(collection: Array<V>, key: number): V | undefined;
4878
- export function get<V, NSV>(collection: Array<V>, key: number, notSetValue: NSV): V | NSV;
4879
- export function get<C extends Object, K extends keyof C>(object: C, key: K, notSetValue: any): C[K];
4880
- export function get<V>(collection: {[key: string]: V}, key: string): V | undefined;
4881
- export function get<V, NSV>(collection: {[key: string]: V}, key: string, notSetValue: NSV): V | NSV;
5199
+ function get<K, V>(collection: Collection<K, V>, key: K): V | undefined;
5200
+ function get<K, V, NSV>(
5201
+ collection: Collection<K, V>,
5202
+ key: K,
5203
+ notSetValue: NSV
5204
+ ): V | NSV;
5205
+ function get<TProps extends object, K extends keyof TProps>(
5206
+ record: Record<TProps>,
5207
+ key: K,
5208
+ notSetValue: unknown
5209
+ ): TProps[K];
5210
+ function get<V>(collection: Array<V>, key: number): V | undefined;
5211
+ function get<V, NSV>(
5212
+ collection: Array<V>,
5213
+ key: number,
5214
+ notSetValue: NSV
5215
+ ): V | NSV;
5216
+ function get<C extends object, K extends keyof C>(
5217
+ object: C,
5218
+ key: K,
5219
+ notSetValue: unknown
5220
+ ): C[K];
5221
+ function get<V>(collection: { [key: string]: V }, key: string): V | undefined;
5222
+ function get<V, NSV>(
5223
+ collection: { [key: string]: V },
5224
+ key: string,
5225
+ notSetValue: NSV
5226
+ ): V | NSV;
4882
5227
 
4883
5228
  /**
4884
5229
  * Returns true if the key is defined in the provided collection.
@@ -4889,14 +5234,14 @@ declare module Immutable {
4889
5234
  *
4890
5235
  * <!-- runkit:activate -->
4891
5236
  * ```js
4892
- * const { has } = require('immutable@4.0.0-rc.8')
5237
+ * const { has } = require('immutable')
4893
5238
  * has([ 'dog', 'frog', 'cat' ], 2) // true
4894
5239
  * has([ 'dog', 'frog', 'cat' ], 5) // false
4895
5240
  * has({ x: 123, y: 456 }, 'x') // true
4896
5241
  * has({ x: 123, y: 456 }, 'z') // false
4897
5242
  * ```
4898
5243
  */
4899
- export function has(collection: Object, key: mixed): boolean;
5244
+ function has(collection: object, key: unknown): boolean;
4900
5245
 
4901
5246
  /**
4902
5247
  * Returns a copy of the collection with the value at key removed.
@@ -4907,7 +5252,7 @@ declare module Immutable {
4907
5252
  *
4908
5253
  * <!-- runkit:activate -->
4909
5254
  * ```js
4910
- * const { remove } = require('immutable@4.0.0-rc.8')
5255
+ * const { remove } = require('immutable')
4911
5256
  * const originalArray = [ 'dog', 'frog', 'cat' ]
4912
5257
  * remove(originalArray, 1) // [ 'dog', 'cat' ]
4913
5258
  * console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
@@ -4916,11 +5261,21 @@ declare module Immutable {
4916
5261
  * console.log(originalObject) // { x: 123, y: 456 }
4917
5262
  * ```
4918
5263
  */
4919
- export function remove<K, C extends Collection<K, any>>(collection: C, key: K): C;
4920
- export function remove<TProps, R extends Record<TProps>, K extends keyof TProps>(collection: C, key: K): C;
4921
- export function remove<C extends Array<any>>(collection: C, key: number): C;
4922
- export function remove<C, K extends keyof Obj>(collection: C, key: K): C;
4923
- export function remove<K, C extends {[key: string]: any}>(collection: C, key: K): C;
5264
+ function remove<K, C extends Collection<K, unknown>>(
5265
+ collection: C,
5266
+ key: K
5267
+ ): C;
5268
+ function remove<
5269
+ TProps extends object,
5270
+ C extends Record<TProps>,
5271
+ K extends keyof TProps
5272
+ >(collection: C, key: K): C;
5273
+ function remove<C extends Array<unknown>>(collection: C, key: number): C;
5274
+ function remove<C, K extends keyof C>(collection: C, key: K): C;
5275
+ function remove<C extends { [key: string]: unknown }, K extends keyof C>(
5276
+ collection: C,
5277
+ key: K
5278
+ ): C;
4924
5279
 
4925
5280
  /**
4926
5281
  * Returns a copy of the collection with the value at key set to the provided
@@ -4932,7 +5287,7 @@ declare module Immutable {
4932
5287
  *
4933
5288
  * <!-- runkit:activate -->
4934
5289
  * ```js
4935
- * const { set } = require('immutable@4.0.0-rc.8')
5290
+ * const { set } = require('immutable')
4936
5291
  * const originalArray = [ 'dog', 'frog', 'cat' ]
4937
5292
  * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ]
4938
5293
  * console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
@@ -4941,11 +5296,23 @@ declare module Immutable {
4941
5296
  * console.log(originalObject) // { x: 123, y: 456 }
4942
5297
  * ```
4943
5298
  */
4944
- export function set<K, V, C extends Collection<K, V>>(collection: C, key: K, value: V): C;
4945
- export function set<TProps, C extends Record<TProps>, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C;
4946
- export function set<V, C extends Array<V>>(collection: C, key: number, value: V): C;
4947
- export function set<C, K extends keyof C>(object: C, key: K, value: C[K]): C;
4948
- export function set<V, C extends {[key: string]: V}>(collection: C, key: string, value: V): C;
5299
+ function set<K, V, C extends Collection<K, V>>(
5300
+ collection: C,
5301
+ key: K,
5302
+ value: V
5303
+ ): C;
5304
+ function set<
5305
+ TProps extends object,
5306
+ C extends Record<TProps>,
5307
+ K extends keyof TProps
5308
+ >(record: C, key: K, value: TProps[K]): C;
5309
+ function set<V, C extends Array<V>>(collection: C, key: number, value: V): C;
5310
+ function set<C, K extends keyof C>(object: C, key: K, value: C[K]): C;
5311
+ function set<V, C extends { [key: string]: V }>(
5312
+ collection: C,
5313
+ key: string,
5314
+ value: V
5315
+ ): C;
4949
5316
 
4950
5317
  /**
4951
5318
  * Returns a copy of the collection with the value at key set to the result of
@@ -4957,25 +5324,75 @@ declare module Immutable {
4957
5324
  *
4958
5325
  * <!-- runkit:activate -->
4959
5326
  * ```js
4960
- * const { update } = require('immutable@4.0.0-rc.8')
5327
+ * const { update } = require('immutable')
4961
5328
  * const originalArray = [ 'dog', 'frog', 'cat' ]
4962
5329
  * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ]
4963
5330
  * console.log(originalArray) // [ 'dog', 'frog', 'cat' ]
4964
5331
  * const originalObject = { x: 123, y: 456 }
4965
- * set(originalObject, 'x', val => val * 6) // { x: 738, y: 456 }
5332
+ * update(originalObject, 'x', val => val * 6) // { x: 738, y: 456 }
4966
5333
  * console.log(originalObject) // { x: 123, y: 456 }
4967
5334
  * ```
4968
5335
  */
4969
- export function update<K, V, C extends Collection<K, V>>(collection: C, key: K, updater: (value: V) => V): C;
4970
- export function update<K, V, C extends Collection<K, V>, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): C;
4971
- export function update<TProps, C extends Record<TProps>, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C;
4972
- export function update<TProps, C extends Record<TProps>, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C;
4973
- export function update<V>(collection: Array<V>, key: number, updater: (value: V) => V): Array<V>;
4974
- export function update<V, NSV>(collection: Array<V>, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): C;
4975
- export function update<C, K extends keyof C>(object: C, key: K, updater: (value: C[K]) => C[K]): C;
4976
- export function update<C, K extends keyof C, NSV>(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C;
4977
- export function update<V, C extends {[key: string]: V}>(collection: C, key: K, updater: (value: V) => V): {[key: string]: V};
4978
- export function update<V, C extends {[key: string]: V}, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V};
5336
+ function update<K, V, C extends Collection<K, V>>(
5337
+ collection: C,
5338
+ key: K,
5339
+ updater: (value: V | undefined) => V
5340
+ ): C;
5341
+ function update<K, V, C extends Collection<K, V>, NSV>(
5342
+ collection: C,
5343
+ key: K,
5344
+ notSetValue: NSV,
5345
+ updater: (value: V | NSV) => V
5346
+ ): C;
5347
+ function update<
5348
+ TProps extends object,
5349
+ C extends Record<TProps>,
5350
+ K extends keyof TProps
5351
+ >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C;
5352
+ function update<
5353
+ TProps extends object,
5354
+ C extends Record<TProps>,
5355
+ K extends keyof TProps,
5356
+ NSV
5357
+ >(
5358
+ record: C,
5359
+ key: K,
5360
+ notSetValue: NSV,
5361
+ updater: (value: TProps[K] | NSV) => TProps[K]
5362
+ ): C;
5363
+ function update<V>(
5364
+ collection: Array<V>,
5365
+ key: number,
5366
+ updater: (value: V) => V
5367
+ ): Array<V>;
5368
+ function update<V, NSV>(
5369
+ collection: Array<V>,
5370
+ key: number,
5371
+ notSetValue: NSV,
5372
+ updater: (value: V | NSV) => V
5373
+ ): Array<V>;
5374
+ function update<C, K extends keyof C>(
5375
+ object: C,
5376
+ key: K,
5377
+ updater: (value: C[K]) => C[K]
5378
+ ): C;
5379
+ function update<C, K extends keyof C, NSV>(
5380
+ object: C,
5381
+ key: K,
5382
+ notSetValue: NSV,
5383
+ updater: (value: C[K] | NSV) => C[K]
5384
+ ): C;
5385
+ function update<V, C extends { [key: string]: V }, K extends keyof C>(
5386
+ collection: C,
5387
+ key: K,
5388
+ updater: (value: V) => V
5389
+ ): { [key: string]: V };
5390
+ function update<V, C extends { [key: string]: V }, K extends keyof C, NSV>(
5391
+ collection: C,
5392
+ key: K,
5393
+ notSetValue: NSV,
5394
+ updater: (value: V | NSV) => V
5395
+ ): { [key: string]: V };
4979
5396
 
4980
5397
  /**
4981
5398
  * Returns the value at the provided key path starting at the provided
@@ -4986,12 +5403,16 @@ declare module Immutable {
4986
5403
  *
4987
5404
  * <!-- runkit:activate -->
4988
5405
  * ```js
4989
- * const { getIn } = require('immutable@4.0.0-rc.8')
5406
+ * const { getIn } = require('immutable')
4990
5407
  * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123
4991
5408
  * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet'
4992
5409
  * ```
4993
5410
  */
4994
- export function getIn(collection: any, keyPath: Iterable<any>, notSetValue: any): any;
5411
+ function getIn(
5412
+ collection: unknown,
5413
+ keyPath: Iterable<unknown>,
5414
+ notSetValue?: unknown
5415
+ ): unknown;
4995
5416
 
4996
5417
  /**
4997
5418
  * Returns true if the key path is defined in the provided collection.
@@ -5001,12 +5422,12 @@ declare module Immutable {
5001
5422
  *
5002
5423
  * <!-- runkit:activate -->
5003
5424
  * ```js
5004
- * const { hasIn } = require('immutable@4.0.0-rc.8')
5425
+ * const { hasIn } = require('immutable')
5005
5426
  * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true
5006
5427
  * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false
5007
5428
  * ```
5008
5429
  */
5009
- export function hasIn(collection: any, keyPath: Iterable<any>): boolean;
5430
+ function hasIn(collection: unknown, keyPath: Iterable<unknown>): boolean;
5010
5431
 
5011
5432
  /**
5012
5433
  * Returns a copy of the collection with the value at the key path removed.
@@ -5016,13 +5437,13 @@ declare module Immutable {
5016
5437
  *
5017
5438
  * <!-- runkit:activate -->
5018
5439
  * ```js
5019
- * const { removeIn } = require('immutable@4.0.0-rc.8')
5440
+ * const { removeIn } = require('immutable')
5020
5441
  * const original = { x: { y: { z: 123 }}}
5021
5442
  * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}}
5022
5443
  * console.log(original) // { x: { y: { z: 123 }}}
5023
5444
  * ```
5024
5445
  */
5025
- export function removeIn<C>(collection: C, keyPath: Iterable<any>): C;
5446
+ function removeIn<C>(collection: C, keyPath: Iterable<unknown>): C;
5026
5447
 
5027
5448
  /**
5028
5449
  * Returns a copy of the collection with the value at the key path set to the
@@ -5033,13 +5454,17 @@ declare module Immutable {
5033
5454
  *
5034
5455
  * <!-- runkit:activate -->
5035
5456
  * ```js
5036
- * const { setIn } = require('immutable@4.0.0-rc.8')
5457
+ * const { setIn } = require('immutable')
5037
5458
  * const original = { x: { y: { z: 123 }}}
5038
5459
  * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}}
5039
5460
  * console.log(original) // { x: { y: { z: 123 }}}
5040
5461
  * ```
5041
5462
  */
5042
- export function setIn<C>(collection: C, keyPath: Iterable<any>, value: any): C;
5463
+ function setIn<C>(
5464
+ collection: C,
5465
+ keyPath: Iterable<unknown>,
5466
+ value: unknown
5467
+ ): C;
5043
5468
 
5044
5469
  /**
5045
5470
  * Returns a copy of the collection with the value at key path set to the
@@ -5050,14 +5475,23 @@ declare module Immutable {
5050
5475
  *
5051
5476
  * <!-- runkit:activate -->
5052
5477
  * ```js
5053
- * const { setIn } = require('immutable@4.0.0-rc.8')
5478
+ * const { updateIn } = require('immutable')
5054
5479
  * const original = { x: { y: { z: 123 }}}
5055
- * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}}
5480
+ * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}}
5056
5481
  * console.log(original) // { x: { y: { z: 123 }}}
5057
5482
  * ```
5058
5483
  */
5059
- export function updateIn<C>(collection: C, keyPath: Iterable<any>, updater: (value: any) => any): C;
5060
- export function updateIn<C>(collection: C, keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): C;
5484
+ function updateIn<C>(
5485
+ collection: C,
5486
+ keyPath: Iterable<unknown>,
5487
+ updater: (value: unknown) => unknown
5488
+ ): C;
5489
+ function updateIn<C>(
5490
+ collection: C,
5491
+ keyPath: Iterable<unknown>,
5492
+ notSetValue: unknown,
5493
+ updater: (value: unknown) => unknown
5494
+ ): C;
5061
5495
 
5062
5496
  /**
5063
5497
  * Returns a copy of the collection with the remaining collections merged in.
@@ -5067,15 +5501,19 @@ declare module Immutable {
5067
5501
  *
5068
5502
  * <!-- runkit:activate -->
5069
5503
  * ```js
5070
- * const { merge } = require('immutable@4.0.0-rc.8')
5504
+ * const { merge } = require('immutable')
5071
5505
  * const original = { x: 123, y: 456 }
5072
5506
  * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' }
5073
- * console.log(original) // { x: { y: { z: 123 }}}
5507
+ * console.log(original) // { x: 123, y: 456 }
5074
5508
  * ```
5075
5509
  */
5076
- export function merge<C>(
5510
+ function merge<C>(
5077
5511
  collection: C,
5078
- ...collections: Array<Iterable<any> | Iterable<[any, any]> | {[key: string]: any}>
5512
+ ...collections: Array<
5513
+ | Iterable<unknown>
5514
+ | Iterable<[unknown, unknown]>
5515
+ | { [key: string]: unknown }
5516
+ >
5079
5517
  ): C;
5080
5518
 
5081
5519
  /**
@@ -5087,53 +5525,72 @@ declare module Immutable {
5087
5525
  *
5088
5526
  * <!-- runkit:activate -->
5089
5527
  * ```js
5090
- * const { mergeWith } = require('immutable@4.0.0-rc.8')
5528
+ * const { mergeWith } = require('immutable')
5091
5529
  * const original = { x: 123, y: 456 }
5092
5530
  * mergeWith(
5093
5531
  * (oldVal, newVal) => oldVal + newVal,
5094
5532
  * original,
5095
5533
  * { y: 789, z: 'abc' }
5096
5534
  * ) // { x: 123, y: 1245, z: 'abc' }
5097
- * console.log(original) // { x: { y: { z: 123 }}}
5535
+ * console.log(original) // { x: 123, y: 456 }
5098
5536
  * ```
5099
5537
  */
5100
- export function mergeWith<C>(
5101
- merger: (oldVal: any, newVal: any, key: any) => any,
5538
+ function mergeWith<C>(
5539
+ merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
5102
5540
  collection: C,
5103
- ...collections: Array<Iterable<any> | Iterable<[any, any]> | {[key: string]: any}>
5541
+ ...collections: Array<
5542
+ | Iterable<unknown>
5543
+ | Iterable<[unknown, unknown]>
5544
+ | { [key: string]: unknown }
5545
+ >
5104
5546
  ): C;
5105
5547
 
5106
5548
  /**
5107
- * Returns a copy of the collection with the remaining collections merged in
5108
- * deeply (recursively).
5549
+ * Like `merge()`, but when two compatible collections are encountered with
5550
+ * the same key, it merges them as well, recursing deeply through the nested
5551
+ * data. Two collections are considered to be compatible (and thus will be
5552
+ * merged together) if they both fall into one of three categories: keyed
5553
+ * (e.g., `Map`s, `Record`s, and objects), indexed (e.g., `List`s and
5554
+ * arrays), or set-like (e.g., `Set`s). If they fall into separate
5555
+ * categories, `mergeDeep` will replace the existing collection with the
5556
+ * collection being merged in. This behavior can be customized by using
5557
+ * `mergeDeepWith()`.
5558
+ *
5559
+ * Note: Indexed and set-like collections are merged using
5560
+ * `concat()`/`union()` and therefore do not recurse.
5109
5561
  *
5110
5562
  * A functional alternative to `collection.mergeDeep()` which will also work
5111
5563
  * with plain Objects and Arrays.
5112
5564
  *
5113
5565
  * <!-- runkit:activate -->
5114
5566
  * ```js
5115
- * const { merge } = require('immutable@4.0.0-rc.8')
5567
+ * const { mergeDeep } = require('immutable')
5116
5568
  * const original = { x: { y: 123 }}
5117
- * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }}
5569
+ * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }}
5118
5570
  * console.log(original) // { x: { y: 123 }}
5119
5571
  * ```
5120
5572
  */
5121
- export function mergeDeep<C>(
5573
+ function mergeDeep<C>(
5122
5574
  collection: C,
5123
- ...collections: Array<Iterable<any> | Iterable<[any, any]> | {[key: string]: any}>
5575
+ ...collections: Array<
5576
+ | Iterable<unknown>
5577
+ | Iterable<[unknown, unknown]>
5578
+ | { [key: string]: unknown }
5579
+ >
5124
5580
  ): C;
5125
5581
 
5126
5582
  /**
5127
- * Returns a copy of the collection with the remaining collections merged in
5128
- * deeply (recursively), calling the `merger` function whenever an existing
5129
- * value is encountered.
5583
+ * Like `mergeDeep()`, but when two non-collections or incompatible
5584
+ * collections are encountered at the same key, it uses the `merger` function
5585
+ * to determine the resulting value. Collections are considered incompatible
5586
+ * if they fall into separate categories between keyed, indexed, and set-like.
5130
5587
  *
5131
5588
  * A functional alternative to `collection.mergeDeepWith()` which will also
5132
5589
  * work with plain Objects and Arrays.
5133
5590
  *
5134
5591
  * <!-- runkit:activate -->
5135
5592
  * ```js
5136
- * const { merge } = require('immutable@4.0.0-rc.8')
5593
+ * const { mergeDeepWith } = require('immutable')
5137
5594
  * const original = { x: { y: 123 }}
5138
5595
  * mergeDeepWith(
5139
5596
  * (oldVal, newVal) => oldVal + newVal,
@@ -5143,13 +5600,37 @@ declare module Immutable {
5143
5600
  * console.log(original) // { x: { y: 123 }}
5144
5601
  * ```
5145
5602
  */
5146
- export function mergeDeepWith<C>(
5147
- merger: (oldVal: any, newVal: any, key: any) => mixed,
5603
+ function mergeDeepWith<C>(
5604
+ merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown,
5148
5605
  collection: C,
5149
- ...collections: Array<Iterable<any> | Iterable<[any, any]> | {[key: string]: any}>
5606
+ ...collections: Array<
5607
+ | Iterable<unknown>
5608
+ | Iterable<[unknown, unknown]>
5609
+ | { [key: string]: unknown }
5610
+ >
5150
5611
  ): C;
5151
5612
  }
5152
5613
 
5153
- declare module "immutable" {
5154
- export = Immutable
5155
- }
5614
+ /**
5615
+ * Defines the main export of the immutable module to be the Immutable namespace
5616
+ * This supports many common module import patterns:
5617
+ *
5618
+ * const Immutable = require("immutable");
5619
+ * const { List } = require("immutable");
5620
+ * import Immutable from "immutable";
5621
+ * import * as Immutable from "immutable";
5622
+ * import { List } from "immutable";
5623
+ *
5624
+ */
5625
+ export = Immutable;
5626
+
5627
+ /**
5628
+ * A global "Immutable" namespace used by UMD modules which allows the use of
5629
+ * the full Immutable API.
5630
+ *
5631
+ * If using Immutable as an imported module, prefer using:
5632
+ *
5633
+ * import Immutable from 'immutable'
5634
+ *
5635
+ */
5636
+ export as namespace Immutable;