immutable 3.8.2 → 4.0.0-rc.12

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.
@@ -9,81 +9,96 @@
9
9
  * This file provides type definitions for use with the Flow type checker.
10
10
  *
11
11
  * An important caveat when using these definitions is that the types for
12
- * `Iterable.Keyed`, `Iterable.Indexed`, `Seq.Keyed`, and so on are stubs.
12
+ * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs.
13
13
  * When referring to those types, you can get the proper definitions by
14
- * importing the types `KeyedIterable`, `IndexedIterable`, `KeyedSeq`, etc.
14
+ * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc.
15
15
  * For example,
16
16
  *
17
17
  * import { Seq } from 'immutable'
18
- * import type { IndexedIterable, IndexedSeq } from 'immutable'
18
+ * import type { IndexedCollection, IndexedSeq } from 'immutable'
19
19
  *
20
20
  * const someSeq: IndexedSeq<number> = Seq.Indexed.of(1, 2, 3)
21
21
  *
22
- * function takesASeq<T, TS: IndexedIterable<T>>(iter: TS): TS {
22
+ * function takesASeq<T, TS: IndexedCollection<T>>(iter: TS): TS {
23
23
  * return iter.butLast()
24
24
  * }
25
25
  *
26
26
  * takesASeq(someSeq)
27
27
  *
28
- * @flow
28
+ * @flow strict
29
29
  */
30
30
 
31
- /*
32
- * Alias for ECMAScript `Iterable` type, declared in
33
- * https://github.com/facebook/flow/blob/master/lib/core.js
34
- *
35
- * Note that Immutable values implement the `ESIterable` interface.
36
- */
37
- type ESIterable<T> = $Iterable<T,void,void>;
38
-
39
- declare class Iterable<K, V> extends _Iterable<K, V, typeof KeyedIterable, typeof IndexedIterable, typeof SetIterable> {}
40
-
41
- declare class _Iterable<K, V, KI, II, SI> {
42
- static Keyed: KI;
43
- static Indexed: II;
44
- static Set: SI;
45
-
46
- static isIterable(maybeIterable: any): boolean;
47
- static isKeyed(maybeKeyed: any): boolean;
48
- static isIndexed(maybeIndexed: any): boolean;
49
- static isAssociative(maybeAssociative: any): boolean;
50
- static isOrdered(maybeOrdered: any): boolean;
51
-
52
- equals(other: Iterable<K,V>): boolean;
31
+ // Helper type that represents plain objects allowed as arguments to
32
+ // some constructors and functions.
33
+ type PlainObjInput<K, V> = {+[key: K]: V, __proto__: null};
34
+
35
+ // Helper types to extract the "keys" and "values" use by the *In() methods.
36
+ type $KeyOf<C> = $Call<
37
+ & (<K>(?_Collection<K, mixed>) => K)
38
+ & (<T>(?$ReadOnlyArray<T>) => number)
39
+ & (<T>(?RecordInstance<T> | T) => $Keys<T>),
40
+ C
41
+ >;
42
+
43
+ type $ValOf<C, K = $KeyOf<C>> = $Call<
44
+ & (<V>(?_Collection<any, V>) => V)
45
+ & (<T>(?$ReadOnlyArray<T>) => T)
46
+ & (<T, K: $Keys<T>>(?RecordInstance<T> | T, K) => $ElementType<T, K>)
47
+ & (<V>(?{[any]: V}) => V),
48
+ C,
49
+ K
50
+ >;
51
+
52
+ type $IterableOf<C> = $Call<
53
+ & (<V: Array<any> | IndexedCollection<any> | SetCollection<any>>(V) => Iterable<$ValOf<V>>)
54
+ & (<V: KeyedCollection<any, any> | RecordInstance<any> | PlainObjInput<any, any>>(V) => Iterable<[$KeyOf<V>, $ValOf<V>]>),
55
+ C
56
+ >;
57
+
58
+ declare class _Collection<K, +V> implements ValueObject {
59
+ equals(other: mixed): boolean;
53
60
  hashCode(): number;
54
- get(key: K): V;
55
- get<V_>(key: K, notSetValue: V_): V|V_;
61
+ get(key: K, ..._: []): V | void;
62
+ get<NSV>(key: K, notSetValue: NSV): V | NSV;
56
63
  has(key: K): boolean;
57
64
  includes(value: V): boolean;
58
65
  contains(value: V): boolean;
59
- first(): V;
60
- last(): V;
66
+ first<NSV>(notSetValue?: NSV): V | NSV;
67
+ last<NSV>(notSetValue?: NSV): V | NSV;
68
+
69
+ hasIn(keyPath: Iterable<mixed>): boolean;
61
70
 
62
- getIn<T>(searchKeyPath: ESIterable<any>, notSetValue: T): T;
63
- getIn<T>(searchKeyPath: ESIterable<any>): T;
64
- hasIn(searchKeyPath: ESIterable<any>): boolean;
71
+ getIn(keyPath: [], notSetValue?: mixed): this;
72
+ getIn<NSV>(keyPath: [K], notSetValue: NSV): V | NSV;
73
+ getIn<NSV, K2: $KeyOf<V>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<V, K2> | NSV;
74
+ getIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<V, K2>, K3> | NSV;
75
+ getIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV;
76
+ getIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV;
65
77
 
66
- toJS(): any;
67
- toArray(): V[];
78
+ update<U>(updater: (value: this) => U): U;
79
+
80
+ toJS(): Array<any> | { [key: string]: mixed };
81
+ toJSON(): Array<V> | { [key: string]: V };
82
+ toArray(): Array<V> | Array<[K,V]>;
68
83
  toObject(): { [key: string]: V };
69
- toMap(): Map<K,V>;
70
- toOrderedMap(): Map<K,V>;
84
+ toMap(): Map<K, V>;
85
+ toOrderedMap(): OrderedMap<K, V>;
71
86
  toSet(): Set<V>;
72
- toOrderedSet(): Set<V>;
87
+ toOrderedSet(): OrderedSet<V>;
73
88
  toList(): List<V>;
74
89
  toStack(): Stack<V>;
75
- toSeq(): Seq<K,V>;
76
- toKeyedSeq(): KeyedSeq<K,V>;
90
+ toSeq(): Seq<K, V>;
91
+ toKeyedSeq(): KeyedSeq<K, V>;
77
92
  toIndexedSeq(): IndexedSeq<V>;
78
93
  toSetSeq(): SetSeq<V>;
79
94
 
80
95
  keys(): Iterator<K>;
81
96
  values(): Iterator<V>;
82
- entries(): Iterator<[K,V]>;
97
+ entries(): Iterator<[K, V]>;
83
98
 
84
99
  keySeq(): IndexedSeq<K>;
85
100
  valueSeq(): IndexedSeq<V>;
86
- entrySeq(): IndexedSeq<[K,V]>;
101
+ entrySeq(): IndexedSeq<[K, V]>;
87
102
 
88
103
  reverse(): this;
89
104
  sort(comparator?: (valueA: V, valueB: V) => number): this;
@@ -95,12 +110,12 @@ declare class _Iterable<K, V, KI, II, SI> {
95
110
 
96
111
  groupBy<G>(
97
112
  grouper: (value: V, key: K, iter: this) => G,
98
- context?: any
113
+ context?: mixed
99
114
  ): KeyedSeq<G, this>;
100
115
 
101
116
  forEach(
102
117
  sideEffect: (value: V, key: K, iter: this) => any,
103
- context?: any
118
+ context?: mixed
104
119
  ): number;
105
120
 
106
121
  slice(begin?: number, end?: number): this;
@@ -108,73 +123,62 @@ declare class _Iterable<K, V, KI, II, SI> {
108
123
  butLast(): this;
109
124
  skip(amount: number): this;
110
125
  skipLast(amount: number): this;
111
- skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
112
- skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
126
+ skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this;
127
+ skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this;
113
128
  take(amount: number): this;
114
129
  takeLast(amount: number): this;
115
- takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
116
- takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: any): this;
117
- flatten(depth?: number): /*this*/Iterable<any,any>;
118
- flatten(shallow?: boolean): /*this*/Iterable<any,any>;
119
-
120
- filter(
121
- predicate: (value: V, key: K, iter: this) => mixed,
122
- context?: any
123
- ): this;
130
+ takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this;
131
+ takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this;
124
132
 
125
133
  filterNot(
126
134
  predicate: (value: V, key: K, iter: this) => mixed,
127
- context?: any
135
+ context?: mixed
128
136
  ): this;
129
137
 
130
138
  reduce<R>(
131
139
  reducer: (reduction: R, value: V, key: K, iter: this) => R,
132
- initialReduction?: R,
133
- context?: any,
140
+ initialReduction: R,
141
+ context?: mixed,
142
+ ): R;
143
+ reduce<R>(
144
+ reducer: (reduction: V | R, value: V, key: K, iter: this) => R
134
145
  ): R;
135
146
 
136
147
  reduceRight<R>(
137
148
  reducer: (reduction: R, value: V, key: K, iter: this) => R,
138
- initialReduction?: R,
139
- context?: any,
149
+ initialReduction: R,
150
+ context?: mixed,
151
+ ): R;
152
+ reduceRight<R>(
153
+ reducer: (reduction: V | R, value: V, key: K, iter: this) => R
140
154
  ): R;
141
155
 
142
- every(predicate: (value: V, key: K, iter: this) => mixed, context?: any): boolean;
143
- some(predicate: (value: V, key: K, iter: this) => mixed, context?: any): boolean;
156
+ every(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean;
157
+ some(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean;
144
158
  join(separator?: string): string;
145
159
  isEmpty(): boolean;
146
- count(predicate?: (value: V, key: K, iter: this) => mixed, context?: any): number;
147
- countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G,number>;
160
+ count(predicate?: (value: V, key: K, iter: this) => mixed, context?: mixed): number;
161
+ countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: mixed): Map<G, number>;
148
162
 
149
- find(
163
+ find<NSV>(
150
164
  predicate: (value: V, key: K, iter: this) => mixed,
151
- context?: any,
152
- ): ?V;
153
- find<V_>(
165
+ context?: mixed,
166
+ notSetValue?: NSV
167
+ ): V | NSV;
168
+ findLast<NSV>(
154
169
  predicate: (value: V, key: K, iter: this) => mixed,
155
- context: any,
156
- notSetValue: V_
157
- ): V|V_;
170
+ context?: mixed,
171
+ notSetValue?: NSV
172
+ ): V | NSV;
158
173
 
159
- findLast(
160
- predicate: (value: V, key: K, iter: this) => mixed,
161
- context?: any,
162
- ): ?V;
163
- findLast<V_>(
164
- predicate: (value: V, key: K, iter: this) => mixed,
165
- context: any,
166
- notSetValue: V_
167
- ): V|V_;
174
+ findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void;
175
+ findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void;
168
176
 
177
+ findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void;
178
+ findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void;
169
179
 
170
- findEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V];
171
- findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V];
172
-
173
- findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: any): ?K;
174
- findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: any): ?K;
175
-
176
- keyOf(searchValue: V): ?K;
177
- lastKeyOf(searchValue: V): ?K;
180
+ keyOf(searchValue: V): K | void;
181
+ lastKeyOf(searchValue: V): K | void;
178
182
 
179
183
  max(comparator?: (valueA: V, valueB: V) => number): V;
180
184
  maxBy<C>(
@@ -187,54 +191,106 @@ declare class _Iterable<K, V, KI, II, SI> {
187
191
  comparator?: (valueA: C, valueB: C) => number
188
192
  ): V;
189
193
 
190
- isSubset(iter: Iterable<any, V>): boolean;
191
- isSubset(iter: ESIterable<V>): boolean;
192
- isSuperset(iter: Iterable<any, V>): boolean;
193
- isSuperset(iter: ESIterable<V>): boolean;
194
+ isSubset(iter: Iterable<V>): boolean;
195
+ isSuperset(iter: Iterable<V>): boolean;
194
196
  }
195
197
 
196
- declare class KeyedIterable<K,V> extends Iterable<K,V> {
197
- static <K,V>(iter?: ESIterable<[K,V]>): KeyedIterable<K,V>;
198
- static <K,V>(obj?: { [key: K]: V }): KeyedIterable<K,V>;
198
+ declare function isImmutable(maybeImmutable: mixed): boolean %checks(maybeImmutable instanceof Collection);
199
+ declare function isCollection(maybeCollection: mixed): boolean %checks(maybeCollection instanceof Collection);
200
+ declare function isKeyed(maybeKeyed: mixed): boolean %checks(maybeKeyed instanceof KeyedCollection);
201
+ declare function isIndexed(maybeIndexed: mixed): boolean %checks(maybeIndexed instanceof IndexedCollection);
202
+ declare function isAssociative(maybeAssociative: mixed): boolean %checks(
203
+ maybeAssociative instanceof KeyedCollection ||
204
+ maybeAssociative instanceof IndexedCollection
205
+ );
206
+ declare function isOrdered(maybeOrdered: mixed): boolean %checks(
207
+ maybeOrdered instanceof IndexedCollection ||
208
+ maybeOrdered instanceof OrderedMap ||
209
+ maybeOrdered instanceof OrderedSet
210
+ );
211
+ declare function isValueObject(maybeValue: mixed): boolean;
212
+
213
+ declare function isSeq(maybeSeq: any): boolean %checks(maybeSeq instanceof Seq);
214
+ declare function isList(maybeList: any): boolean %checks(maybeList instanceof List);
215
+ declare function isMap(maybeMap: any): boolean %checks(maybeMap instanceof Map);
216
+ declare function isOrderedMap(maybeOrderedMap: any): boolean %checks(maybeOrderedMap instanceof OrderedMap);
217
+ declare function isStack(maybeStack: any): boolean %checks(maybeStack instanceof Stack);
218
+ declare function isSet(maybeSet: any): boolean %checks(maybeSet instanceof Set);
219
+ declare function isOrderedSet(maybeOrderedSet: any): boolean %checks(maybeOrderedSet instanceof OrderedSet);
220
+ declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof Record);
221
+
222
+ declare interface ValueObject {
223
+ equals(other: mixed): boolean;
224
+ hashCode(): number;
225
+ }
199
226
 
200
- @@iterator(): Iterator<[K,V]>;
201
- toSeq(): KeyedSeq<K,V>;
202
- flip(): /*this*/KeyedIterable<V,K>;
227
+ declare class Collection<K, +V> extends _Collection<K, V> {
228
+ static Keyed: typeof KeyedCollection;
229
+ static Indexed: typeof IndexedCollection;
230
+ static Set: typeof SetCollection;
203
231
 
204
- mapKeys<K_>(
205
- mapper: (key: K, value: V, iter: this) => K_,
206
- context?: any
207
- ): /*this*/KeyedIterable<K_,V>;
232
+ static isCollection: typeof isCollection;
233
+ static isKeyed: typeof isKeyed;
234
+ static isIndexed: typeof isIndexed;
235
+ static isAssociative: typeof isAssociative;
236
+ static isOrdered: typeof isOrdered;
237
+ }
208
238
 
209
- mapEntries<K_,V_>(
210
- mapper: (entry: [K,V], index: number, iter: this) => [K_,V_],
211
- context?: any
212
- ): /*this*/KeyedIterable<K_,V_>;
239
+ declare class KeyedCollection<K, +V> extends Collection<K, V> {
240
+ static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): KeyedCollection<K, V>;
213
241
 
214
- concat(...iters: ESIterable<[K,V]>[]): this;
242
+ toJS(): { [key: string]: mixed };
243
+ toJSON(): { [key: string]: V };
244
+ toArray(): Array<[K, V]>;
245
+ @@iterator(): Iterator<[K, V]>;
246
+ toSeq(): KeyedSeq<K, V>;
247
+ flip(): KeyedCollection<V, K>;
215
248
 
216
- map<V_>(
217
- mapper: (value: V, key: K, iter: this) => V_,
218
- context?: any
219
- ): /*this*/KeyedIterable<K,V_>;
249
+ concat<KC, VC>(...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>>): KeyedCollection<K | KC, V | VC>;
220
250
 
221
- flatMap<K_, V_>(
222
- mapper: (value: V, key: K, iter: this) => ESIterable<[K_,V_]>,
223
- context?: any
224
- ): /*this*/KeyedIterable<K_,V_>;
251
+ filter(predicate: typeof Boolean): KeyedCollection<K, $NonMaybeType<V>>;
252
+ filter(
253
+ predicate: (value: V, key: K, iter: this) => mixed,
254
+ context?: mixed
255
+ ): KeyedCollection<K, V>;
225
256
 
226
- flatten(depth?: number): /*this*/KeyedIterable<any,any>;
227
- flatten(shallow?: boolean): /*this*/KeyedIterable<any,any>;
257
+ map<M>(
258
+ mapper: (value: V, key: K, iter: this) => M,
259
+ context?: mixed
260
+ ): KeyedCollection<K, M>;
261
+
262
+ mapKeys<M>(
263
+ mapper: (key: K, value: V, iter: this) => M,
264
+ context?: mixed
265
+ ): KeyedCollection<M, V>;
266
+
267
+ mapEntries<KM, VM>(
268
+ mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
269
+ context?: mixed
270
+ ): KeyedCollection<KM, VM>;
271
+
272
+ flatMap<KM, VM>(
273
+ mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
274
+ context?: mixed
275
+ ): KeyedCollection<KM, VM>;
276
+
277
+ flatten(depth?: number): KeyedCollection<any, any>;
278
+ flatten(shallow?: boolean): KeyedCollection<any, any>;
228
279
  }
229
280
 
230
- declare class IndexedIterable<T> extends Iterable<number,T> {
231
- static <T>(iter?: ESIterable<T>): IndexedIterable<T>;
281
+ Collection.Keyed = KeyedCollection
282
+
283
+ declare class IndexedCollection<+T> extends Collection<number, T> {
284
+ static <T>(iter?: Iterable<T>): IndexedCollection<T>;
232
285
 
286
+ toJS(): Array<mixed>;
287
+ toJSON(): Array<T>;
288
+ toArray(): Array<T>;
233
289
  @@iterator(): Iterator<T>;
234
290
  toSeq(): IndexedSeq<T>;
235
- fromEntrySeq<K,V>(): KeyedSeq<K,V>;
291
+ fromEntrySeq<K, V>(): KeyedSeq<K, V>;
236
292
  interpose(separator: T): this;
237
- interleave(...iterables: ESIterable<T>[]): this;
293
+ interleave(...collections: Iterable<T>[]): this;
238
294
  splice(
239
295
  index: number,
240
296
  removeNum: number,
@@ -242,418 +298,1325 @@ declare class IndexedIterable<T> extends Iterable<number,T> {
242
298
  ): this;
243
299
 
244
300
  zip<A>(
245
- a: ESIterable<A>,
246
- $?: null
247
- ): IndexedIterable<[T,A]>;
248
- zip<A,B>(
249
- a: ESIterable<A>,
250
- b: ESIterable<B>,
251
- $?: null
252
- ): IndexedIterable<[T,A,B]>;
253
- zip<A,B,C>(
254
- a: ESIterable<A>,
255
- b: ESIterable<B>,
256
- c: ESIterable<C>,
257
- $?: null
258
- ): IndexedIterable<[T,A,B,C]>;
259
- zip<A,B,C,D>(
260
- a: ESIterable<A>,
261
- b: ESIterable<B>,
262
- c: ESIterable<C>,
263
- d: ESIterable<D>,
264
- $?: null
265
- ): IndexedIterable<[T,A,B,C,D]>;
266
- zip<A,B,C,D,E>(
267
- a: ESIterable<A>,
268
- b: ESIterable<B>,
269
- c: ESIterable<C>,
270
- d: ESIterable<D>,
271
- e: ESIterable<E>,
272
- $?: null
273
- ): IndexedIterable<[T,A,B,C,D,E]>;
274
-
275
- zipWith<A,R>(
301
+ a: Iterable<A>,
302
+ ..._: []
303
+ ): IndexedCollection<[T, A]>;
304
+ zip<A, B>(
305
+ a: Iterable<A>,
306
+ b: Iterable<B>,
307
+ ..._: []
308
+ ): IndexedCollection<[T, A, B]>;
309
+ zip<A, B, C>(
310
+ a: Iterable<A>,
311
+ b: Iterable<B>,
312
+ c: Iterable<C>,
313
+ ..._: []
314
+ ): IndexedCollection<[T, A, B, C]>;
315
+ zip<A, B, C, D>(
316
+ a: Iterable<A>,
317
+ b: Iterable<B>,
318
+ c: Iterable<C>,
319
+ d: Iterable<D>,
320
+ ..._: []
321
+ ): IndexedCollection<[T, A, B, C, D]>;
322
+ zip<A, B, C, D, E>(
323
+ a: Iterable<A>,
324
+ b: Iterable<B>,
325
+ c: Iterable<C>,
326
+ d: Iterable<D>,
327
+ e: Iterable<E>,
328
+ ..._: []
329
+ ): IndexedCollection<[T, A, B, C, D, E]>;
330
+
331
+ zipAll<A>(
332
+ a: Iterable<A>,
333
+ ..._: []
334
+ ): IndexedCollection<[T|void, A|void]>;
335
+ zipAll<A, B>(
336
+ a: Iterable<A>,
337
+ b: Iterable<B>,
338
+ ..._: []
339
+ ): IndexedCollection<[T|void, A|void, B|void]>;
340
+ zipAll<A, B, C>(
341
+ a: Iterable<A>,
342
+ b: Iterable<B>,
343
+ c: Iterable<C>,
344
+ ..._: []
345
+ ): IndexedCollection<[T|void, A|void, B|void, C|void]>;
346
+ zipAll<A, B, C, D>(
347
+ a: Iterable<A>,
348
+ b: Iterable<B>,
349
+ c: Iterable<C>,
350
+ d: Iterable<D>,
351
+ ..._: []
352
+ ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void]>;
353
+ zipAll<A, B, C, D, E>(
354
+ a: Iterable<A>,
355
+ b: Iterable<B>,
356
+ c: Iterable<C>,
357
+ d: Iterable<D>,
358
+ e: Iterable<E>,
359
+ ..._: []
360
+ ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void, E|void]>;
361
+
362
+ zipWith<A, R>(
276
363
  zipper: (value: T, a: A) => R,
277
- a: ESIterable<A>,
278
- $?: null
279
- ): IndexedIterable<R>;
280
- zipWith<A,B,R>(
364
+ a: Iterable<A>,
365
+ ..._: []
366
+ ): IndexedCollection<R>;
367
+ zipWith<A, B, R>(
281
368
  zipper: (value: T, a: A, b: B) => R,
282
- a: ESIterable<A>,
283
- b: ESIterable<B>,
284
- $?: null
285
- ): IndexedIterable<R>;
286
- zipWith<A,B,C,R>(
369
+ a: Iterable<A>,
370
+ b: Iterable<B>,
371
+ ..._: []
372
+ ): IndexedCollection<R>;
373
+ zipWith<A, B, C, R>(
287
374
  zipper: (value: T, a: A, b: B, c: C) => R,
288
- a: ESIterable<A>,
289
- b: ESIterable<B>,
290
- c: ESIterable<C>,
291
- $?: null
292
- ): IndexedIterable<R>;
293
- zipWith<A,B,C,D,R>(
375
+ a: Iterable<A>,
376
+ b: Iterable<B>,
377
+ c: Iterable<C>,
378
+ ..._: []
379
+ ): IndexedCollection<R>;
380
+ zipWith<A, B, C, D, R>(
294
381
  zipper: (value: T, a: A, b: B, c: C, d: D) => R,
295
- a: ESIterable<A>,
296
- b: ESIterable<B>,
297
- c: ESIterable<C>,
298
- d: ESIterable<D>,
299
- $?: null
300
- ): IndexedIterable<R>;
301
- zipWith<A,B,C,D,E,R>(
382
+ a: Iterable<A>,
383
+ b: Iterable<B>,
384
+ c: Iterable<C>,
385
+ d: Iterable<D>,
386
+ ..._: []
387
+ ): IndexedCollection<R>;
388
+ zipWith<A, B, C, D, E, R>(
302
389
  zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
303
- a: ESIterable<A>,
304
- b: ESIterable<B>,
305
- c: ESIterable<C>,
306
- d: ESIterable<D>,
307
- e: ESIterable<E>,
308
- $?: null
309
- ): IndexedIterable<R>;
390
+ a: Iterable<A>,
391
+ b: Iterable<B>,
392
+ c: Iterable<C>,
393
+ d: Iterable<D>,
394
+ e: Iterable<E>,
395
+ ..._: []
396
+ ): IndexedCollection<R>;
310
397
 
311
398
  indexOf(searchValue: T): number;
312
399
  lastIndexOf(searchValue: T): number;
313
400
  findIndex(
314
401
  predicate: (value: T, index: number, iter: this) => mixed,
315
- context?: any
402
+ context?: mixed
316
403
  ): number;
317
404
  findLastIndex(
318
405
  predicate: (value: T, index: number, iter: this) => mixed,
319
- context?: any
406
+ context?: mixed
320
407
  ): number;
321
408
 
322
- concat(...iters: ESIterable<T>[]): this;
409
+ concat<C>(...iters: Array<Iterable<C> | C>): IndexedCollection<T | C>;
323
410
 
324
- map<U>(
325
- mapper: (value: T, index: number, iter: this) => U,
326
- context?: any
327
- ): /*this*/IndexedIterable<U>;
411
+ filter(predicate: typeof Boolean): IndexedCollection<$NonMaybeType<T>>;
412
+ filter(
413
+ predicate: (value: T, index: number, iter: this) => mixed,
414
+ context?: mixed
415
+ ): IndexedCollection<T>;
328
416
 
329
- flatMap<U>(
330
- mapper: (value: T, index: number, iter: this) => ESIterable<U>,
331
- context?: any
332
- ): /*this*/IndexedIterable<U>;
417
+ map<M>(
418
+ mapper: (value: T, index: number, iter: this) => M,
419
+ context?: mixed
420
+ ): IndexedCollection<M>;
333
421
 
334
- flatten(depth?: number): /*this*/IndexedIterable<any>;
335
- flatten(shallow?: boolean): /*this*/IndexedIterable<any>;
422
+ flatMap<M>(
423
+ mapper: (value: T, index: number, iter: this) => Iterable<M>,
424
+ context?: mixed
425
+ ): IndexedCollection<M>;
426
+
427
+ flatten(depth?: number): IndexedCollection<any>;
428
+ flatten(shallow?: boolean): IndexedCollection<any>;
336
429
  }
337
430
 
338
- declare class SetIterable<T> extends Iterable<T,T> {
339
- static <T>(iter?: ESIterable<T>): SetIterable<T>;
431
+ declare class SetCollection<+T> extends Collection<T, T> {
432
+ static <T>(iter?: Iterable<T>): SetCollection<T>;
340
433
 
434
+ toJS(): Array<mixed>;
435
+ toJSON(): Array<T>;
436
+ toArray(): Array<T>;
341
437
  @@iterator(): Iterator<T>;
342
438
  toSeq(): SetSeq<T>;
343
439
 
344
- concat(...iters: ESIterable<T>[]): this;
345
-
346
- // `map` and `flatMap` cannot be defined further up the hiearchy, because the
347
- // implementation for `KeyedIterable` allows the value type to change without
348
- // constraining the key type. That does not work for `SetIterable` - the value
349
- // and key types *must* match.
350
- map<U>(
351
- mapper: (value: T, value: T, iter: this) => U,
352
- context?: any
353
- ): /*this*/SetIterable<U>;
354
-
355
- flatMap<U>(
356
- mapper: (value: T, value: T, iter: this) => ESIterable<U>,
357
- context?: any
358
- ): /*this*/SetIterable<U>;
440
+ concat<U>(...collections: Iterable<U>[]): SetCollection<T | U>;
359
441
 
360
- flatten(depth?: number): /*this*/SetIterable<any>;
361
- flatten(shallow?: boolean): /*this*/SetIterable<any>;
362
- }
442
+ // `filter`, `map` and `flatMap` cannot be defined further up the hierarchy,
443
+ // because the implementation for `KeyedCollection` allows the value type to
444
+ // change without constraining the key type. That does not work for
445
+ // `SetCollection` - the value and key types *must* match.
446
+ filter(predicate: typeof Boolean): SetCollection<$NonMaybeType<T>>;
447
+ filter(
448
+ predicate: (value: T, value: T, iter: this) => mixed,
449
+ context?: mixed
450
+ ): SetCollection<T>;
363
451
 
364
- declare class Collection<K,V> extends _Iterable<K,V, typeof KeyedCollection, typeof IndexedCollection, typeof SetCollection> {
365
- size: number;
366
- }
452
+ map<M>(
453
+ mapper: (value: T, value: T, iter: this) => M,
454
+ context?: mixed
455
+ ): SetCollection<M>;
367
456
 
368
- declare class KeyedCollection<K,V> extends Collection<K,V> mixins KeyedIterable<K,V> {
369
- toSeq(): KeyedSeq<K,V>;
370
- }
457
+ flatMap<M>(
458
+ mapper: (value: T, value: T, iter: this) => Iterable<M>,
459
+ context?: mixed
460
+ ): SetCollection<M>;
371
461
 
372
- declare class IndexedCollection<T> extends Collection<number,T> mixins IndexedIterable<T> {
373
- toSeq(): IndexedSeq<T>;
462
+ flatten(depth?: number): SetCollection<any>;
463
+ flatten(shallow?: boolean): SetCollection<any>;
374
464
  }
375
465
 
376
- declare class SetCollection<T> extends Collection<T,T> mixins SetIterable<T> {
377
- toSeq(): SetSeq<T>;
378
- }
466
+ declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof Seq);
467
+ declare class Seq<K, +V> extends _Collection<K, V> {
468
+ static Keyed: typeof KeyedSeq;
469
+ static Indexed: typeof IndexedSeq;
470
+ static Set: typeof SetSeq;
379
471
 
380
- declare class Seq<K,V> extends _Iterable<K,V, typeof KeyedSeq, typeof IndexedSeq, typeof SetSeq> {
381
- static <K,V>(iter: KeyedSeq<K,V>): KeyedSeq<K,V>;
382
- static <T> (iter: SetSeq<T>): SetSeq<K,V>;
383
- static <T> (iter?: ESIterable<T>): IndexedSeq<T>;
384
- static <K,V>(iter: { [key: K]: V }): KeyedSeq<K,V>;
472
+ static <K, V>(values: KeyedSeq<K, V>): KeyedSeq<K, V>;
473
+ static <T>(values: SetSeq<T>): SetSeq<K, V>;
474
+ static <T>(values: Iterable<T>): IndexedSeq<T>;
475
+ static <K, V>(values?: PlainObjInput<K, V>): KeyedSeq<K, V>;
385
476
 
386
- static isSeq(maybeSeq: any): boolean;
387
- static of<T>(...values: T[]): IndexedSeq<T>;
477
+ static isSeq: typeof isSeq;
388
478
 
389
- size: ?number;
479
+ size: number | void;
390
480
  cacheResult(): this;
391
481
  toSeq(): this;
392
482
  }
393
483
 
394
- declare class KeyedSeq<K,V> extends Seq<K,V> mixins KeyedIterable<K,V> {
395
- static <K,V>(iter?: ESIterable<[K,V]>): KeyedSeq<K,V>;
396
- static <K,V>(iter?: { [key: K]: V }): KeyedSeq<K,V>;
484
+ declare class KeyedSeq<K, +V> extends Seq<K, V> mixins KeyedCollection<K, V> {
485
+ static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): KeyedSeq<K, V>;
486
+
487
+ // Override specialized return types
488
+ flip(): KeyedSeq<V, K>;
489
+
490
+ concat<KC, VC>(...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>>): KeyedSeq<K | KC, V | VC>;
491
+
492
+ filter(predicate: typeof Boolean): KeyedSeq<K, $NonMaybeType<V>>;
493
+ filter(
494
+ predicate: (value: V, key: K, iter: this) => mixed,
495
+ context?: mixed
496
+ ): KeyedSeq<K, V>;
497
+
498
+ map<M>(
499
+ mapper: (value: V, key: K, iter: this) => M,
500
+ context?: mixed
501
+ ): KeyedSeq<K, M>;
502
+
503
+ mapKeys<M>(
504
+ mapper: (key: K, value: V, iter: this) => M,
505
+ context?: mixed
506
+ ): KeyedSeq<M, V>;
507
+
508
+ mapEntries<KM, VM>(
509
+ mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
510
+ context?: mixed
511
+ ): KeyedSeq<KM, VM>;
512
+
513
+ flatMap<KM, VM>(
514
+ mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
515
+ context?: mixed
516
+ ): KeyedSeq<KM, VM>;
517
+
518
+ flatten(depth?: number): KeyedSeq<any, any>;
519
+ flatten(shallow?: boolean): KeyedSeq<any, any>;
397
520
  }
398
521
 
399
- declare class IndexedSeq<T> extends Seq<number,T> mixins IndexedIterable<T> {
400
- static <T>(iter?: ESIterable<T>): IndexedSeq<T>;
522
+ declare class IndexedSeq<+T> extends Seq<number, T> mixins IndexedCollection<T> {
523
+ static <T>(values?: Iterable<T>): IndexedSeq<T>;
524
+
401
525
  static of<T>(...values: T[]): IndexedSeq<T>;
526
+
527
+ // Override specialized return types
528
+
529
+ concat<C>(...iters: Array<Iterable<C> | C>): IndexedSeq<T | C>;
530
+
531
+ filter(predicate: typeof Boolean): IndexedSeq<$NonMaybeType<T>>;
532
+ filter(
533
+ predicate: (value: T, index: number, iter: this) => mixed,
534
+ context?: mixed
535
+ ): IndexedSeq<T>;
536
+
537
+ map<M>(
538
+ mapper: (value: T, index: number, iter: this) => M,
539
+ context?: mixed
540
+ ): IndexedSeq<M>;
541
+
542
+ flatMap<M>(
543
+ mapper: (value: T, index: number, iter: this) => Iterable<M>,
544
+ context?: mixed
545
+ ): IndexedSeq<M>;
546
+
547
+ flatten(depth?: number): IndexedSeq<any>;
548
+ flatten(shallow?: boolean): IndexedSeq<any>;
549
+
550
+ zip<A>(
551
+ a: Iterable<A>,
552
+ ..._: []
553
+ ): IndexedSeq<[T, A]>;
554
+ zip<A, B>(
555
+ a: Iterable<A>,
556
+ b: Iterable<B>,
557
+ ..._: []
558
+ ): IndexedSeq<[T, A, B]>;
559
+ zip<A, B, C>(
560
+ a: Iterable<A>,
561
+ b: Iterable<B>,
562
+ c: Iterable<C>,
563
+ ..._: []
564
+ ): IndexedSeq<[T, A, B, C]>;
565
+ zip<A, B, C, D>(
566
+ a: Iterable<A>,
567
+ b: Iterable<B>,
568
+ c: Iterable<C>,
569
+ d: Iterable<D>,
570
+ ..._: []
571
+ ): IndexedSeq<[T, A, B, C, D]>;
572
+ zip<A, B, C, D, E>(
573
+ a: Iterable<A>,
574
+ b: Iterable<B>,
575
+ c: Iterable<C>,
576
+ d: Iterable<D>,
577
+ e: Iterable<E>,
578
+ ..._: []
579
+ ): IndexedSeq<[T, A, B, C, D, E]>;
580
+
581
+ zipAll<A>(
582
+ a: Iterable<A>,
583
+ ..._: []
584
+ ): IndexedSeq<[T|void, A|void]>;
585
+ zipAll<A, B>(
586
+ a: Iterable<A>,
587
+ b: Iterable<B>,
588
+ ..._: []
589
+ ): IndexedSeq<[T|void, A|void, B|void]>;
590
+ zipAll<A, B, C>(
591
+ a: Iterable<A>,
592
+ b: Iterable<B>,
593
+ c: Iterable<C>,
594
+ ..._: []
595
+ ): IndexedSeq<[T|void, A|void, B|void, C|void]>;
596
+ zipAll<A, B, C, D>(
597
+ a: Iterable<A>,
598
+ b: Iterable<B>,
599
+ c: Iterable<C>,
600
+ d: Iterable<D>,
601
+ ..._: []
602
+ ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void]>;
603
+ zipAll<A, B, C, D, E>(
604
+ a: Iterable<A>,
605
+ b: Iterable<B>,
606
+ c: Iterable<C>,
607
+ d: Iterable<D>,
608
+ e: Iterable<E>,
609
+ ..._: []
610
+ ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void, E|void]>;
611
+
612
+ zipWith<A, R>(
613
+ zipper: (value: T, a: A) => R,
614
+ a: Iterable<A>,
615
+ ..._: []
616
+ ): IndexedSeq<R>;
617
+ zipWith<A, B, R>(
618
+ zipper: (value: T, a: A, b: B) => R,
619
+ a: Iterable<A>,
620
+ b: Iterable<B>,
621
+ ..._: []
622
+ ): IndexedSeq<R>;
623
+ zipWith<A, B, C, R>(
624
+ zipper: (value: T, a: A, b: B, c: C) => R,
625
+ a: Iterable<A>,
626
+ b: Iterable<B>,
627
+ c: Iterable<C>,
628
+ ..._: []
629
+ ): IndexedSeq<R>;
630
+ zipWith<A, B, C, D, R>(
631
+ zipper: (value: T, a: A, b: B, c: C, d: D) => R,
632
+ a: Iterable<A>,
633
+ b: Iterable<B>,
634
+ c: Iterable<C>,
635
+ d: Iterable<D>,
636
+ ..._: []
637
+ ): IndexedSeq<R>;
638
+ zipWith<A, B, C, D, E, R>(
639
+ zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
640
+ a: Iterable<A>,
641
+ b: Iterable<B>,
642
+ c: Iterable<C>,
643
+ d: Iterable<D>,
644
+ e: Iterable<E>,
645
+ ..._: []
646
+ ): IndexedSeq<R>;
402
647
  }
403
648
 
404
- declare class SetSeq<T> extends Seq<T,T> mixins SetIterable<T> {
405
- static <T>(iter?: ESIterable<T>): IndexedSeq<T>;
649
+ declare class SetSeq<+T> extends Seq<T, T> mixins SetCollection<T> {
650
+ static <T>(values?: Iterable<T>): SetSeq<T>;
651
+
406
652
  static of<T>(...values: T[]): SetSeq<T>;
653
+
654
+ // Override specialized return types
655
+
656
+ concat<U>(...collections: Iterable<U>[]): SetSeq<T | U>;
657
+
658
+ filter(predicate: typeof Boolean): SetSeq<$NonMaybeType<T>>;
659
+ filter(
660
+ predicate: (value: T, value: T, iter: this) => mixed,
661
+ context?: mixed
662
+ ): SetSeq<T>;
663
+
664
+ map<M>(
665
+ mapper: (value: T, value: T, iter: this) => M,
666
+ context?: mixed
667
+ ): SetSeq<M>;
668
+
669
+ flatMap<M>(
670
+ mapper: (value: T, value: T, iter: this) => Iterable<M>,
671
+ context?: mixed
672
+ ): SetSeq<M>;
673
+
674
+ flatten(depth?: number): SetSeq<any>;
675
+ flatten(shallow?: boolean): SetSeq<any>;
676
+ }
677
+
678
+ declare class UpdatableInCollection<K, +V> {
679
+ setIn<S>(keyPath: [], value: S): S;
680
+ setIn(keyPath: [K], value: V): this;
681
+ setIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], value: S): this;
682
+ setIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, S: $ValOf<$ValOf<V, K2>, K3>>(keyPath: [K, K2, K3], value: S): this;
683
+ setIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this;
684
+ setIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this;
685
+
686
+ deleteIn(keyPath: []): void;
687
+ deleteIn(keyPath: [K]): this;
688
+ deleteIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this;
689
+ deleteIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(keyPath: [K, K2, K3]): this;
690
+ deleteIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this;
691
+ deleteIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this;
692
+
693
+ removeIn(keyPath: []): void;
694
+ removeIn(keyPath: [K]): this;
695
+ removeIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this;
696
+ removeIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>(keyPath: [K, K2, K3]): this;
697
+ removeIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this;
698
+ removeIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this;
699
+
700
+ updateIn<U>(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U;
701
+ updateIn<U>(keyPath: [], updater: (value: this) => U): U;
702
+ updateIn<NSV>(keyPath: [K], notSetValue: NSV, updater: (value: V) => V): this;
703
+ updateIn(keyPath: [K], updater: (value: V) => V): this;
704
+ updateIn<NSV, K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<V, K2> | NSV) => S): this;
705
+ updateIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], updater: (value: $ValOf<V, K2>) => S): this;
706
+ updateIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, S: $ValOf<$ValOf<V, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<V, K2>, K3> | NSV) => S): this;
707
+ updateIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, S: $ValOf<$ValOf<V, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<V, K2>, K3>) => S): this;
708
+ updateIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV) => S): this;
709
+ updateIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>) => S): this;
710
+ updateIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV) => S): this;
711
+ updateIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>) => S): this;
407
712
  }
408
713
 
409
- declare class List<T> extends IndexedCollection<T> {
410
- static (iterable?: ESIterable<T>): List<T>;
714
+ declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List);
715
+ declare class List<+T> extends IndexedCollection<T> mixins UpdatableInCollection<number, T> {
716
+ static (collection?: Iterable<T>): List<T>;
411
717
 
412
- static isList(maybeList: any): boolean;
413
718
  static of<T>(...values: T[]): List<T>;
414
719
 
415
- set<U>(index: number, value: U): List<T|U>;
720
+ static isList: typeof isList;
721
+
722
+ size: number;
723
+
724
+ set<U>(index: number, value: U): List<T | U>;
416
725
  delete(index: number): this;
417
726
  remove(index: number): this;
418
- insert<U>(index: number, value: U): List<T|U>;
727
+ insert<U>(index: number, value: U): List<T | U>;
419
728
  clear(): this;
420
- push<U>(...values: U[]): List<T|U>;
729
+ push<U>(...values: U[]): List<T | U>;
421
730
  pop(): this;
422
- unshift<U>(...values: U[]): List<T|U>;
731
+ unshift<U>(...values: U[]): List<T | U>;
423
732
  shift(): this;
424
733
 
425
- update<U>(updater: (value: this) => List<U>): List<U>;
426
- update<U>(index: number, updater: (value: T) => U): List<T|U>;
427
- update<U>(index: number, notSetValue: U, updater: (value: T) => U): List<T|U>;
734
+ update<U>(updater: (value: this) => U): U;
735
+ update<U>(index: number, updater: (value: T) => U): List<T | U>;
736
+ update<U>(index: number, notSetValue: U, updater: (value: T) => U): List<T | U>;
428
737
 
429
- merge<U>(...iterables: ESIterable<U>[]): List<T|U>;
738
+ merge<U>(...collections: Iterable<U>[]): List<T | U>;
430
739
 
431
- mergeWith<U,V>(
432
- merger: (previous: T, next: U, key: number) => V,
433
- ...iterables: ESIterable<U>[]
434
- ): List<T|U|V>;
740
+ setSize(size: number): this;
435
741
 
436
- mergeDeep<U>(...iterables: ESIterable<U>[]): List<T|U>;
742
+ mergeIn(keyPath: Iterable<mixed>, ...collections: Iterable<mixed>[]): this;
743
+ mergeDeepIn(keyPath: Iterable<mixed>, ...collections: Iterable<mixed>[]): this;
437
744
 
438
- mergeDeepWith<U,V>(
439
- merger: (previous: T, next: U, key: number) => V,
440
- ...iterables: ESIterable<U>[]
441
- ): List<T|U|V>;
442
-
443
- setSize(size: number): List<?T>;
444
- setIn(keyPath: ESIterable<any>, value: any): List<T>;
445
- deleteIn(keyPath: ESIterable<any>, value: any): this;
446
- removeIn(keyPath: ESIterable<any>, value: any): this;
745
+ withMutations(mutator: (mutable: this) => mixed): this;
746
+ asMutable(): this;
747
+ wasAltered(): boolean;
748
+ asImmutable(): this;
447
749
 
448
- updateIn(keyPath: ESIterable<any>, notSetValue: any, value: any): List<T>;
449
- updateIn(keyPath: ESIterable<any>, value: any): List<T>;
750
+ // Override specialized return types
450
751
 
451
- mergeIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): List<T>;
452
- mergeDeepIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): List<T>;
752
+ concat<C>(...iters: Array<Iterable<C> | C>): List<T | C>;
453
753
 
454
- withMutations(mutator: (mutable: this) => any): this;
455
- asMutable(): this;
456
- asImmutable(): this;
754
+ filter(predicate: typeof Boolean): List<$NonMaybeType<T>>;
755
+ filter(
756
+ predicate: (value: T, index: number, iter: this) => mixed,
757
+ context?: mixed
758
+ ): List<T>;
457
759
 
458
- // Overrides that specialize return types
459
760
  map<M>(
460
761
  mapper: (value: T, index: number, iter: this) => M,
461
- context?: any
762
+ context?: mixed
462
763
  ): List<M>;
463
764
 
464
765
  flatMap<M>(
465
- mapper: (value: T, index: number, iter: this) => ESIterable<M>,
466
- context?: any
766
+ mapper: (value: T, index: number, iter: this) => Iterable<M>,
767
+ context?: mixed
467
768
  ): List<M>;
468
769
 
469
- flatten(depth?: number): /*this*/List<any>;
470
- flatten(shallow?: boolean): /*this*/List<any>;
770
+ flatten(depth?: number): List<any>;
771
+ flatten(shallow?: boolean): List<any>;
772
+
773
+ zip<A>(
774
+ a: Iterable<A>,
775
+ ..._: []
776
+ ): List<[T, A]>;
777
+ zip<A, B>(
778
+ a: Iterable<A>,
779
+ b: Iterable<B>,
780
+ ..._: []
781
+ ): List<[T, A, B]>;
782
+ zip<A, B, C>(
783
+ a: Iterable<A>,
784
+ b: Iterable<B>,
785
+ c: Iterable<C>,
786
+ ..._: []
787
+ ): List<[T, A, B, C]>;
788
+ zip<A, B, C, D>(
789
+ a: Iterable<A>,
790
+ b: Iterable<B>,
791
+ c: Iterable<C>,
792
+ d: Iterable<D>,
793
+ ..._: []
794
+ ): List<[T, A, B, C, D]>;
795
+ zip<A, B, C, D, E>(
796
+ a: Iterable<A>,
797
+ b: Iterable<B>,
798
+ c: Iterable<C>,
799
+ d: Iterable<D>,
800
+ e: Iterable<E>,
801
+ ..._: []
802
+ ): List<[T, A, B, C, D, E]>;
803
+
804
+ zipAll<A>(
805
+ a: Iterable<A>,
806
+ ..._: []
807
+ ): List<[T|void, A|void]>;
808
+ zipAll<A, B>(
809
+ a: Iterable<A>,
810
+ b: Iterable<B>,
811
+ ..._: []
812
+ ): List<[T|void, A|void, B|void]>;
813
+ zipAll<A, B, C>(
814
+ a: Iterable<A>,
815
+ b: Iterable<B>,
816
+ c: Iterable<C>,
817
+ ..._: []
818
+ ): List<[T|void, A|void, B|void, C|void]>;
819
+ zipAll<A, B, C, D>(
820
+ a: Iterable<A>,
821
+ b: Iterable<B>,
822
+ c: Iterable<C>,
823
+ d: Iterable<D>,
824
+ ..._: []
825
+ ): List<[T|void, A|void, B|void, C|void, D|void]>;
826
+ zipAll<A, B, C, D, E>(
827
+ a: Iterable<A>,
828
+ b: Iterable<B>,
829
+ c: Iterable<C>,
830
+ d: Iterable<D>,
831
+ e: Iterable<E>,
832
+ ..._: []
833
+ ): List<[T|void, A|void, B|void, C|void, D|void, E|void]>;
834
+
835
+ zipWith<A, R>(
836
+ zipper: (value: T, a: A) => R,
837
+ a: Iterable<A>,
838
+ ..._: []
839
+ ): List<R>;
840
+ zipWith<A, B, R>(
841
+ zipper: (value: T, a: A, b: B) => R,
842
+ a: Iterable<A>,
843
+ b: Iterable<B>,
844
+ ..._: []
845
+ ): List<R>;
846
+ zipWith<A, B, C, R>(
847
+ zipper: (value: T, a: A, b: B, c: C) => R,
848
+ a: Iterable<A>,
849
+ b: Iterable<B>,
850
+ c: Iterable<C>,
851
+ ..._: []
852
+ ): List<R>;
853
+ zipWith<A, B, C, D, R>(
854
+ zipper: (value: T, a: A, b: B, c: C, d: D) => R,
855
+ a: Iterable<A>,
856
+ b: Iterable<B>,
857
+ c: Iterable<C>,
858
+ d: Iterable<D>,
859
+ ..._: []
860
+ ): List<R>;
861
+ zipWith<A, B, C, D, E, R>(
862
+ zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
863
+ a: Iterable<A>,
864
+ b: Iterable<B>,
865
+ c: Iterable<C>,
866
+ d: Iterable<D>,
867
+ e: Iterable<E>,
868
+ ..._: []
869
+ ): List<R>;
471
870
  }
472
871
 
473
- declare class Map<K,V> extends KeyedCollection<K,V> {
474
- static <K, V>(): Map<K, V>;
475
- static <V>(obj?: {[key: string]: V}): Map<string, V>;
476
- static <K, V>(iterable?: ESIterable<[K,V]>): Map<K, V>;
872
+ declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map);
873
+ declare class Map<K, +V> extends KeyedCollection<K, V> mixins UpdatableInCollection<K, V> {
874
+ static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): Map<K, V>;
477
875
 
478
- static isMap(maybeMap: any): boolean;
876
+ static isMap: typeof isMap;
479
877
 
480
- set<K_, V_>(key: K_, value: V_): Map<K|K_, V|V_>;
878
+ size: number;
879
+
880
+ set<K_, V_>(key: K_, value: V_): Map<K | K_, V | V_>;
481
881
  delete(key: K): this;
482
882
  remove(key: K): this;
483
883
  clear(): this;
484
884
 
485
- update<K_,V_>(updater: (value: this) => Map<K_,V_>): Map<K_,V_>;
486
- update<V_>(key: K, updater: (value: V) => V_): Map<K,V|V_>;
487
- update<V_>(key: K, notSetValue: V_, updater: (value: V) => V_): Map<K,V|V_>;
885
+ deleteAll(keys: Iterable<K>): Map<K, V>;
886
+ removeAll(keys: Iterable<K>): Map<K, V>;
887
+
888
+ update<U>(updater: (value: this) => U): U;
889
+ update<V_>(key: K, updater: (value: V) => V_): Map<K, V | V_>;
890
+ update<V_>(key: K, notSetValue: V_, updater: (value: V) => V_): Map<K, V | V_>;
891
+
892
+ merge<K_, V_>(
893
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
894
+ ): Map<K | K_, V | V_>;
895
+ concat<K_, V_>(
896
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
897
+ ): Map<K | K_, V | V_>;
898
+
899
+ mergeWith<K_, W, X>(
900
+ merger: (oldVal: V, newVal: W, key: K) => X,
901
+ ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[]
902
+ ): Map<K | K_, V | W | X>;
903
+
904
+ mergeDeep<K_, V_>(
905
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
906
+ ): Map<K | K_, V | V_>;
907
+
908
+ mergeDeepWith<K_, V_>(
909
+ merger: (oldVal: any, newVal: any, key: any) => mixed,
910
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
911
+ ): Map<K | K_, V | V_>;
912
+
913
+ mergeIn(
914
+ keyPath: Iterable<mixed>,
915
+ ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
916
+ ): this;
917
+ mergeDeepIn(
918
+ keyPath: Iterable<mixed>,
919
+ ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
920
+ ): this;
488
921
 
489
- merge<K_,V_>(
490
- ...iterables: (ESIterable<[K_,V_]> | { [key: K_]: V_ })[]
491
- ): Map<K|K_,V|V_>;
922
+ withMutations(mutator: (mutable: this) => mixed): this;
923
+ asMutable(): this;
924
+ wasAltered(): boolean;
925
+ asImmutable(): this;
492
926
 
493
- mergeWith<K_,W,X>(
494
- merger: (previous: V, next: W, key: number) => X,
495
- ...iterables: ESIterable<W>[]
496
- ): Map<K,V|W|X>;
927
+ // Override specialized return types
497
928
 
498
- mergeDeep<K_,V_>(
499
- ...iterables: (ESIterable<[K_,V_]> | { [key: K_]: V_ })[]
500
- ): Map<K|K_,V|V_>;
929
+ flip(): Map<V, K>;
501
930
 
502
- mergeDeepWith<K_,W,X>(
503
- merger: (previous: V, next: W, key: number) => X,
504
- ...iterables: ESIterable<W>[]
505
- ): Map<K,V|W|X>;
931
+ filter(predicate: typeof Boolean): Map<K, $NonMaybeType<V>>;
932
+ filter(
933
+ predicate: (value: V, key: K, iter: this) => mixed,
934
+ context?: mixed
935
+ ): Map<K, V>;
506
936
 
507
- setIn(keyPath: ESIterable<any>, value: any): Map<K,V>;
508
- deleteIn(keyPath: ESIterable<any>, value: any): this;
509
- removeIn(keyPath: ESIterable<any>, value: any): this;
937
+ map<M>(
938
+ mapper: (value: V, key: K, iter: this) => M,
939
+ context?: mixed
940
+ ): Map<K, M>;
941
+
942
+ mapKeys<M>(
943
+ mapper: (key: K, value: V, iter: this) => M,
944
+ context?: mixed
945
+ ): Map<M, V>;
946
+
947
+ mapEntries<KM, VM>(
948
+ mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
949
+ context?: mixed
950
+ ): Map<KM, VM>;
951
+
952
+ flatMap<KM, VM>(
953
+ mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
954
+ context?: mixed
955
+ ): Map<KM, VM>;
956
+
957
+ flatten(depth?: number): Map<any, any>;
958
+ flatten(shallow?: boolean): Map<any, any>;
959
+ }
510
960
 
511
- updateIn(keyPath: ESIterable<any>, notSetValue: any, value: any): Map<K,V>;
512
- updateIn(keyPath: ESIterable<any>, value: any): Map<K,V>;
961
+ declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap);
962
+ declare class OrderedMap<K, +V> extends Map<K, V> mixins UpdatableInCollection<K, V> {
963
+ static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): OrderedMap<K, V>;
513
964
 
514
- mergeIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): Map<K,V>;
515
- mergeDeepIn(keyPath: ESIterable<any>, ...iterables: ESIterable<any>[]): Map<K,V>;
965
+ static isOrderedMap: typeof isOrderedMap;
516
966
 
517
- withMutations(mutator: (mutable: this) => any): this;
518
- asMutable(): this;
519
- asImmutable(): this;
967
+ size: number;
520
968
 
521
- // Overrides that specialize return types
969
+ set<K_, V_>(key: K_, value: V_): OrderedMap<K | K_, V | V_>;
970
+ delete(key: K): this;
971
+ remove(key: K): this;
972
+ clear(): this;
522
973
 
523
- map<V_>(
524
- mapper: (value: V, key: K, iter: this) => V_,
525
- context?: any
526
- ): Map<K,V_>;
974
+ update<U>(updater: (value: this) => U): U;
975
+ update<V_>(key: K, updater: (value: V) => V_): OrderedMap<K, V | V_>;
976
+ update<V_>(key: K, notSetValue: V_, updater: (value: V) => V_): OrderedMap<K, V | V_>;
977
+
978
+ merge<K_, V_>(
979
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
980
+ ): OrderedMap<K | K_, V | V_>;
981
+ concat<K_, V_>(
982
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
983
+ ): OrderedMap<K | K_, V | V_>;
984
+
985
+ mergeWith<K_, W, X>(
986
+ merger: (oldVal: V, newVal: W, key: K) => X,
987
+ ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[]
988
+ ): OrderedMap<K | K_, V | W | X>;
989
+
990
+ mergeDeep<K_, V_>(
991
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
992
+ ): OrderedMap<K | K_, V | V_>;
993
+
994
+ mergeDeepWith<K_, V_>(
995
+ merger: (oldVal: any, newVal: any, key: any) => mixed,
996
+ ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[]
997
+ ): OrderedMap<K | K_, V | V_>;
998
+
999
+ mergeIn(
1000
+ keyPath: Iterable<mixed>,
1001
+ ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
1002
+ ): this;
1003
+ mergeDeepIn(
1004
+ keyPath: Iterable<mixed>,
1005
+ ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[]
1006
+ ): this;
527
1007
 
528
- flatMap<K_,V_>(
529
- mapper: (value: V, key: K, iter: this) => ESIterable<[K_,V_]>,
530
- context?: any
531
- ): Map<K_,V_>;
1008
+ withMutations(mutator: (mutable: this) => mixed): this;
1009
+ asMutable(): this;
1010
+ wasAltered(): boolean;
1011
+ asImmutable(): this;
532
1012
 
533
- flip(): Map<V,K>;
1013
+ // Override specialized return types
534
1014
 
535
- mapKeys<K_>(
536
- mapper: (key: K, value: V, iter: this) => K_,
537
- context?: any
538
- ): Map<K_,V>;
1015
+ flip(): OrderedMap<V, K>;
539
1016
 
540
- flatten(depth?: number): /*this*/Map<any,any>;
541
- flatten(shallow?: boolean): /*this*/Map<any,any>;
542
- }
1017
+ filter(predicate: typeof Boolean): OrderedMap<K, $NonMaybeType<V>>;
1018
+ filter(
1019
+ predicate: (value: V, key: K, iter: this) => mixed,
1020
+ context?: mixed
1021
+ ): OrderedMap<K, V>;
543
1022
 
544
- // OrderedMaps have nothing that Maps do not have. We do not need to override constructor & other statics
545
- declare class OrderedMap<K,V> extends Map<K,V> {
546
- static isOrderedMap(maybeOrderedMap: any): bool;
1023
+ map<M>(
1024
+ mapper: (value: V, key: K, iter: this) => M,
1025
+ context?: mixed
1026
+ ): OrderedMap<K, M>;
1027
+
1028
+ mapKeys<M>(
1029
+ mapper: (key: K, value: V, iter: this) => M,
1030
+ context?: mixed
1031
+ ): OrderedMap<M, V>;
1032
+
1033
+ mapEntries<KM, VM>(
1034
+ mapper: (entry: [K, V], index: number, iter: this) => [KM, VM],
1035
+ context?: mixed
1036
+ ): OrderedMap<KM, VM>;
1037
+
1038
+ flatMap<KM, VM>(
1039
+ mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>,
1040
+ context?: mixed
1041
+ ): OrderedMap<KM, VM>;
1042
+
1043
+ flatten(depth?: number): OrderedMap<any, any>;
1044
+ flatten(shallow?: boolean): OrderedMap<any, any>;
547
1045
  }
548
1046
 
549
- declare class Set<T> extends SetCollection<T> {
550
- static <T>(iterable?: ESIterable<T>): Set<T>;
1047
+ declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof Set);
1048
+ declare class Set<+T> extends SetCollection<T> {
1049
+ static <T>(values?: Iterable<T>): Set<T>;
551
1050
 
552
- static isSet(maybeSet: any): boolean;
553
1051
  static of<T>(...values: T[]): Set<T>;
554
- static fromKeys<T>(iter: ESIterable<[T,any]>): Set<T>;
555
- static fromKeys(iter: { [key: string]: any }): Set<string>;
1052
+ static fromKeys<T>(values: Iterable<[T, mixed]> | PlainObjInput<T, mixed>): Set<T>;
556
1053
 
557
- add<U>(value: U): Set<T|U>;
1054
+ static intersect(sets: Iterable<Iterable<T>>): Set<T>;
1055
+ static union(sets: Iterable<Iterable<T>>): Set<T>;
1056
+
1057
+ static isSet: typeof isSet;
1058
+
1059
+ size: number;
1060
+
1061
+ add<U>(value: U): Set<T | U>;
558
1062
  delete(value: T): this;
559
1063
  remove(value: T): this;
560
1064
  clear(): this;
561
- union<U>(...iterables: ESIterable<U>[]): Set<T|U>;
562
- merge<U>(...iterables: ESIterable<U>[]): Set<T|U>;
563
- intersect<U>(...iterables: ESIterable<U>[]): Set<T&U>;
564
- subtract<U>(...iterables: ESIterable<U>[]): Set<T>;
1065
+ union<U>(...collections: Iterable<U>[]): Set<T | U>;
1066
+ merge<U>(...collections: Iterable<U>[]): Set<T | U>;
1067
+ concat<U>(...collections: Iterable<U>[]): Set<T | U>;
1068
+ intersect<U>(...collections: Iterable<U>[]): Set<T & U>;
1069
+ subtract(...collections: Iterable<mixed>[]): this;
565
1070
 
566
- withMutations(mutator: (mutable: this) => any): this;
1071
+ withMutations(mutator: (mutable: this) => mixed): this;
567
1072
  asMutable(): this;
1073
+ wasAltered(): boolean;
568
1074
  asImmutable(): this;
569
1075
 
570
- // Overrides that specialize return types
1076
+ // Override specialized return types
1077
+
1078
+ filter(predicate: typeof Boolean): Set<$NonMaybeType<T>>;
1079
+ filter(
1080
+ predicate: (value: T, value: T, iter: this) => mixed,
1081
+ context?: mixed
1082
+ ): Set<T>;
571
1083
 
572
1084
  map<M>(
573
1085
  mapper: (value: T, value: T, iter: this) => M,
574
- context?: any
1086
+ context?: mixed
575
1087
  ): Set<M>;
576
1088
 
577
1089
  flatMap<M>(
578
- mapper: (value: T, value: T, iter: this) => ESIterable<M>,
579
- context?: any
1090
+ mapper: (value: T, value: T, iter: this) => Iterable<M>,
1091
+ context?: mixed
580
1092
  ): Set<M>;
581
1093
 
582
- flatten(depth?: number): /*this*/Set<any>;
583
- flatten(shallow?: boolean): /*this*/Set<any>;
1094
+ flatten(depth?: number): Set<any>;
1095
+ flatten(shallow?: boolean): Set<any>;
584
1096
  }
585
1097
 
586
- // OrderedSets have nothing that Sets do not have. We do not need to override constructor & other statics
587
- declare class OrderedSet<T> extends Set<T> {
588
- static isOrderedSet(maybeOrderedSet: any): bool;
1098
+ // Overrides except for `isOrderedSet` are for specialized return types
1099
+ declare function isOrderedSet(maybeOrderedSet: mixed): boolean %checks(maybeOrderedSet instanceof OrderedSet);
1100
+ declare class OrderedSet<+T> extends Set<T> {
1101
+ static <T>(values?: Iterable<T>): OrderedSet<T>;
1102
+
1103
+ static of<T>(...values: T[]): OrderedSet<T>;
1104
+ static fromKeys<T>(values: Iterable<[T, mixed]> | PlainObjInput<T, mixed>): OrderedSet<T>;
1105
+
1106
+ static isOrderedSet: typeof isOrderedSet;
1107
+
1108
+ size: number;
1109
+
1110
+ add<U>(value: U): OrderedSet<T | U>;
1111
+ union<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
1112
+ merge<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
1113
+ concat<U>(...collections: Iterable<U>[]): OrderedSet<T | U>;
1114
+ intersect<U>(...collections: Iterable<U>[]): OrderedSet<T & U>;
1115
+
1116
+ filter(predicate: typeof Boolean): OrderedSet<$NonMaybeType<T>>;
1117
+ filter(
1118
+ predicate: (value: T, value: T, iter: this) => mixed,
1119
+ context?: mixed
1120
+ ): OrderedSet<T>;
1121
+
1122
+ map<M>(
1123
+ mapper: (value: T, value: T, iter: this) => M,
1124
+ context?: mixed
1125
+ ): OrderedSet<M>;
1126
+
1127
+ flatMap<M>(
1128
+ mapper: (value: T, value: T, iter: this) => Iterable<M>,
1129
+ context?: mixed
1130
+ ): OrderedSet<M>;
1131
+
1132
+ flatten(depth?: number): OrderedSet<any>;
1133
+ flatten(shallow?: boolean): OrderedSet<any>;
1134
+
1135
+ zip<A>(
1136
+ a: Iterable<A>,
1137
+ ..._: []
1138
+ ): OrderedSet<[T, A]>;
1139
+ zip<A, B>(
1140
+ a: Iterable<A>,
1141
+ b: Iterable<B>,
1142
+ ..._: []
1143
+ ): OrderedSet<[T, A, B]>;
1144
+ zip<A, B, C>(
1145
+ a: Iterable<A>,
1146
+ b: Iterable<B>,
1147
+ c: Iterable<C>,
1148
+ ..._: []
1149
+ ): OrderedSet<[T, A, B, C]>;
1150
+ zip<A, B, C, D>(
1151
+ a: Iterable<A>,
1152
+ b: Iterable<B>,
1153
+ c: Iterable<C>,
1154
+ d: Iterable<D>,
1155
+ ..._: []
1156
+ ): OrderedSet<[T, A, B, C, D]>;
1157
+ zip<A, B, C, D, E>(
1158
+ a: Iterable<A>,
1159
+ b: Iterable<B>,
1160
+ c: Iterable<C>,
1161
+ d: Iterable<D>,
1162
+ e: Iterable<E>,
1163
+ ..._: []
1164
+ ): OrderedSet<[T, A, B, C, D, E]>;
1165
+
1166
+ zipAll<A>(
1167
+ a: Iterable<A>,
1168
+ ..._: []
1169
+ ): OrderedSet<[T|void, A|void]>;
1170
+ zipAll<A, B>(
1171
+ a: Iterable<A>,
1172
+ b: Iterable<B>,
1173
+ ..._: []
1174
+ ): OrderedSet<[T|void, A|void, B|void]>;
1175
+ zipAll<A, B, C>(
1176
+ a: Iterable<A>,
1177
+ b: Iterable<B>,
1178
+ c: Iterable<C>,
1179
+ ..._: []
1180
+ ): OrderedSet<[T|void, A|void, B|void, C|void]>;
1181
+ zipAll<A, B, C, D>(
1182
+ a: Iterable<A>,
1183
+ b: Iterable<B>,
1184
+ c: Iterable<C>,
1185
+ d: Iterable<D>,
1186
+ ..._: []
1187
+ ): OrderedSet<[T|void, A|void, B|void, C|void, D|void]>;
1188
+ zipAll<A, B, C, D, E>(
1189
+ a: Iterable<A>,
1190
+ b: Iterable<B>,
1191
+ c: Iterable<C>,
1192
+ d: Iterable<D>,
1193
+ e: Iterable<E>,
1194
+ ..._: []
1195
+ ): OrderedSet<[T|void, A|void, B|void, C|void, D|void, E|void]>;
1196
+
1197
+ zipWith<A, R>(
1198
+ zipper: (value: T, a: A) => R,
1199
+ a: Iterable<A>,
1200
+ ..._: []
1201
+ ): OrderedSet<R>;
1202
+ zipWith<A, B, R>(
1203
+ zipper: (value: T, a: A, b: B) => R,
1204
+ a: Iterable<A>,
1205
+ b: Iterable<B>,
1206
+ ..._: []
1207
+ ): OrderedSet<R>;
1208
+ zipWith<A, B, C, R>(
1209
+ zipper: (value: T, a: A, b: B, c: C) => R,
1210
+ a: Iterable<A>,
1211
+ b: Iterable<B>,
1212
+ c: Iterable<C>,
1213
+ ..._: []
1214
+ ): OrderedSet<R>;
1215
+ zipWith<A, B, C, D, R>(
1216
+ zipper: (value: T, a: A, b: B, c: C, d: D) => R,
1217
+ a: Iterable<A>,
1218
+ b: Iterable<B>,
1219
+ c: Iterable<C>,
1220
+ d: Iterable<D>,
1221
+ ..._: []
1222
+ ): OrderedSet<R>;
1223
+ zipWith<A, B, C, D, E, R>(
1224
+ zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
1225
+ a: Iterable<A>,
1226
+ b: Iterable<B>,
1227
+ c: Iterable<C>,
1228
+ d: Iterable<D>,
1229
+ e: Iterable<E>,
1230
+ ..._: []
1231
+ ): OrderedSet<R>;
589
1232
  }
590
1233
 
591
- declare class Stack<T> extends IndexedCollection<T> {
592
- static <T>(iterable?: ESIterable<T>): Stack<T>;
1234
+ declare function isStack(maybeStack: mixed): boolean %checks(maybeStack instanceof Stack);
1235
+ declare class Stack<+T> extends IndexedCollection<T> {
1236
+ static <T>(collection?: Iterable<T>): Stack<T>;
593
1237
 
594
- static isStack(maybeStack: any): boolean;
1238
+ static isStack(maybeStack: mixed): boolean;
595
1239
  static of<T>(...values: T[]): Stack<T>;
596
1240
 
1241
+ static isStack: typeof isStack;
1242
+
1243
+ size: number;
1244
+
597
1245
  peek(): T;
598
1246
  clear(): this;
599
- unshift<U>(...values: U[]): Stack<T|U>;
600
- unshiftAll<U>(iter: ESIterable<U>): Stack<T|U>;
1247
+ unshift<U>(...values: U[]): Stack<T | U>;
1248
+ unshiftAll<U>(iter: Iterable<U>): Stack<T | U>;
601
1249
  shift(): this;
602
- push<U>(...values: U[]): Stack<T|U>;
603
- pushAll<U>(iter: ESIterable<U>): Stack<T|U>;
1250
+ push<U>(...values: U[]): Stack<T | U>;
1251
+ pushAll<U>(iter: Iterable<U>): Stack<T | U>;
604
1252
  pop(): this;
605
1253
 
606
- withMutations(mutator: (mutable: this) => any): this;
1254
+ withMutations(mutator: (mutable: this) => mixed): this;
607
1255
  asMutable(): this;
1256
+ wasAltered(): boolean;
608
1257
  asImmutable(): this;
609
1258
 
610
- // Overrides that specialize return types
1259
+ // Override specialized return types
1260
+
1261
+ concat<C>(...iters: Array<Iterable<C> | C>): Stack<T | C>;
1262
+
1263
+ filter(predicate: typeof Boolean): Stack<$NonMaybeType<T>>;
1264
+ filter(
1265
+ predicate: (value: T, index: number, iter: this) => mixed,
1266
+ context?: mixed
1267
+ ): Stack<T>;
1268
+
1269
+ map<M>(
1270
+ mapper: (value: T, index: number, iter: this) => M,
1271
+ context?: mixed
1272
+ ): Stack<M>;
611
1273
 
612
- map<U>(
613
- mapper: (value: T, index: number, iter: this) => U,
614
- context?: any
615
- ): Stack<U>;
1274
+ flatMap<M>(
1275
+ mapper: (value: T, index: number, iter: this) => Iterable<M>,
1276
+ context?: mixed
1277
+ ): Stack<M>;
616
1278
 
617
- flatMap<U>(
618
- mapper: (value: T, index: number, iter: this) => ESIterable<U>,
619
- context?: any
620
- ): Stack<U>;
1279
+ flatten(depth?: number): Stack<any>;
1280
+ flatten(shallow?: boolean): Stack<any>;
621
1281
 
622
- flatten(depth?: number): /*this*/Stack<any>;
623
- flatten(shallow?: boolean): /*this*/Stack<any>;
1282
+ zip<A>(
1283
+ a: Iterable<A>,
1284
+ ..._: []
1285
+ ): Stack<[T, A]>;
1286
+ zip<A, B>(
1287
+ a: Iterable<A>,
1288
+ b: Iterable<B>,
1289
+ ..._: []
1290
+ ): Stack<[T, A, B]>;
1291
+ zip<A, B, C>(
1292
+ a: Iterable<A>,
1293
+ b: Iterable<B>,
1294
+ c: Iterable<C>,
1295
+ ..._: []
1296
+ ): Stack<[T, A, B, C]>;
1297
+ zip<A, B, C, D>(
1298
+ a: Iterable<A>,
1299
+ b: Iterable<B>,
1300
+ c: Iterable<C>,
1301
+ d: Iterable<D>,
1302
+ ..._: []
1303
+ ): Stack<[T, A, B, C, D]>;
1304
+ zip<A, B, C, D, E>(
1305
+ a: Iterable<A>,
1306
+ b: Iterable<B>,
1307
+ c: Iterable<C>,
1308
+ d: Iterable<D>,
1309
+ e: Iterable<E>,
1310
+ ..._: []
1311
+ ): Stack<[T, A, B, C, D, E]>;
1312
+
1313
+ zipAll<A>(
1314
+ a: Iterable<A>,
1315
+ ..._: []
1316
+ ): Stack<[T|void, A|void]>;
1317
+ zipAll<A, B>(
1318
+ a: Iterable<A>,
1319
+ b: Iterable<B>,
1320
+ ..._: []
1321
+ ): Stack<[T|void, A|void, B|void]>;
1322
+ zipAll<A, B, C>(
1323
+ a: Iterable<A>,
1324
+ b: Iterable<B>,
1325
+ c: Iterable<C>,
1326
+ ..._: []
1327
+ ): Stack<[T|void, A|void, B|void, C|void]>;
1328
+ zipAll<A, B, C, D>(
1329
+ a: Iterable<A>,
1330
+ b: Iterable<B>,
1331
+ c: Iterable<C>,
1332
+ d: Iterable<D>,
1333
+ ..._: []
1334
+ ): Stack<[T|void, A|void, B|void, C|void, D|void]>;
1335
+ zipAll<A, B, C, D, E>(
1336
+ a: Iterable<A>,
1337
+ b: Iterable<B>,
1338
+ c: Iterable<C>,
1339
+ d: Iterable<D>,
1340
+ e: Iterable<E>,
1341
+ ..._: []
1342
+ ): Stack<[T|void, A|void, B|void, C|void, D|void, E|void]>;
1343
+
1344
+ zipWith<A, R>(
1345
+ zipper: (value: T, a: A) => R,
1346
+ a: Iterable<A>,
1347
+ ..._: []
1348
+ ): Stack<R>;
1349
+ zipWith<A, B, R>(
1350
+ zipper: (value: T, a: A, b: B) => R,
1351
+ a: Iterable<A>,
1352
+ b: Iterable<B>,
1353
+ ..._: []
1354
+ ): Stack<R>;
1355
+ zipWith<A, B, C, R>(
1356
+ zipper: (value: T, a: A, b: B, c: C) => R,
1357
+ a: Iterable<A>,
1358
+ b: Iterable<B>,
1359
+ c: Iterable<C>,
1360
+ ..._: []
1361
+ ): Stack<R>;
1362
+ zipWith<A, B, C, D, R>(
1363
+ zipper: (value: T, a: A, b: B, c: C, d: D) => R,
1364
+ a: Iterable<A>,
1365
+ b: Iterable<B>,
1366
+ c: Iterable<C>,
1367
+ d: Iterable<D>,
1368
+ ..._: []
1369
+ ): Stack<R>;
1370
+ zipWith<A, B, C, D, E, R>(
1371
+ zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R,
1372
+ a: Iterable<A>,
1373
+ b: Iterable<B>,
1374
+ c: Iterable<C>,
1375
+ d: Iterable<D>,
1376
+ e: Iterable<E>,
1377
+ ..._: []
1378
+ ): Stack<R>;
624
1379
  }
625
1380
 
626
1381
  declare function Range(start?: number, end?: number, step?: number): IndexedSeq<number>;
627
1382
  declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
628
1383
 
629
- //TODO: Once flow can extend normal Objects we can change this back to actually reflect Record behavior.
630
- // For now fallback to any to not break existing Code
631
- declare class Record<T: Object> {
632
- static <T: Object>(spec: T, name?: string): /*T & Record<T>*/any;
633
- get<A>(key: $Keys<T>): A;
634
- set<A>(key: $Keys<T>, value: A): /*T & Record<T>*/this;
635
- remove(key: $Keys<T>): /*T & Record<T>*/this;
1384
+ // The type of a Record factory function.
1385
+ type RecordFactory<Values: Object> = Class<RecordInstance<Values>>;
1386
+
1387
+ // The type of runtime Record instances.
1388
+ type RecordOf<Values: Object> = RecordInstance<Values> & $ReadOnly<Values>;
1389
+
1390
+ // The values of a Record instance.
1391
+ type _RecordValues<T, R: RecordInstance<T> | T> = R;
1392
+ type RecordValues<R> = _RecordValues<*, R>;
1393
+
1394
+ declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance);
1395
+ declare class Record {
1396
+ static <Values: Object>(spec: Values, name?: string): typeof RecordInstance;
1397
+ constructor<Values: Object>(spec: Values, name?: string): typeof RecordInstance;
1398
+
1399
+ static isRecord: typeof isRecord;
1400
+
1401
+ static getDescriptiveName(record: RecordInstance<any>): string;
636
1402
  }
637
1403
 
638
- declare function fromJS(json: any, reviver?: (k: any, v: Iterable<any,any>) => any): any;
639
- declare function is(first: any, second: any): boolean;
1404
+ declare class RecordInstance<T: Object = Object> {
1405
+ static (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): RecordOf<T>;
1406
+ // Note: a constructor can only create an instance of RecordInstance<T>,
1407
+ // it's encouraged to not use `new` when creating Records.
1408
+ constructor (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): void;
1409
+
1410
+ size: number;
1411
+
1412
+ has(key: string): boolean;
1413
+
1414
+ get<K: $Keys<T>>(key: K, ..._: []): $ElementType<T, K>;
1415
+ get<K: $Keys<T>, NSV>(key: K, notSetValue: NSV): $ElementType<T, K> | NSV;
1416
+
1417
+ hasIn(keyPath: Iterable<mixed>): boolean;
1418
+
1419
+ getIn(keyPath: [], notSetValue?: mixed): this & $ReadOnly<T>;
1420
+ getIn<K: $Keys<T>>(keyPath: [K], notSetValue?: mixed): $ElementType<T, K>;
1421
+ getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf<T, K>, K2> | NSV;
1422
+ getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV;
1423
+ getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV;
1424
+ getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV;
1425
+
1426
+ equals(other: any): boolean;
1427
+ hashCode(): number;
1428
+
1429
+ set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & $ReadOnly<T>;
1430
+ update<K: $Keys<T>>(key: K, updater: (value: $ElementType<T, K>) => $ElementType<T, K>): this & $ReadOnly<T>;
1431
+ merge(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & $ReadOnly<T>;
1432
+ mergeDeep(...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>): this & $ReadOnly<T>;
1433
+
1434
+ mergeWith(
1435
+ merger: (oldVal: $ValOf<T>, newVal: $ValOf<T>, key: $Keys<T>) => $ValOf<T>,
1436
+ ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
1437
+ ): this & $ReadOnly<T>;
1438
+ mergeDeepWith(
1439
+ merger: (oldVal: any, newVal: any, key: any) => any,
1440
+ ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>>
1441
+ ): this & $ReadOnly<T>;
1442
+
1443
+ delete<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
1444
+ remove<K: $Keys<T>>(key: K): this & $ReadOnly<T>;
1445
+ clear(): this & $ReadOnly<T>;
1446
+
1447
+ setIn<S>(keyPath: [], value: S): S;
1448
+ setIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], value: S): this & $ReadOnly<T>;
1449
+ setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], value: S): this & $ReadOnly<T>;
1450
+ setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & $ReadOnly<T>;
1451
+ setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & $ReadOnly<T>;
1452
+ setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & $ReadOnly<T>;
1453
+
1454
+ deleteIn(keyPath: []): void;
1455
+ deleteIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
1456
+ deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & $ReadOnly<T>;
1457
+ deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly<T>;
1458
+ deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly<T>;
1459
+ deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly<T>;
1460
+
1461
+ removeIn(keyPath: []): void;
1462
+ removeIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>;
1463
+ removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>(keyPath: [K, K2]): this & $ReadOnly<T>;
1464
+ removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly<T>;
1465
+ removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly<T>;
1466
+ removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly<T>;
1467
+
1468
+ updateIn<U>(keyPath: [], notSetValue: mixed, updater: (value: this & T) => U): U;
1469
+ updateIn<U>(keyPath: [], updater: (value: this & T) => U): U;
1470
+ updateIn<NSV, K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf<T, K>) => S): this & $ReadOnly<T>;
1471
+ updateIn<K: $Keys<T>, S: $ValOf<T, K>>(keyPath: [K], updater: (value: $ValOf<T, K>) => S): this & $ReadOnly<T>;
1472
+ updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf<T, K>, K2> | NSV) => S): this & $ReadOnly<T>;
1473
+ updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ValOf<T, K>, K2>) => S): this & $ReadOnly<T>;
1474
+ updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV) => S): this & $ReadOnly<T>;
1475
+ updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>) => S): this & $ReadOnly<T>;
1476
+ updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV) => S): this & $ReadOnly<T>;
1477
+ updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>) => S): this & $ReadOnly<T>;
1478
+ updateIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV) => S): this & $ReadOnly<T>;
1479
+ updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5>) => S): this & $ReadOnly<T>;
1480
+
1481
+ mergeIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & $ReadOnly<T>;
1482
+ mergeDeepIn(keyPath: Iterable<mixed>, ...collections: Array<any>): this & $ReadOnly<T>;
1483
+
1484
+ toSeq(): KeyedSeq<$Keys<T>, any>;
1485
+
1486
+ toJS(): { [key: $Keys<T>]: mixed };
1487
+ toJSON(): T;
1488
+ toObject(): T;
1489
+
1490
+ withMutations(mutator: (mutable: this & T) => mixed): this & $ReadOnly<T>;
1491
+ asMutable(): this & $ReadOnly<T>;
1492
+ wasAltered(): boolean;
1493
+ asImmutable(): this & $ReadOnly<T>;
1494
+
1495
+ @@iterator(): Iterator<[$Keys<T>, $ValOf<T>]>;
1496
+ }
1497
+
1498
+ declare function fromJS(
1499
+ jsValue: mixed,
1500
+ reviver?: (
1501
+ key: string | number,
1502
+ sequence: KeyedCollection<string, mixed> | IndexedCollection<mixed>,
1503
+ path?: Array<string | number>
1504
+ ) => mixed
1505
+ ): mixed;
1506
+
1507
+ declare function is(first: mixed, second: mixed): boolean;
1508
+ declare function hash(value: mixed): number;
1509
+
1510
+ declare function get<C: Object, K: $Keys<C>>(collection: C, key: K, notSetValue: mixed): $ValOf<C, K>;
1511
+ declare function get<C, K: $KeyOf<C>, NSV>(collection: C, key: K, notSetValue: NSV): $ValOf<C, K> | NSV;
1512
+
1513
+ declare function has(collection: Object, key: mixed): boolean;
1514
+ declare function remove<C>(collection: C, key: $KeyOf<C>): C;
1515
+ declare function set<C, K: $KeyOf<C>, V: $ValOf<C, K>>(collection: C, key: K, value: V): C;
1516
+ declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>, NSV>(collection: C, key: K, notSetValue: NSV, updater: ($ValOf<C, K> | NSV) => V): C;
1517
+ declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>>(collection: C, key: K, updater: ($ValOf<C, K>) => V): C;
1518
+
1519
+ declare function getIn<C>(collection: C, keyPath: [], notSetValue?: mixed): C;
1520
+ declare function getIn<C, K: $KeyOf<C>, NSV>(collection: C, keyPath: [K], notSetValue: NSV): $ValOf<C, K> | NSV;
1521
+ declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf<C, K>, K2> | NSV;
1522
+ declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV;
1523
+ declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV;
1524
+ declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV;
1525
+
1526
+ declare function hasIn(collection: Object, keyPath: Iterable<mixed>): boolean;
1527
+
1528
+ declare function removeIn<C>(collection: C, keyPath: []): void;
1529
+ declare function removeIn<C, K: $KeyOf<C>>(collection: C, keyPath: [K]): C;
1530
+ declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C>>>(collection: C, keyPath: [K, K2]): C;
1531
+ declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C>>, K3: $KeyOf<$ValOf<$ValOf<C>, K2>>>(collection: C, keyPath: [K, K2, K3]): C;
1532
+ declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C>>, K3: $KeyOf<$ValOf<$ValOf<C>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>>>(collection: C, keyPath: [K, K2, K3, K4]): C;
1533
+ declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C>>, K3: $KeyOf<$ValOf<$ValOf<C>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C>, K2>, K3>, K4>>>(collection: C, keyPath: [K, K2, K3, K4, K5]): C;
1534
+
1535
+ declare function setIn<S>(collection: Object, keyPath: [], value: S): S;
1536
+ declare function setIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>(collection: C, keyPath: [K], value: S): C;
1537
+ declare function setIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, S: $ValOf<$ValOf<C, K>, K2>>(collection: C, keyPath: [K, K2], value: S): C;
1538
+ declare function setIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>(collection: C, keyPath: [K, K2, K3], value: S): C;
1539
+ declare function setIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], value: S): C;
1540
+ declare function setIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], value: S): C;
1541
+
1542
+ declare function updateIn<C, S>(collection: C, keyPath: [], notSetValue: mixed, updater: (value: C) => S): S;
1543
+ declare function updateIn<C, S>(collection: C, keyPath: [], updater: (value: C) => S): S;
1544
+ declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>, NSV>(collection: C, keyPath: [K], notSetValue: NSV, updater: (value: $ValOf<C, K> | NSV) => S): C;
1545
+ declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>(collection: C, keyPath: [K], updater: (value: $ValOf<C, K>) => S): C;
1546
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, S: $ValOf<$ValOf<C, K>, K2>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf<C, K>, K2> | NSV) => S): C;
1547
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, S: $ValOf<$ValOf<C, K>, K2>>(collection: C, keyPath: [K, K2], updater: (value: $ValOf<$ValOf<C, K>, K2>) => S): C;
1548
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV) => S): C;
1549
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>(collection: C, keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>) => S): C;
1550
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV) => S): C;
1551
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>) => S): C;
1552
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV) => S): C;
1553
+ declare function updateIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>) => S): C;
1554
+
1555
+ declare function merge<C>(
1556
+ collection: C,
1557
+ ...collections: Array<$IterableOf<C> | $Shape<RecordValues<C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1558
+ ): C;
1559
+ declare function mergeWith<C>(
1560
+ merger: (oldVal: $ValOf<C>, newVal: $ValOf<C>, key: $KeyOf<C>) => $ValOf<C>,
1561
+ collection: C,
1562
+ ...collections: Array<$IterableOf<C> | $Shape<RecordValues<C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1563
+ ): C;
1564
+ declare function mergeDeep<C>(
1565
+ collection: C,
1566
+ ...collections: Array<$IterableOf<C> | $Shape<RecordValues<C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1567
+ ): C;
1568
+ declare function mergeDeepWith<C>(
1569
+ merger: (oldVal: any, newVal: any, key: any) => mixed,
1570
+ collection: C,
1571
+ ...collections: Array<$IterableOf<C> | $Shape<RecordValues<C>> | PlainObjInput<$KeyOf<C>, $ValOf<C>>>
1572
+ ): C;
640
1573
 
641
1574
  export {
642
- Iterable,
643
1575
  Collection,
644
1576
  Seq,
645
1577
 
646
- // These classes do not actually exist under these names. But it is useful to
647
- // have the types available.
648
- KeyedIterable,
649
- IndexedIterable,
650
- SetIterable,
651
- KeyedCollection,
652
- IndexedCollection,
653
- SetCollection,
654
- KeyedSeq,
655
- IndexedSeq,
656
- SetSeq,
1578
+ List,
1579
+ Map,
1580
+ OrderedMap,
1581
+ OrderedSet,
1582
+ Range,
1583
+ Repeat,
1584
+ Record,
1585
+ Set,
1586
+ Stack,
1587
+
1588
+ fromJS,
1589
+ is,
1590
+ hash,
1591
+
1592
+ isImmutable,
1593
+ isCollection,
1594
+ isKeyed,
1595
+ isIndexed,
1596
+ isAssociative,
1597
+ isOrdered,
1598
+ isRecord,
1599
+ isValueObject,
1600
+
1601
+ get,
1602
+ has,
1603
+ remove,
1604
+ set,
1605
+ update,
1606
+ getIn,
1607
+ hasIn,
1608
+ removeIn,
1609
+ setIn,
1610
+ updateIn,
1611
+ merge,
1612
+ mergeWith,
1613
+ mergeDeep,
1614
+ mergeDeepWith,
1615
+ }
1616
+
1617
+ export default {
1618
+ Collection,
1619
+ Seq,
657
1620
 
658
1621
  List,
659
1622
  Map,
@@ -667,4 +1630,45 @@ export {
667
1630
 
668
1631
  fromJS,
669
1632
  is,
1633
+ hash,
1634
+
1635
+ isImmutable,
1636
+ isCollection,
1637
+ isKeyed,
1638
+ isIndexed,
1639
+ isAssociative,
1640
+ isOrdered,
1641
+ isRecord,
1642
+ isValueObject,
1643
+
1644
+ get,
1645
+ has,
1646
+ remove,
1647
+ set,
1648
+ update,
1649
+ getIn,
1650
+ hasIn,
1651
+ removeIn,
1652
+ setIn,
1653
+ updateIn,
1654
+ merge,
1655
+ mergeWith,
1656
+ mergeDeep,
1657
+ mergeDeepWith,
1658
+ }
1659
+
1660
+ export type {
1661
+ KeyedCollection,
1662
+ IndexedCollection,
1663
+ SetCollection,
1664
+ KeyedSeq,
1665
+ IndexedSeq,
1666
+ SetSeq,
1667
+ RecordFactory,
1668
+ RecordOf,
1669
+ RecordInstance,
1670
+ ValueObject,
1671
+
1672
+ $KeyOf,
1673
+ $ValOf,
670
1674
  }