immutable.js.flow (62767B)
1 /** 2 * This file provides type definitions for use with the Flow type checker. 3 * 4 * An important caveat when using these definitions is that the types for 5 * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs. 6 * When referring to those types, you can get the proper definitions by 7 * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc. 8 * For example, 9 * 10 * import { Seq } from 'immutable' 11 * import type { IndexedCollection, IndexedSeq } from 'immutable' 12 * 13 * const someSeq: IndexedSeq<number> = Seq.Indexed.of(1, 2, 3) 14 * 15 * function takesASeq<T, TS: IndexedCollection<T>>(iter: TS): TS { 16 * return iter.butLast() 17 * } 18 * 19 * takesASeq(someSeq) 20 * 21 * @flow strict 22 */ 23 24 // Helper type that represents plain objects allowed as arguments to 25 // some constructors and functions. 26 type PlainObjInput<K, V> = { +[key: K]: V, __proto__: null }; 27 28 type K<T> = $Keys<T>; 29 30 // Helper types to extract the "keys" and "values" use by the *In() methods. 31 type $KeyOf<C> = $Call< 32 (<K>(?_Collection<K, mixed>) => K) & 33 (<T>(?$ReadOnlyArray<T>) => number) & 34 (<T>(?RecordInstance<T> | T) => $Keys<T>) & 35 (<T: Object>(T) => $Keys<T>), 36 C 37 >; 38 39 type $ValOf<C, K = $KeyOf<C>> = $Call< 40 (<V>(?_Collection<any, V>) => V) & 41 (<T>(?$ReadOnlyArray<T>) => T) & 42 (<T, K: $Keys<T>>(?RecordInstance<T> | T, K) => $ElementType<T, K>) & 43 (<T: Object>(T) => $Values<T>), 44 C, 45 K 46 >; 47 48 type $IterableOf<C> = $Call< 49 (<V: Array<any> | IndexedCollection<any> | SetCollection<any>>( 50 V 51 ) => Iterable<$ValOf<V>>) & 52 (< 53 V: 54 | KeyedCollection<any, any> 55 | RecordInstance<any> 56 | PlainObjInput<any, any> 57 >( 58 V 59 ) => Iterable<[$KeyOf<V>, $ValOf<V>]>), 60 C 61 >; 62 63 const PairSorting: $ReadOnly<{ LeftThenRight: number, RightThenLeft: number }> = 64 { 65 LeftThenRight: -1, 66 RightThenLeft: +1, 67 }; 68 69 type Comparator<T> = (left: T, right: T) => number; 70 71 declare class _Collection<K, +V> implements ValueObject { 72 equals(other: mixed): boolean; 73 hashCode(): number; 74 get(key: K, ..._: []): V | void; 75 get<NSV>(key: K, notSetValue: NSV): V | NSV; 76 has(key: K): boolean; 77 includes(value: V): boolean; 78 contains(value: V): boolean; 79 first<NSV>(notSetValue?: NSV): V | NSV; 80 last<NSV>(notSetValue?: NSV): V | NSV; 81 82 hasIn(keyPath: Iterable<mixed>): boolean; 83 84 getIn(keyPath: [], notSetValue?: mixed): this; 85 getIn<NSV>(keyPath: [K], notSetValue: NSV): V | NSV; 86 getIn<NSV, K2: $KeyOf<V>>( 87 keyPath: [K, K2], 88 notSetValue: NSV 89 ): $ValOf<V, K2> | NSV; 90 getIn<NSV, K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>( 91 keyPath: [K, K2, K3], 92 notSetValue: NSV 93 ): $ValOf<$ValOf<V, K2>, K3> | NSV; 94 getIn< 95 NSV, 96 K2: $KeyOf<V>, 97 K3: $KeyOf<$ValOf<V, K2>>, 98 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>> 99 >( 100 keyPath: [K, K2, K3, K4], 101 notSetValue: NSV 102 ): $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV; 103 getIn< 104 NSV, 105 K2: $KeyOf<V>, 106 K3: $KeyOf<$ValOf<V, K2>>, 107 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 108 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>> 109 >( 110 keyPath: [K, K2, K3, K4, K5], 111 notSetValue: NSV 112 ): $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV; 113 114 update<U>(updater: (value: this) => U): U; 115 116 toJS(): Array<any> | { [key: string]: mixed }; 117 toJSON(): Array<V> | { [key: string]: V }; 118 toArray(): Array<V> | Array<[K, V]>; 119 toObject(): { [key: string]: V }; 120 toMap(): Map<K, V>; 121 toOrderedMap(): OrderedMap<K, V>; 122 toSet(): Set<V>; 123 toOrderedSet(): OrderedSet<V>; 124 toList(): List<V>; 125 toStack(): Stack<V>; 126 toSeq(): Seq<K, V>; 127 toKeyedSeq(): KeyedSeq<K, V>; 128 toIndexedSeq(): IndexedSeq<V>; 129 toSetSeq(): SetSeq<V>; 130 131 keys(): Iterator<K>; 132 values(): Iterator<V>; 133 entries(): Iterator<[K, V]>; 134 135 keySeq(): IndexedSeq<K>; 136 valueSeq(): IndexedSeq<V>; 137 entrySeq(): IndexedSeq<[K, V]>; 138 139 reverse(): this; 140 sort(comparator?: Comparator<V>): this; 141 142 sortBy<C>( 143 comparatorValueMapper: (value: V, key: K, iter: this) => C, 144 comparator?: Comparator<C> 145 ): this; 146 147 groupBy<G>( 148 grouper: (value: V, key: K, iter: this) => G, 149 context?: mixed 150 ): KeyedSeq<G, this>; 151 152 forEach( 153 sideEffect: (value: V, key: K, iter: this) => any, 154 context?: mixed 155 ): number; 156 157 slice(begin?: number, end?: number): this; 158 rest(): this; 159 butLast(): this; 160 skip(amount: number): this; 161 skipLast(amount: number): this; 162 skipWhile( 163 predicate: (value: V, key: K, iter: this) => mixed, 164 context?: mixed 165 ): this; 166 skipUntil( 167 predicate: (value: V, key: K, iter: this) => mixed, 168 context?: mixed 169 ): this; 170 take(amount: number): this; 171 takeLast(amount: number): this; 172 takeWhile( 173 predicate: (value: V, key: K, iter: this) => mixed, 174 context?: mixed 175 ): this; 176 takeUntil( 177 predicate: (value: V, key: K, iter: this) => mixed, 178 context?: mixed 179 ): this; 180 181 filterNot( 182 predicate: (value: V, key: K, iter: this) => mixed, 183 context?: mixed 184 ): this; 185 186 reduce<R>( 187 reducer: (reduction: R, value: V, key: K, iter: this) => R, 188 initialReduction: R, 189 context?: mixed 190 ): R; 191 reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; 192 193 reduceRight<R>( 194 reducer: (reduction: R, value: V, key: K, iter: this) => R, 195 initialReduction: R, 196 context?: mixed 197 ): R; 198 reduceRight<R>( 199 reducer: (reduction: V | R, value: V, key: K, iter: this) => R 200 ): R; 201 202 every( 203 predicate: (value: V, key: K, iter: this) => mixed, 204 context?: mixed 205 ): boolean; 206 some( 207 predicate: (value: V, key: K, iter: this) => mixed, 208 context?: mixed 209 ): boolean; 210 join(separator?: string): string; 211 isEmpty(): boolean; 212 count( 213 predicate?: (value: V, key: K, iter: this) => mixed, 214 context?: mixed 215 ): number; 216 countBy<G>( 217 grouper: (value: V, key: K, iter: this) => G, 218 context?: mixed 219 ): Map<G, number>; 220 221 find<NSV>( 222 predicate: (value: V, key: K, iter: this) => mixed, 223 context?: mixed, 224 notSetValue?: NSV 225 ): V | NSV; 226 findLast<NSV>( 227 predicate: (value: V, key: K, iter: this) => mixed, 228 context?: mixed, 229 notSetValue?: NSV 230 ): V | NSV; 231 232 findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; 233 findLastEntry( 234 predicate: (value: V, key: K, iter: this) => mixed 235 ): [K, V] | void; 236 237 findKey( 238 predicate: (value: V, key: K, iter: this) => mixed, 239 context?: mixed 240 ): K | void; 241 findLastKey( 242 predicate: (value: V, key: K, iter: this) => mixed, 243 context?: mixed 244 ): K | void; 245 246 keyOf(searchValue: V): K | void; 247 lastKeyOf(searchValue: V): K | void; 248 249 max(comparator?: Comparator<V>): V; 250 maxBy<C>( 251 comparatorValueMapper: (value: V, key: K, iter: this) => C, 252 comparator?: Comparator<C> 253 ): V; 254 min(comparator?: Comparator<V>): V; 255 minBy<C>( 256 comparatorValueMapper: (value: V, key: K, iter: this) => C, 257 comparator?: Comparator<C> 258 ): V; 259 260 isSubset(iter: Iterable<V>): boolean; 261 isSuperset(iter: Iterable<V>): boolean; 262 } 263 264 declare function isImmutable( 265 maybeImmutable: mixed 266 ): boolean %checks(maybeImmutable instanceof Collection); 267 declare function isCollection( 268 maybeCollection: mixed 269 ): boolean %checks(maybeCollection instanceof Collection); 270 declare function isKeyed( 271 maybeKeyed: mixed 272 ): boolean %checks(maybeKeyed instanceof KeyedCollection); 273 declare function isIndexed( 274 maybeIndexed: mixed 275 ): boolean %checks(maybeIndexed instanceof IndexedCollection); 276 declare function isAssociative( 277 maybeAssociative: mixed 278 ): boolean %checks(maybeAssociative instanceof KeyedCollection || 279 maybeAssociative instanceof IndexedCollection); 280 declare function isOrdered( 281 maybeOrdered: mixed 282 ): boolean %checks(maybeOrdered instanceof IndexedCollection || 283 maybeOrdered instanceof OrderedMap || 284 maybeOrdered instanceof OrderedSet); 285 declare function isValueObject(maybeValue: mixed): boolean; 286 287 declare function isSeq(maybeSeq: any): boolean %checks(maybeSeq instanceof Seq); 288 declare function isList(maybeList: any): boolean %checks(maybeList instanceof 289 List); 290 declare function isMap(maybeMap: any): boolean %checks(maybeMap instanceof Map); 291 declare function isOrderedMap( 292 maybeOrderedMap: any 293 ): boolean %checks(maybeOrderedMap instanceof OrderedMap); 294 declare function isStack(maybeStack: any): boolean %checks(maybeStack instanceof 295 Stack); 296 declare function isSet(maybeSet: any): boolean %checks(maybeSet instanceof Set); 297 declare function isOrderedSet( 298 maybeOrderedSet: any 299 ): boolean %checks(maybeOrderedSet instanceof OrderedSet); 300 declare function isRecord( 301 maybeRecord: any 302 ): boolean %checks(maybeRecord instanceof Record); 303 304 declare interface ValueObject { 305 equals(other: mixed): boolean; 306 hashCode(): number; 307 } 308 309 declare class Collection<K, +V> extends _Collection<K, V> { 310 static Keyed: typeof KeyedCollection; 311 static Indexed: typeof IndexedCollection; 312 static Set: typeof SetCollection; 313 314 static isCollection: typeof isCollection; 315 static isKeyed: typeof isKeyed; 316 static isIndexed: typeof isIndexed; 317 static isAssociative: typeof isAssociative; 318 static isOrdered: typeof isOrdered; 319 } 320 321 declare class KeyedCollection<K, +V> extends Collection<K, V> { 322 static <K, V>( 323 values?: Iterable<[K, V]> | PlainObjInput<K, V> 324 ): KeyedCollection<K, V>; 325 326 toJS(): { [key: string]: mixed }; 327 toJSON(): { [key: string]: V }; 328 toArray(): Array<[K, V]>; 329 @@iterator(): Iterator<[K, V]>; 330 toSeq(): KeyedSeq<K, V>; 331 flip(): KeyedCollection<V, K>; 332 333 concat<KC, VC>( 334 ...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>> 335 ): KeyedCollection<K | KC, V | VC>; 336 337 filter(predicate: typeof Boolean): KeyedCollection<K, $NonMaybeType<V>>; 338 filter( 339 predicate: (value: V, key: K, iter: this) => mixed, 340 context?: mixed 341 ): KeyedCollection<K, V>; 342 343 partition( 344 predicate: (value: V, key: K, iter: this) => mixed, 345 context?: mixed 346 ): [this, this]; 347 348 map<M>( 349 mapper: (value: V, key: K, iter: this) => M, 350 context?: mixed 351 ): KeyedCollection<K, M>; 352 353 mapKeys<M>( 354 mapper: (key: K, value: V, iter: this) => M, 355 context?: mixed 356 ): KeyedCollection<M, V>; 357 358 mapEntries<KM, VM>( 359 mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], 360 context?: mixed 361 ): KeyedCollection<KM, VM>; 362 363 flatMap<KM, VM>( 364 mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, 365 context?: mixed 366 ): KeyedCollection<KM, VM>; 367 368 flatten(depth?: number): KeyedCollection<any, any>; 369 flatten(shallow?: boolean): KeyedCollection<any, any>; 370 } 371 372 Collection.Keyed = KeyedCollection; 373 374 declare class IndexedCollection<+T> extends Collection<number, T> { 375 static <T>(iter?: Iterable<T>): IndexedCollection<T>; 376 377 toJS(): Array<mixed>; 378 toJSON(): Array<T>; 379 toArray(): Array<T>; 380 @@iterator(): Iterator<T>; 381 toSeq(): IndexedSeq<T>; 382 fromEntrySeq<K, V>(): KeyedSeq<K, V>; 383 interpose(separator: T): this; 384 interleave(...collections: Iterable<T>[]): this; 385 splice(index: number, removeNum: number, ...values: T[]): this; 386 387 zip<A>(a: Iterable<A>, ..._: []): IndexedCollection<[T, A]>; 388 zip<A, B>( 389 a: Iterable<A>, 390 b: Iterable<B>, 391 ..._: [] 392 ): IndexedCollection<[T, A, B]>; 393 zip<A, B, C>( 394 a: Iterable<A>, 395 b: Iterable<B>, 396 c: Iterable<C>, 397 ..._: [] 398 ): IndexedCollection<[T, A, B, C]>; 399 zip<A, B, C, D>( 400 a: Iterable<A>, 401 b: Iterable<B>, 402 c: Iterable<C>, 403 d: Iterable<D>, 404 ..._: [] 405 ): IndexedCollection<[T, A, B, C, D]>; 406 zip<A, B, C, D, E>( 407 a: Iterable<A>, 408 b: Iterable<B>, 409 c: Iterable<C>, 410 d: Iterable<D>, 411 e: Iterable<E>, 412 ..._: [] 413 ): IndexedCollection<[T, A, B, C, D, E]>; 414 415 zipAll<A>(a: Iterable<A>, ..._: []): IndexedCollection<[T | void, A | void]>; 416 zipAll<A, B>( 417 a: Iterable<A>, 418 b: Iterable<B>, 419 ..._: [] 420 ): IndexedCollection<[T | void, A | void, B | void]>; 421 zipAll<A, B, C>( 422 a: Iterable<A>, 423 b: Iterable<B>, 424 c: Iterable<C>, 425 ..._: [] 426 ): IndexedCollection<[T | void, A | void, B | void, C | void]>; 427 zipAll<A, B, C, D>( 428 a: Iterable<A>, 429 b: Iterable<B>, 430 c: Iterable<C>, 431 d: Iterable<D>, 432 ..._: [] 433 ): IndexedCollection<[T | void, A | void, B | void, C | void, D | void]>; 434 zipAll<A, B, C, D, E>( 435 a: Iterable<A>, 436 b: Iterable<B>, 437 c: Iterable<C>, 438 d: Iterable<D>, 439 e: Iterable<E>, 440 ..._: [] 441 ): IndexedCollection< 442 [T | void, A | void, B | void, C | void, D | void, E | void] 443 >; 444 445 zipWith<A, R>( 446 zipper: (value: T, a: A) => R, 447 a: Iterable<A>, 448 ..._: [] 449 ): IndexedCollection<R>; 450 zipWith<A, B, R>( 451 zipper: (value: T, a: A, b: B) => R, 452 a: Iterable<A>, 453 b: Iterable<B>, 454 ..._: [] 455 ): IndexedCollection<R>; 456 zipWith<A, B, C, R>( 457 zipper: (value: T, a: A, b: B, c: C) => R, 458 a: Iterable<A>, 459 b: Iterable<B>, 460 c: Iterable<C>, 461 ..._: [] 462 ): IndexedCollection<R>; 463 zipWith<A, B, C, D, R>( 464 zipper: (value: T, a: A, b: B, c: C, d: D) => R, 465 a: Iterable<A>, 466 b: Iterable<B>, 467 c: Iterable<C>, 468 d: Iterable<D>, 469 ..._: [] 470 ): IndexedCollection<R>; 471 zipWith<A, B, C, D, E, R>( 472 zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, 473 a: Iterable<A>, 474 b: Iterable<B>, 475 c: Iterable<C>, 476 d: Iterable<D>, 477 e: Iterable<E>, 478 ..._: [] 479 ): IndexedCollection<R>; 480 481 indexOf(searchValue: T): number; 482 lastIndexOf(searchValue: T): number; 483 findIndex( 484 predicate: (value: T, index: number, iter: this) => mixed, 485 context?: mixed 486 ): number; 487 findLastIndex( 488 predicate: (value: T, index: number, iter: this) => mixed, 489 context?: mixed 490 ): number; 491 492 concat<C>(...iters: Array<Iterable<C> | C>): IndexedCollection<T | C>; 493 494 filter(predicate: typeof Boolean): IndexedCollection<$NonMaybeType<T>>; 495 filter( 496 predicate: (value: T, index: number, iter: this) => mixed, 497 context?: mixed 498 ): IndexedCollection<T>; 499 500 partition( 501 predicate: (value: T, index: number, iter: this) => mixed, 502 context?: mixed 503 ): [this, this]; 504 505 map<M>( 506 mapper: (value: T, index: number, iter: this) => M, 507 context?: mixed 508 ): IndexedCollection<M>; 509 510 flatMap<M>( 511 mapper: (value: T, index: number, iter: this) => Iterable<M>, 512 context?: mixed 513 ): IndexedCollection<M>; 514 515 flatten(depth?: number): IndexedCollection<any>; 516 flatten(shallow?: boolean): IndexedCollection<any>; 517 } 518 519 declare class SetCollection<+T> extends Collection<T, T> { 520 static <T>(iter?: Iterable<T>): SetCollection<T>; 521 522 toJS(): Array<mixed>; 523 toJSON(): Array<T>; 524 toArray(): Array<T>; 525 @@iterator(): Iterator<T>; 526 toSeq(): SetSeq<T>; 527 528 concat<U>(...collections: Iterable<U>[]): SetCollection<T | U>; 529 530 // `filter`, `map` and `flatMap` cannot be defined further up the hierarchy, 531 // because the implementation for `KeyedCollection` allows the value type to 532 // change without constraining the key type. That does not work for 533 // `SetCollection` - the value and key types *must* match. 534 filter(predicate: typeof Boolean): SetCollection<$NonMaybeType<T>>; 535 filter( 536 predicate: (value: T, value: T, iter: this) => mixed, 537 context?: mixed 538 ): SetCollection<T>; 539 540 partition( 541 predicate: (value: T, value: T, iter: this) => mixed, 542 context?: mixed 543 ): [this, this]; 544 545 map<M>( 546 mapper: (value: T, value: T, iter: this) => M, 547 context?: mixed 548 ): SetCollection<M>; 549 550 flatMap<M>( 551 mapper: (value: T, value: T, iter: this) => Iterable<M>, 552 context?: mixed 553 ): SetCollection<M>; 554 555 flatten(depth?: number): SetCollection<any>; 556 flatten(shallow?: boolean): SetCollection<any>; 557 } 558 559 declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof 560 Seq); 561 declare class Seq<K, +V> extends _Collection<K, V> { 562 static Keyed: typeof KeyedSeq; 563 static Indexed: typeof IndexedSeq; 564 static Set: typeof SetSeq; 565 566 static <K, V>(values: KeyedSeq<K, V>): KeyedSeq<K, V>; 567 static <T>(values: SetSeq<T>): SetSeq<K, V>; 568 static <T>(values: Iterable<T>): IndexedSeq<T>; 569 static <K, V>(values?: PlainObjInput<K, V>): KeyedSeq<K, V>; 570 571 static isSeq: typeof isSeq; 572 573 size: number | void; 574 cacheResult(): this; 575 toSeq(): this; 576 } 577 578 declare class KeyedSeq<K, +V> extends Seq<K, V> mixins KeyedCollection<K, V> { 579 static <K, V>( 580 values?: Iterable<[K, V]> | PlainObjInput<K, V> 581 ): KeyedSeq<K, V>; 582 583 // Override specialized return types 584 flip(): KeyedSeq<V, K>; 585 586 concat<KC, VC>( 587 ...iters: Array<Iterable<[KC, VC]> | PlainObjInput<KC, VC>> 588 ): KeyedSeq<K | KC, V | VC>; 589 590 filter(predicate: typeof Boolean): KeyedSeq<K, $NonMaybeType<V>>; 591 filter( 592 predicate: (value: V, key: K, iter: this) => mixed, 593 context?: mixed 594 ): KeyedSeq<K, V>; 595 596 partition( 597 predicate: (value: V, key: K, iter: this) => mixed, 598 context?: mixed 599 ): [this, this]; 600 601 map<M>( 602 mapper: (value: V, key: K, iter: this) => M, 603 context?: mixed 604 ): KeyedSeq<K, M>; 605 606 mapKeys<M>( 607 mapper: (key: K, value: V, iter: this) => M, 608 context?: mixed 609 ): KeyedSeq<M, V>; 610 611 mapEntries<KM, VM>( 612 mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], 613 context?: mixed 614 ): KeyedSeq<KM, VM>; 615 616 flatMap<KM, VM>( 617 mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, 618 context?: mixed 619 ): KeyedSeq<KM, VM>; 620 621 flatten(depth?: number): KeyedSeq<any, any>; 622 flatten(shallow?: boolean): KeyedSeq<any, any>; 623 } 624 625 declare class IndexedSeq<+T> 626 extends Seq<number, T> 627 mixins IndexedCollection<T> 628 { 629 static <T>(values?: Iterable<T>): IndexedSeq<T>; 630 631 static of<T>(...values: T[]): IndexedSeq<T>; 632 633 // Override specialized return types 634 635 concat<C>(...iters: Array<Iterable<C> | C>): IndexedSeq<T | C>; 636 637 filter(predicate: typeof Boolean): IndexedSeq<$NonMaybeType<T>>; 638 filter( 639 predicate: (value: T, index: number, iter: this) => mixed, 640 context?: mixed 641 ): IndexedSeq<T>; 642 643 partition( 644 predicate: (value: T, index: number, iter: this) => mixed, 645 context?: mixed 646 ): [this, this]; 647 648 map<M>( 649 mapper: (value: T, index: number, iter: this) => M, 650 context?: mixed 651 ): IndexedSeq<M>; 652 653 flatMap<M>( 654 mapper: (value: T, index: number, iter: this) => Iterable<M>, 655 context?: mixed 656 ): IndexedSeq<M>; 657 658 flatten(depth?: number): IndexedSeq<any>; 659 flatten(shallow?: boolean): IndexedSeq<any>; 660 661 zip<A>(a: Iterable<A>, ..._: []): IndexedSeq<[T, A]>; 662 zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): IndexedSeq<[T, A, B]>; 663 zip<A, B, C>( 664 a: Iterable<A>, 665 b: Iterable<B>, 666 c: Iterable<C>, 667 ..._: [] 668 ): IndexedSeq<[T, A, B, C]>; 669 zip<A, B, C, D>( 670 a: Iterable<A>, 671 b: Iterable<B>, 672 c: Iterable<C>, 673 d: Iterable<D>, 674 ..._: [] 675 ): IndexedSeq<[T, A, B, C, D]>; 676 zip<A, B, C, D, E>( 677 a: Iterable<A>, 678 b: Iterable<B>, 679 c: Iterable<C>, 680 d: Iterable<D>, 681 e: Iterable<E>, 682 ..._: [] 683 ): IndexedSeq<[T, A, B, C, D, E]>; 684 685 zipAll<A>(a: Iterable<A>, ..._: []): IndexedSeq<[T | void, A | void]>; 686 zipAll<A, B>( 687 a: Iterable<A>, 688 b: Iterable<B>, 689 ..._: [] 690 ): IndexedSeq<[T | void, A | void, B | void]>; 691 zipAll<A, B, C>( 692 a: Iterable<A>, 693 b: Iterable<B>, 694 c: Iterable<C>, 695 ..._: [] 696 ): IndexedSeq<[T | void, A | void, B | void, C | void]>; 697 zipAll<A, B, C, D>( 698 a: Iterable<A>, 699 b: Iterable<B>, 700 c: Iterable<C>, 701 d: Iterable<D>, 702 ..._: [] 703 ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void]>; 704 zipAll<A, B, C, D, E>( 705 a: Iterable<A>, 706 b: Iterable<B>, 707 c: Iterable<C>, 708 d: Iterable<D>, 709 e: Iterable<E>, 710 ..._: [] 711 ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void, E | void]>; 712 713 zipWith<A, R>( 714 zipper: (value: T, a: A) => R, 715 a: Iterable<A>, 716 ..._: [] 717 ): IndexedSeq<R>; 718 zipWith<A, B, R>( 719 zipper: (value: T, a: A, b: B) => R, 720 a: Iterable<A>, 721 b: Iterable<B>, 722 ..._: [] 723 ): IndexedSeq<R>; 724 zipWith<A, B, C, R>( 725 zipper: (value: T, a: A, b: B, c: C) => R, 726 a: Iterable<A>, 727 b: Iterable<B>, 728 c: Iterable<C>, 729 ..._: [] 730 ): IndexedSeq<R>; 731 zipWith<A, B, C, D, R>( 732 zipper: (value: T, a: A, b: B, c: C, d: D) => R, 733 a: Iterable<A>, 734 b: Iterable<B>, 735 c: Iterable<C>, 736 d: Iterable<D>, 737 ..._: [] 738 ): IndexedSeq<R>; 739 zipWith<A, B, C, D, E, R>( 740 zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, 741 a: Iterable<A>, 742 b: Iterable<B>, 743 c: Iterable<C>, 744 d: Iterable<D>, 745 e: Iterable<E>, 746 ..._: [] 747 ): IndexedSeq<R>; 748 } 749 750 declare class SetSeq<+T> extends Seq<T, T> mixins SetCollection<T> { 751 static <T>(values?: Iterable<T>): SetSeq<T>; 752 753 static of<T>(...values: T[]): SetSeq<T>; 754 755 // Override specialized return types 756 757 concat<U>(...collections: Iterable<U>[]): SetSeq<T | U>; 758 759 filter(predicate: typeof Boolean): SetSeq<$NonMaybeType<T>>; 760 filter( 761 predicate: (value: T, value: T, iter: this) => mixed, 762 context?: mixed 763 ): SetSeq<T>; 764 765 partition( 766 predicate: (value: T, value: T, iter: this) => mixed, 767 context?: mixed 768 ): [this, this]; 769 770 map<M>( 771 mapper: (value: T, value: T, iter: this) => M, 772 context?: mixed 773 ): SetSeq<M>; 774 775 flatMap<M>( 776 mapper: (value: T, value: T, iter: this) => Iterable<M>, 777 context?: mixed 778 ): SetSeq<M>; 779 780 flatten(depth?: number): SetSeq<any>; 781 flatten(shallow?: boolean): SetSeq<any>; 782 } 783 784 declare class UpdatableInCollection<K, +V> { 785 setIn<S>(keyPath: [], value: S): S; 786 setIn(keyPath: [K], value: V): this; 787 setIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>(keyPath: [K, K2], value: S): this; 788 setIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>, S: $ValOf<$ValOf<V, K2>, K3>>( 789 keyPath: [K, K2, K3], 790 value: S 791 ): this; 792 setIn< 793 K2: $KeyOf<V>, 794 K3: $KeyOf<$ValOf<V, K2>>, 795 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 796 S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> 797 >( 798 keyPath: [K, K2, K3, K4], 799 value: S 800 ): this; 801 setIn< 802 K2: $KeyOf<V>, 803 K3: $KeyOf<$ValOf<V, K2>>, 804 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 805 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, 806 S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> 807 >( 808 keyPath: [K, K2, K3, K4, K5], 809 value: S 810 ): this; 811 812 deleteIn(keyPath: []): void; 813 deleteIn(keyPath: [K]): this; 814 deleteIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this; 815 deleteIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>( 816 keyPath: [K, K2, K3] 817 ): this; 818 deleteIn< 819 K2: $KeyOf<V>, 820 K3: $KeyOf<$ValOf<V, K2>>, 821 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>> 822 >( 823 keyPath: [K, K2, K3, K4] 824 ): this; 825 deleteIn< 826 K2: $KeyOf<V>, 827 K3: $KeyOf<$ValOf<V, K2>>, 828 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 829 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>> 830 >( 831 keyPath: [K, K2, K3, K4, K5] 832 ): this; 833 834 removeIn(keyPath: []): void; 835 removeIn(keyPath: [K]): this; 836 removeIn<K2: $KeyOf<V>>(keyPath: [K, K2]): this; 837 removeIn<K2: $KeyOf<V>, K3: $KeyOf<$ValOf<V, K2>>>( 838 keyPath: [K, K2, K3] 839 ): this; 840 removeIn< 841 K2: $KeyOf<V>, 842 K3: $KeyOf<$ValOf<V, K2>>, 843 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>> 844 >( 845 keyPath: [K, K2, K3, K4] 846 ): this; 847 removeIn< 848 K2: $KeyOf<V>, 849 K3: $KeyOf<$ValOf<V, K2>>, 850 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 851 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>> 852 >( 853 keyPath: [K, K2, K3, K4, K5] 854 ): this; 855 856 updateIn<U>(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; 857 updateIn<U>(keyPath: [], updater: (value: this) => U): U; 858 updateIn<NSV>(keyPath: [K], notSetValue: NSV, updater: (value: V) => V): this; 859 updateIn(keyPath: [K], updater: (value: V) => V): this; 860 updateIn<NSV, K2: $KeyOf<V>, S: $ValOf<V, K2>>( 861 keyPath: [K, K2], 862 notSetValue: NSV, 863 updater: (value: $ValOf<V, K2> | NSV) => S 864 ): this; 865 updateIn<K2: $KeyOf<V>, S: $ValOf<V, K2>>( 866 keyPath: [K, K2], 867 updater: (value: $ValOf<V, K2>) => S 868 ): this; 869 updateIn< 870 NSV, 871 K2: $KeyOf<V>, 872 K3: $KeyOf<$ValOf<V, K2>>, 873 S: $ValOf<$ValOf<V, K2>, K3> 874 >( 875 keyPath: [K, K2, K3], 876 notSetValue: NSV, 877 updater: (value: $ValOf<$ValOf<V, K2>, K3> | NSV) => S 878 ): this; 879 updateIn< 880 K2: $KeyOf<V>, 881 K3: $KeyOf<$ValOf<V, K2>>, 882 S: $ValOf<$ValOf<V, K2>, K3> 883 >( 884 keyPath: [K, K2, K3], 885 updater: (value: $ValOf<$ValOf<V, K2>, K3>) => S 886 ): this; 887 updateIn< 888 NSV, 889 K2: $KeyOf<V>, 890 K3: $KeyOf<$ValOf<V, K2>>, 891 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 892 S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> 893 >( 894 keyPath: [K, K2, K3, K4], 895 notSetValue: NSV, 896 updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> | NSV) => S 897 ): this; 898 updateIn< 899 K2: $KeyOf<V>, 900 K3: $KeyOf<$ValOf<V, K2>>, 901 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 902 S: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4> 903 >( 904 keyPath: [K, K2, K3, K4], 905 updater: (value: $ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>) => S 906 ): this; 907 updateIn< 908 NSV, 909 K2: $KeyOf<V>, 910 K3: $KeyOf<$ValOf<V, K2>>, 911 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 912 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, 913 S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> 914 >( 915 keyPath: [K, K2, K3, K4, K5], 916 notSetValue: NSV, 917 updater: ( 918 value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> | NSV 919 ) => S 920 ): this; 921 updateIn< 922 K2: $KeyOf<V>, 923 K3: $KeyOf<$ValOf<V, K2>>, 924 K4: $KeyOf<$ValOf<$ValOf<V, K2>, K3>>, 925 K5: $KeyOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>>, 926 S: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5> 927 >( 928 keyPath: [K, K2, K3, K4, K5], 929 updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<V, K2>, K3>, K4>, K5>) => S 930 ): this; 931 } 932 933 declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof 934 List); 935 declare class List<+T> 936 extends IndexedCollection<T> 937 mixins UpdatableInCollection<number, T> 938 { 939 static (collection?: Iterable<T>): List<T>; 940 941 static of<T>(...values: T[]): List<T>; 942 943 static isList: typeof isList; 944 945 size: number; 946 947 set<U>(index: number, value: U): List<T | U>; 948 delete(index: number): this; 949 remove(index: number): this; 950 insert<U>(index: number, value: U): List<T | U>; 951 clear(): this; 952 push<U>(...values: U[]): List<T | U>; 953 pop(): this; 954 unshift<U>(...values: U[]): List<T | U>; 955 shift(): this; 956 957 update<U>(updater: (value: this) => U): U; 958 update<U>(index: number, updater: (value: T) => U): List<T | U>; 959 update<U>( 960 index: number, 961 notSetValue: U, 962 updater: (value: T) => U 963 ): List<T | U>; 964 965 merge<U>(...collections: Iterable<U>[]): List<T | U>; 966 967 setSize(size: number): this; 968 969 mergeIn(keyPath: Iterable<mixed>, ...collections: Iterable<mixed>[]): this; 970 mergeDeepIn( 971 keyPath: Iterable<mixed>, 972 ...collections: Iterable<mixed>[] 973 ): this; 974 975 withMutations(mutator: (mutable: this) => mixed): this; 976 asMutable(): this; 977 wasAltered(): boolean; 978 asImmutable(): this; 979 980 // Override specialized return types 981 982 concat<C>(...iters: Array<Iterable<C> | C>): List<T | C>; 983 984 filter(predicate: typeof Boolean): List<$NonMaybeType<T>>; 985 filter( 986 predicate: (value: T, index: number, iter: this) => mixed, 987 context?: mixed 988 ): List<T>; 989 990 partition( 991 predicate: (value: T, index: number, iter: this) => mixed, 992 context?: mixed 993 ): [this, this]; 994 995 map<M>( 996 mapper: (value: T, index: number, iter: this) => M, 997 context?: mixed 998 ): List<M>; 999 1000 flatMap<M>( 1001 mapper: (value: T, index: number, iter: this) => Iterable<M>, 1002 context?: mixed 1003 ): List<M>; 1004 1005 flatten(depth?: number): List<any>; 1006 flatten(shallow?: boolean): List<any>; 1007 1008 zip<A>(a: Iterable<A>, ..._: []): List<[T, A]>; 1009 zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): List<[T, A, B]>; 1010 zip<A, B, C>( 1011 a: Iterable<A>, 1012 b: Iterable<B>, 1013 c: Iterable<C>, 1014 ..._: [] 1015 ): List<[T, A, B, C]>; 1016 zip<A, B, C, D>( 1017 a: Iterable<A>, 1018 b: Iterable<B>, 1019 c: Iterable<C>, 1020 d: Iterable<D>, 1021 ..._: [] 1022 ): List<[T, A, B, C, D]>; 1023 zip<A, B, C, D, E>( 1024 a: Iterable<A>, 1025 b: Iterable<B>, 1026 c: Iterable<C>, 1027 d: Iterable<D>, 1028 e: Iterable<E>, 1029 ..._: [] 1030 ): List<[T, A, B, C, D, E]>; 1031 1032 zipAll<A>(a: Iterable<A>, ..._: []): List<[T | void, A | void]>; 1033 zipAll<A, B>( 1034 a: Iterable<A>, 1035 b: Iterable<B>, 1036 ..._: [] 1037 ): List<[T | void, A | void, B | void]>; 1038 zipAll<A, B, C>( 1039 a: Iterable<A>, 1040 b: Iterable<B>, 1041 c: Iterable<C>, 1042 ..._: [] 1043 ): List<[T | void, A | void, B | void, C | void]>; 1044 zipAll<A, B, C, D>( 1045 a: Iterable<A>, 1046 b: Iterable<B>, 1047 c: Iterable<C>, 1048 d: Iterable<D>, 1049 ..._: [] 1050 ): List<[T | void, A | void, B | void, C | void, D | void]>; 1051 zipAll<A, B, C, D, E>( 1052 a: Iterable<A>, 1053 b: Iterable<B>, 1054 c: Iterable<C>, 1055 d: Iterable<D>, 1056 e: Iterable<E>, 1057 ..._: [] 1058 ): List<[T | void, A | void, B | void, C | void, D | void, E | void]>; 1059 1060 zipWith<A, R>( 1061 zipper: (value: T, a: A) => R, 1062 a: Iterable<A>, 1063 ..._: [] 1064 ): List<R>; 1065 zipWith<A, B, R>( 1066 zipper: (value: T, a: A, b: B) => R, 1067 a: Iterable<A>, 1068 b: Iterable<B>, 1069 ..._: [] 1070 ): List<R>; 1071 zipWith<A, B, C, R>( 1072 zipper: (value: T, a: A, b: B, c: C) => R, 1073 a: Iterable<A>, 1074 b: Iterable<B>, 1075 c: Iterable<C>, 1076 ..._: [] 1077 ): List<R>; 1078 zipWith<A, B, C, D, R>( 1079 zipper: (value: T, a: A, b: B, c: C, d: D) => R, 1080 a: Iterable<A>, 1081 b: Iterable<B>, 1082 c: Iterable<C>, 1083 d: Iterable<D>, 1084 ..._: [] 1085 ): List<R>; 1086 zipWith<A, B, C, D, E, R>( 1087 zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, 1088 a: Iterable<A>, 1089 b: Iterable<B>, 1090 c: Iterable<C>, 1091 d: Iterable<D>, 1092 e: Iterable<E>, 1093 ..._: [] 1094 ): List<R>; 1095 } 1096 1097 declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof 1098 Map); 1099 declare class Map<K, +V> 1100 extends KeyedCollection<K, V> 1101 mixins UpdatableInCollection<K, V> 1102 { 1103 static <K, V>(values?: Iterable<[K, V]> | PlainObjInput<K, V>): Map<K, V>; 1104 1105 static isMap: typeof isMap; 1106 1107 size: number; 1108 1109 set<K_, V_>(key: K_, value: V_): Map<K | K_, V | V_>; 1110 delete(key: K): this; 1111 remove(key: K): this; 1112 clear(): this; 1113 1114 deleteAll(keys: Iterable<K>): Map<K, V>; 1115 removeAll(keys: Iterable<K>): Map<K, V>; 1116 1117 update<U>(updater: (value: this) => U): U; 1118 update<V_>(key: K, updater: (value: V) => V_): Map<K, V | V_>; 1119 update<V_>( 1120 key: K, 1121 notSetValue: V_, 1122 updater: (value: V) => V_ 1123 ): Map<K, V | V_>; 1124 1125 merge<K_, V_>( 1126 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1127 ): Map<K | K_, V | V_>; 1128 concat<K_, V_>( 1129 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1130 ): Map<K | K_, V | V_>; 1131 1132 mergeWith<K_, W, X>( 1133 merger: (oldVal: V, newVal: W, key: K) => X, 1134 ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[] 1135 ): Map<K | K_, V | W | X>; 1136 1137 mergeDeep<K_, V_>( 1138 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1139 ): Map<K | K_, V | V_>; 1140 1141 mergeDeepWith<K_, V_>( 1142 merger: (oldVal: any, newVal: any, key: any) => mixed, 1143 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1144 ): Map<K | K_, V | V_>; 1145 1146 mergeIn( 1147 keyPath: Iterable<mixed>, 1148 ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[] 1149 ): this; 1150 mergeDeepIn( 1151 keyPath: Iterable<mixed>, 1152 ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[] 1153 ): this; 1154 1155 withMutations(mutator: (mutable: this) => mixed): this; 1156 asMutable(): this; 1157 wasAltered(): boolean; 1158 asImmutable(): this; 1159 1160 // Override specialized return types 1161 1162 flip(): Map<V, K>; 1163 1164 filter(predicate: typeof Boolean): Map<K, $NonMaybeType<V>>; 1165 filter( 1166 predicate: (value: V, key: K, iter: this) => mixed, 1167 context?: mixed 1168 ): Map<K, V>; 1169 1170 partition( 1171 predicate: (value: V, key: K, iter: this) => mixed, 1172 context?: mixed 1173 ): [this, this]; 1174 1175 map<M>( 1176 mapper: (value: V, key: K, iter: this) => M, 1177 context?: mixed 1178 ): Map<K, M>; 1179 1180 mapKeys<M>( 1181 mapper: (key: K, value: V, iter: this) => M, 1182 context?: mixed 1183 ): Map<M, V>; 1184 1185 mapEntries<KM, VM>( 1186 mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], 1187 context?: mixed 1188 ): Map<KM, VM>; 1189 1190 flatMap<KM, VM>( 1191 mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, 1192 context?: mixed 1193 ): Map<KM, VM>; 1194 1195 flatten(depth?: number): Map<any, any>; 1196 flatten(shallow?: boolean): Map<any, any>; 1197 } 1198 1199 declare function isOrderedMap( 1200 maybeOrderedMap: mixed 1201 ): boolean %checks(maybeOrderedMap instanceof OrderedMap); 1202 declare class OrderedMap<K, +V> 1203 extends Map<K, V> 1204 mixins UpdatableInCollection<K, V> 1205 { 1206 static <K, V>( 1207 values?: Iterable<[K, V]> | PlainObjInput<K, V> 1208 ): OrderedMap<K, V>; 1209 1210 static isOrderedMap: typeof isOrderedMap; 1211 1212 size: number; 1213 1214 set<K_, V_>(key: K_, value: V_): OrderedMap<K | K_, V | V_>; 1215 delete(key: K): this; 1216 remove(key: K): this; 1217 clear(): this; 1218 1219 update<U>(updater: (value: this) => U): U; 1220 update<V_>(key: K, updater: (value: V) => V_): OrderedMap<K, V | V_>; 1221 update<V_>( 1222 key: K, 1223 notSetValue: V_, 1224 updater: (value: V) => V_ 1225 ): OrderedMap<K, V | V_>; 1226 1227 merge<K_, V_>( 1228 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1229 ): OrderedMap<K | K_, V | V_>; 1230 concat<K_, V_>( 1231 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1232 ): OrderedMap<K | K_, V | V_>; 1233 1234 mergeWith<K_, W, X>( 1235 merger: (oldVal: V, newVal: W, key: K) => X, 1236 ...collections: (Iterable<[K_, W]> | PlainObjInput<K_, W>)[] 1237 ): OrderedMap<K | K_, V | W | X>; 1238 1239 mergeDeep<K_, V_>( 1240 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1241 ): OrderedMap<K | K_, V | V_>; 1242 1243 mergeDeepWith<K_, V_>( 1244 merger: (oldVal: any, newVal: any, key: any) => mixed, 1245 ...collections: (Iterable<[K_, V_]> | PlainObjInput<K_, V_>)[] 1246 ): OrderedMap<K | K_, V | V_>; 1247 1248 mergeIn( 1249 keyPath: Iterable<mixed>, 1250 ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[] 1251 ): this; 1252 mergeDeepIn( 1253 keyPath: Iterable<mixed>, 1254 ...collections: (Iterable<mixed> | PlainObjInput<mixed, mixed>)[] 1255 ): this; 1256 1257 withMutations(mutator: (mutable: this) => mixed): this; 1258 asMutable(): this; 1259 wasAltered(): boolean; 1260 asImmutable(): this; 1261 1262 // Override specialized return types 1263 1264 flip(): OrderedMap<V, K>; 1265 1266 filter(predicate: typeof Boolean): OrderedMap<K, $NonMaybeType<V>>; 1267 filter( 1268 predicate: (value: V, key: K, iter: this) => mixed, 1269 context?: mixed 1270 ): OrderedMap<K, V>; 1271 1272 partition( 1273 predicate: (value: V, key: K, iter: this) => mixed, 1274 context?: mixed 1275 ): [this, this]; 1276 1277 map<M>( 1278 mapper: (value: V, key: K, iter: this) => M, 1279 context?: mixed 1280 ): OrderedMap<K, M>; 1281 1282 mapKeys<M>( 1283 mapper: (key: K, value: V, iter: this) => M, 1284 context?: mixed 1285 ): OrderedMap<M, V>; 1286 1287 mapEntries<KM, VM>( 1288 mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], 1289 context?: mixed 1290 ): OrderedMap<KM, VM>; 1291 1292 flatMap<KM, VM>( 1293 mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, 1294 context?: mixed 1295 ): OrderedMap<KM, VM>; 1296 1297 flatten(depth?: number): OrderedMap<any, any>; 1298 flatten(shallow?: boolean): OrderedMap<any, any>; 1299 } 1300 1301 declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof 1302 Set); 1303 declare class Set<+T> extends SetCollection<T> { 1304 static <T>(values?: Iterable<T>): Set<T>; 1305 1306 static of<T>(...values: T[]): Set<T>; 1307 static fromKeys<T>( 1308 values: Iterable<[T, mixed]> | PlainObjInput<T, mixed> 1309 ): Set<T>; 1310 1311 static intersect(sets: Iterable<Iterable<T>>): Set<T>; 1312 static union(sets: Iterable<Iterable<T>>): Set<T>; 1313 1314 static isSet: typeof isSet; 1315 1316 size: number; 1317 1318 add<U>(value: U): Set<T | U>; 1319 delete(value: T): this; 1320 remove(value: T): this; 1321 clear(): this; 1322 union<U>(...collections: Iterable<U>[]): Set<T | U>; 1323 merge<U>(...collections: Iterable<U>[]): Set<T | U>; 1324 concat<U>(...collections: Iterable<U>[]): Set<T | U>; 1325 intersect<U>(...collections: Iterable<U>[]): Set<T & U>; 1326 subtract(...collections: Iterable<mixed>[]): this; 1327 1328 withMutations(mutator: (mutable: this) => mixed): this; 1329 asMutable(): this; 1330 wasAltered(): boolean; 1331 asImmutable(): this; 1332 1333 // Override specialized return types 1334 1335 filter(predicate: typeof Boolean): Set<$NonMaybeType<T>>; 1336 filter( 1337 predicate: (value: T, value: T, iter: this) => mixed, 1338 context?: mixed 1339 ): Set<T>; 1340 1341 partition( 1342 predicate: (value: T, value: T, iter: this) => mixed, 1343 context?: mixed 1344 ): [this, this]; 1345 1346 map<M>( 1347 mapper: (value: T, value: T, iter: this) => M, 1348 context?: mixed 1349 ): Set<M>; 1350 1351 flatMap<M>( 1352 mapper: (value: T, value: T, iter: this) => Iterable<M>, 1353 context?: mixed 1354 ): Set<M>; 1355 1356 flatten(depth?: number): Set<any>; 1357 flatten(shallow?: boolean): Set<any>; 1358 } 1359 1360 // Overrides except for `isOrderedSet` are for specialized return types 1361 declare function isOrderedSet( 1362 maybeOrderedSet: mixed 1363 ): boolean %checks(maybeOrderedSet instanceof OrderedSet); 1364 declare class OrderedSet<+T> extends Set<T> { 1365 static <T>(values?: Iterable<T>): OrderedSet<T>; 1366 1367 static of<T>(...values: T[]): OrderedSet<T>; 1368 static fromKeys<T>( 1369 values: Iterable<[T, mixed]> | PlainObjInput<T, mixed> 1370 ): OrderedSet<T>; 1371 1372 static isOrderedSet: typeof isOrderedSet; 1373 1374 size: number; 1375 1376 add<U>(value: U): OrderedSet<T | U>; 1377 union<U>(...collections: Iterable<U>[]): OrderedSet<T | U>; 1378 merge<U>(...collections: Iterable<U>[]): OrderedSet<T | U>; 1379 concat<U>(...collections: Iterable<U>[]): OrderedSet<T | U>; 1380 intersect<U>(...collections: Iterable<U>[]): OrderedSet<T & U>; 1381 1382 filter(predicate: typeof Boolean): OrderedSet<$NonMaybeType<T>>; 1383 filter( 1384 predicate: (value: T, value: T, iter: this) => mixed, 1385 context?: mixed 1386 ): OrderedSet<T>; 1387 1388 partition( 1389 predicate: (value: T, value: T, iter: this) => mixed, 1390 context?: mixed 1391 ): [this, this]; 1392 1393 map<M>( 1394 mapper: (value: T, value: T, iter: this) => M, 1395 context?: mixed 1396 ): OrderedSet<M>; 1397 1398 flatMap<M>( 1399 mapper: (value: T, value: T, iter: this) => Iterable<M>, 1400 context?: mixed 1401 ): OrderedSet<M>; 1402 1403 flatten(depth?: number): OrderedSet<any>; 1404 flatten(shallow?: boolean): OrderedSet<any>; 1405 1406 zip<A>(a: Iterable<A>, ..._: []): OrderedSet<[T, A]>; 1407 zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): OrderedSet<[T, A, B]>; 1408 zip<A, B, C>( 1409 a: Iterable<A>, 1410 b: Iterable<B>, 1411 c: Iterable<C>, 1412 ..._: [] 1413 ): OrderedSet<[T, A, B, C]>; 1414 zip<A, B, C, D>( 1415 a: Iterable<A>, 1416 b: Iterable<B>, 1417 c: Iterable<C>, 1418 d: Iterable<D>, 1419 ..._: [] 1420 ): OrderedSet<[T, A, B, C, D]>; 1421 zip<A, B, C, D, E>( 1422 a: Iterable<A>, 1423 b: Iterable<B>, 1424 c: Iterable<C>, 1425 d: Iterable<D>, 1426 e: Iterable<E>, 1427 ..._: [] 1428 ): OrderedSet<[T, A, B, C, D, E]>; 1429 1430 zipAll<A>(a: Iterable<A>, ..._: []): OrderedSet<[T | void, A | void]>; 1431 zipAll<A, B>( 1432 a: Iterable<A>, 1433 b: Iterable<B>, 1434 ..._: [] 1435 ): OrderedSet<[T | void, A | void, B | void]>; 1436 zipAll<A, B, C>( 1437 a: Iterable<A>, 1438 b: Iterable<B>, 1439 c: Iterable<C>, 1440 ..._: [] 1441 ): OrderedSet<[T | void, A | void, B | void, C | void]>; 1442 zipAll<A, B, C, D>( 1443 a: Iterable<A>, 1444 b: Iterable<B>, 1445 c: Iterable<C>, 1446 d: Iterable<D>, 1447 ..._: [] 1448 ): OrderedSet<[T | void, A | void, B | void, C | void, D | void]>; 1449 zipAll<A, B, C, D, E>( 1450 a: Iterable<A>, 1451 b: Iterable<B>, 1452 c: Iterable<C>, 1453 d: Iterable<D>, 1454 e: Iterable<E>, 1455 ..._: [] 1456 ): OrderedSet<[T | void, A | void, B | void, C | void, D | void, E | void]>; 1457 1458 zipWith<A, R>( 1459 zipper: (value: T, a: A) => R, 1460 a: Iterable<A>, 1461 ..._: [] 1462 ): OrderedSet<R>; 1463 zipWith<A, B, R>( 1464 zipper: (value: T, a: A, b: B) => R, 1465 a: Iterable<A>, 1466 b: Iterable<B>, 1467 ..._: [] 1468 ): OrderedSet<R>; 1469 zipWith<A, B, C, R>( 1470 zipper: (value: T, a: A, b: B, c: C) => R, 1471 a: Iterable<A>, 1472 b: Iterable<B>, 1473 c: Iterable<C>, 1474 ..._: [] 1475 ): OrderedSet<R>; 1476 zipWith<A, B, C, D, R>( 1477 zipper: (value: T, a: A, b: B, c: C, d: D) => R, 1478 a: Iterable<A>, 1479 b: Iterable<B>, 1480 c: Iterable<C>, 1481 d: Iterable<D>, 1482 ..._: [] 1483 ): OrderedSet<R>; 1484 zipWith<A, B, C, D, E, R>( 1485 zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, 1486 a: Iterable<A>, 1487 b: Iterable<B>, 1488 c: Iterable<C>, 1489 d: Iterable<D>, 1490 e: Iterable<E>, 1491 ..._: [] 1492 ): OrderedSet<R>; 1493 } 1494 1495 declare function isStack( 1496 maybeStack: mixed 1497 ): boolean %checks(maybeStack instanceof Stack); 1498 declare class Stack<+T> extends IndexedCollection<T> { 1499 static <T>(collection?: Iterable<T>): Stack<T>; 1500 1501 static isStack(maybeStack: mixed): boolean; 1502 static of<T>(...values: T[]): Stack<T>; 1503 1504 static isStack: typeof isStack; 1505 1506 size: number; 1507 1508 peek(): T; 1509 clear(): this; 1510 unshift<U>(...values: U[]): Stack<T | U>; 1511 unshiftAll<U>(iter: Iterable<U>): Stack<T | U>; 1512 shift(): this; 1513 push<U>(...values: U[]): Stack<T | U>; 1514 pushAll<U>(iter: Iterable<U>): Stack<T | U>; 1515 pop(): this; 1516 1517 withMutations(mutator: (mutable: this) => mixed): this; 1518 asMutable(): this; 1519 wasAltered(): boolean; 1520 asImmutable(): this; 1521 1522 // Override specialized return types 1523 1524 concat<C>(...iters: Array<Iterable<C> | C>): Stack<T | C>; 1525 1526 filter(predicate: typeof Boolean): Stack<$NonMaybeType<T>>; 1527 filter( 1528 predicate: (value: T, index: number, iter: this) => mixed, 1529 context?: mixed 1530 ): Stack<T>; 1531 1532 map<M>( 1533 mapper: (value: T, index: number, iter: this) => M, 1534 context?: mixed 1535 ): Stack<M>; 1536 1537 flatMap<M>( 1538 mapper: (value: T, index: number, iter: this) => Iterable<M>, 1539 context?: mixed 1540 ): Stack<M>; 1541 1542 flatten(depth?: number): Stack<any>; 1543 flatten(shallow?: boolean): Stack<any>; 1544 1545 zip<A>(a: Iterable<A>, ..._: []): Stack<[T, A]>; 1546 zip<A, B>(a: Iterable<A>, b: Iterable<B>, ..._: []): Stack<[T, A, B]>; 1547 zip<A, B, C>( 1548 a: Iterable<A>, 1549 b: Iterable<B>, 1550 c: Iterable<C>, 1551 ..._: [] 1552 ): Stack<[T, A, B, C]>; 1553 zip<A, B, C, D>( 1554 a: Iterable<A>, 1555 b: Iterable<B>, 1556 c: Iterable<C>, 1557 d: Iterable<D>, 1558 ..._: [] 1559 ): Stack<[T, A, B, C, D]>; 1560 zip<A, B, C, D, E>( 1561 a: Iterable<A>, 1562 b: Iterable<B>, 1563 c: Iterable<C>, 1564 d: Iterable<D>, 1565 e: Iterable<E>, 1566 ..._: [] 1567 ): Stack<[T, A, B, C, D, E]>; 1568 1569 zipAll<A>(a: Iterable<A>, ..._: []): Stack<[T | void, A | void]>; 1570 zipAll<A, B>( 1571 a: Iterable<A>, 1572 b: Iterable<B>, 1573 ..._: [] 1574 ): Stack<[T | void, A | void, B | void]>; 1575 zipAll<A, B, C>( 1576 a: Iterable<A>, 1577 b: Iterable<B>, 1578 c: Iterable<C>, 1579 ..._: [] 1580 ): Stack<[T | void, A | void, B | void, C | void]>; 1581 zipAll<A, B, C, D>( 1582 a: Iterable<A>, 1583 b: Iterable<B>, 1584 c: Iterable<C>, 1585 d: Iterable<D>, 1586 ..._: [] 1587 ): Stack<[T | void, A | void, B | void, C | void, D | void]>; 1588 zipAll<A, B, C, D, E>( 1589 a: Iterable<A>, 1590 b: Iterable<B>, 1591 c: Iterable<C>, 1592 d: Iterable<D>, 1593 e: Iterable<E>, 1594 ..._: [] 1595 ): Stack<[T | void, A | void, B | void, C | void, D | void, E | void]>; 1596 1597 zipWith<A, R>( 1598 zipper: (value: T, a: A) => R, 1599 a: Iterable<A>, 1600 ..._: [] 1601 ): Stack<R>; 1602 zipWith<A, B, R>( 1603 zipper: (value: T, a: A, b: B) => R, 1604 a: Iterable<A>, 1605 b: Iterable<B>, 1606 ..._: [] 1607 ): Stack<R>; 1608 zipWith<A, B, C, R>( 1609 zipper: (value: T, a: A, b: B, c: C) => R, 1610 a: Iterable<A>, 1611 b: Iterable<B>, 1612 c: Iterable<C>, 1613 ..._: [] 1614 ): Stack<R>; 1615 zipWith<A, B, C, D, R>( 1616 zipper: (value: T, a: A, b: B, c: C, d: D) => R, 1617 a: Iterable<A>, 1618 b: Iterable<B>, 1619 c: Iterable<C>, 1620 d: Iterable<D>, 1621 ..._: [] 1622 ): Stack<R>; 1623 zipWith<A, B, C, D, E, R>( 1624 zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, 1625 a: Iterable<A>, 1626 b: Iterable<B>, 1627 c: Iterable<C>, 1628 d: Iterable<D>, 1629 e: Iterable<E>, 1630 ..._: [] 1631 ): Stack<R>; 1632 } 1633 1634 declare function Range( 1635 start?: number, 1636 end?: number, 1637 step?: number 1638 ): IndexedSeq<number>; 1639 declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>; 1640 1641 // The type of a Record factory function. 1642 type RecordFactory<Values: Object> = Class<RecordInstance<Values>>; 1643 1644 // The type of runtime Record instances. 1645 type RecordOf<Values: Object> = RecordInstance<Values> & $ReadOnly<Values>; 1646 1647 // The values of a Record instance. 1648 type _RecordValues<T, R: RecordInstance<T> | T> = R; 1649 type RecordValues<R> = _RecordValues<*, R>; 1650 1651 declare function isRecord( 1652 maybeRecord: any 1653 ): boolean %checks(maybeRecord instanceof RecordInstance); 1654 declare class Record { 1655 static <Values: Object>(spec: Values, name?: string): typeof RecordInstance; 1656 constructor<Values: Object>( 1657 spec: Values, 1658 name?: string 1659 ): typeof RecordInstance; 1660 1661 static isRecord: typeof isRecord; 1662 1663 static getDescriptiveName(record: RecordInstance<any>): string; 1664 } 1665 1666 declare class RecordInstance<T: Object = Object> { 1667 static (values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): RecordOf<T>; 1668 // Note: a constructor can only create an instance of RecordInstance<T>, 1669 // it's encouraged to not use `new` when creating Records. 1670 constructor(values?: Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>): void; 1671 1672 size: number; 1673 1674 has(key: string): boolean; 1675 1676 get<K: $Keys<T>>(key: K, ..._: []): $ElementType<T, K>; 1677 get<K: $Keys<T>, NSV>(key: K, notSetValue: NSV): $ElementType<T, K> | NSV; 1678 1679 hasIn(keyPath: Iterable<mixed>): boolean; 1680 1681 getIn(keyPath: [], notSetValue?: mixed): this & $ReadOnly<T>; 1682 getIn<K: $Keys<T>>(keyPath: [K], notSetValue?: mixed): $ElementType<T, K>; 1683 getIn<NSV, K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>( 1684 keyPath: [K, K2], 1685 notSetValue: NSV 1686 ): $ValOf<$ValOf<T, K>, K2> | NSV; 1687 getIn< 1688 NSV, 1689 K: $Keys<T>, 1690 K2: $KeyOf<$ValOf<T, K>>, 1691 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>> 1692 >( 1693 keyPath: [K, K2, K3], 1694 notSetValue: NSV 1695 ): $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV; 1696 getIn< 1697 NSV, 1698 K: $Keys<T>, 1699 K2: $KeyOf<$ValOf<T, K>>, 1700 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1701 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>> 1702 >( 1703 keyPath: [K, K2, K3, K4], 1704 notSetValue: NSV 1705 ): $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV; 1706 getIn< 1707 NSV, 1708 K: $Keys<T>, 1709 K2: $KeyOf<$ValOf<T, K>>, 1710 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1711 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1712 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>> 1713 >( 1714 keyPath: [K, K2, K3, K4, K5], 1715 notSetValue: NSV 1716 ): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV; 1717 1718 equals(other: any): boolean; 1719 hashCode(): number; 1720 1721 set<K: $Keys<T>>(key: K, value: $ElementType<T, K>): this & $ReadOnly<T>; 1722 update<K: $Keys<T>>( 1723 key: K, 1724 updater: (value: $ElementType<T, K>) => $ElementType<T, K> 1725 ): this & $ReadOnly<T>; 1726 merge( 1727 ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>> 1728 ): this & $ReadOnly<T>; 1729 mergeDeep( 1730 ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>> 1731 ): this & $ReadOnly<T>; 1732 1733 mergeWith( 1734 merger: (oldVal: $ValOf<T>, newVal: $ValOf<T>, key: $Keys<T>) => $ValOf<T>, 1735 ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>> 1736 ): this & $ReadOnly<T>; 1737 mergeDeepWith( 1738 merger: (oldVal: any, newVal: any, key: any) => any, 1739 ...collections: Array<Iterable<[$Keys<T>, $ValOf<T>]> | $Shape<T>> 1740 ): this & $ReadOnly<T>; 1741 1742 delete<K: $Keys<T>>(key: K): this & $ReadOnly<T>; 1743 remove<K: $Keys<T>>(key: K): this & $ReadOnly<T>; 1744 clear(): this & $ReadOnly<T>; 1745 1746 setIn<S>(keyPath: [], value: S): S; 1747 setIn<K: $Keys<T>, S: $ValOf<T, K>>( 1748 keyPath: [K], 1749 value: S 1750 ): this & $ReadOnly<T>; 1751 setIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>( 1752 keyPath: [K, K2], 1753 value: S 1754 ): this & $ReadOnly<T>; 1755 setIn< 1756 K: $Keys<T>, 1757 K2: $KeyOf<$ValOf<T, K>>, 1758 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1759 S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> 1760 >( 1761 keyPath: [K, K2, K3], 1762 value: S 1763 ): this & $ReadOnly<T>; 1764 setIn< 1765 K: $Keys<T>, 1766 K2: $KeyOf<$ValOf<T, K>>, 1767 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1768 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1769 S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> 1770 >( 1771 keyPath: [K, K2, K3, K4], 1772 value: S 1773 ): this & $ReadOnly<T>; 1774 setIn< 1775 K: $Keys<T>, 1776 K2: $KeyOf<$ValOf<T, K>>, 1777 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1778 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1779 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, 1780 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> 1781 >( 1782 keyPath: [K, K2, K3, K4, K5], 1783 value: S 1784 ): this & $ReadOnly<T>; 1785 1786 deleteIn(keyPath: []): void; 1787 deleteIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>; 1788 deleteIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>( 1789 keyPath: [K, K2] 1790 ): this & $ReadOnly<T>; 1791 deleteIn< 1792 K: $Keys<T>, 1793 K2: $KeyOf<$ValOf<T, K>>, 1794 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>> 1795 >( 1796 keyPath: [K, K2, K3] 1797 ): this & $ReadOnly<T>; 1798 deleteIn< 1799 K: $Keys<T>, 1800 K2: $KeyOf<$ValOf<T, K>>, 1801 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1802 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>> 1803 >( 1804 keyPath: [K, K2, K3, K4] 1805 ): this & $ReadOnly<T>; 1806 deleteIn< 1807 K: $Keys<T>, 1808 K2: $KeyOf<$ValOf<T, K>>, 1809 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1810 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1811 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>> 1812 >( 1813 keyPath: [K, K2, K3, K4, K5] 1814 ): this & $ReadOnly<T>; 1815 1816 removeIn(keyPath: []): void; 1817 removeIn<K: $Keys<T>>(keyPath: [K]): this & $ReadOnly<T>; 1818 removeIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>>( 1819 keyPath: [K, K2] 1820 ): this & $ReadOnly<T>; 1821 removeIn< 1822 K: $Keys<T>, 1823 K2: $KeyOf<$ValOf<T, K>>, 1824 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>> 1825 >( 1826 keyPath: [K, K2, K3] 1827 ): this & $ReadOnly<T>; 1828 removeIn< 1829 K: $Keys<T>, 1830 K2: $KeyOf<$ValOf<T, K>>, 1831 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1832 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>> 1833 >( 1834 keyPath: [K, K2, K3, K4] 1835 ): this & $ReadOnly<T>; 1836 removeIn< 1837 K: $Keys<T>, 1838 K2: $KeyOf<$ValOf<T, K>>, 1839 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1840 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1841 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>> 1842 >( 1843 keyPath: [K, K2, K3, K4, K5] 1844 ): this & $ReadOnly<T>; 1845 1846 updateIn<U>( 1847 keyPath: [], 1848 notSetValue: mixed, 1849 updater: (value: this & T) => U 1850 ): U; 1851 updateIn<U>(keyPath: [], updater: (value: this & T) => U): U; 1852 updateIn<NSV, K: $Keys<T>, S: $ValOf<T, K>>( 1853 keyPath: [K], 1854 notSetValue: NSV, 1855 updater: (value: $ValOf<T, K>) => S 1856 ): this & $ReadOnly<T>; 1857 updateIn<K: $Keys<T>, S: $ValOf<T, K>>( 1858 keyPath: [K], 1859 updater: (value: $ValOf<T, K>) => S 1860 ): this & $ReadOnly<T>; 1861 updateIn< 1862 NSV, 1863 K: $Keys<T>, 1864 K2: $KeyOf<$ValOf<T, K>>, 1865 S: $ValOf<$ValOf<T, K>, K2> 1866 >( 1867 keyPath: [K, K2], 1868 notSetValue: NSV, 1869 updater: (value: $ValOf<$ValOf<T, K>, K2> | NSV) => S 1870 ): this & $ReadOnly<T>; 1871 updateIn<K: $Keys<T>, K2: $KeyOf<$ValOf<T, K>>, S: $ValOf<$ValOf<T, K>, K2>>( 1872 keyPath: [K, K2], 1873 updater: (value: $ValOf<$ValOf<T, K>, K2>) => S 1874 ): this & $ReadOnly<T>; 1875 updateIn< 1876 NSV, 1877 K: $Keys<T>, 1878 K2: $KeyOf<$ValOf<T, K>>, 1879 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1880 S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> 1881 >( 1882 keyPath: [K, K2, K3], 1883 notSetValue: NSV, 1884 updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> | NSV) => S 1885 ): this & $ReadOnly<T>; 1886 updateIn< 1887 K: $Keys<T>, 1888 K2: $KeyOf<$ValOf<T, K>>, 1889 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1890 S: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3> 1891 >( 1892 keyPath: [K, K2, K3], 1893 updater: (value: $ValOf<$ValOf<$ValOf<T, K>, K2>, K3>) => S 1894 ): this & $ReadOnly<T>; 1895 updateIn< 1896 NSV, 1897 K: $Keys<T>, 1898 K2: $KeyOf<$ValOf<T, K>>, 1899 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1900 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1901 S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> 1902 >( 1903 keyPath: [K, K2, K3, K4], 1904 notSetValue: NSV, 1905 updater: ( 1906 value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> | NSV 1907 ) => S 1908 ): this & $ReadOnly<T>; 1909 updateIn< 1910 K: $Keys<T>, 1911 K2: $KeyOf<$ValOf<T, K>>, 1912 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1913 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1914 S: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4> 1915 >( 1916 keyPath: [K, K2, K3, K4], 1917 updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>) => S 1918 ): this & $ReadOnly<T>; 1919 updateIn< 1920 NSV, 1921 K: $Keys<T>, 1922 K2: $KeyOf<$ValOf<T, K>>, 1923 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1924 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1925 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, 1926 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> 1927 >( 1928 keyPath: [K, K2, K3, K4, K5], 1929 notSetValue: NSV, 1930 updater: ( 1931 value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> | NSV 1932 ) => S 1933 ): this & $ReadOnly<T>; 1934 updateIn< 1935 K: $Keys<T>, 1936 K2: $KeyOf<$ValOf<T, K>>, 1937 K3: $KeyOf<$ValOf<$ValOf<T, K>, K2>>, 1938 K4: $KeyOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>>, 1939 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>>, 1940 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> 1941 >( 1942 keyPath: [K, K2, K3, K4, K5], 1943 updater: ( 1944 value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<T, K>, K2>, K3>, K4>, K5> 1945 ) => S 1946 ): this & $ReadOnly<T>; 1947 1948 mergeIn( 1949 keyPath: Iterable<mixed>, 1950 ...collections: Array<any> 1951 ): this & $ReadOnly<T>; 1952 mergeDeepIn( 1953 keyPath: Iterable<mixed>, 1954 ...collections: Array<any> 1955 ): this & $ReadOnly<T>; 1956 1957 toSeq(): KeyedSeq<$Keys<T>, any>; 1958 1959 toJS(): { [key: $Keys<T>]: mixed }; 1960 toJSON(): T; 1961 toObject(): T; 1962 1963 withMutations(mutator: (mutable: this & T) => mixed): this & $ReadOnly<T>; 1964 asMutable(): this & $ReadOnly<T>; 1965 wasAltered(): boolean; 1966 asImmutable(): this & $ReadOnly<T>; 1967 1968 @@iterator(): Iterator<[$Keys<T>, $ValOf<T>]>; 1969 } 1970 1971 declare function fromJS( 1972 jsValue: mixed, 1973 reviver?: ( 1974 key: string | number, 1975 sequence: KeyedCollection<string, mixed> | IndexedCollection<mixed>, 1976 path?: Array<string | number> 1977 ) => mixed 1978 ): Collection<mixed, mixed>; 1979 1980 declare function is(first: mixed, second: mixed): boolean; 1981 declare function hash(value: mixed): number; 1982 1983 declare function get<C: Object, K: $Keys<C>>( 1984 collection: C, 1985 key: K, 1986 notSetValue: mixed 1987 ): $ValOf<C, K>; 1988 declare function get<C, K: $KeyOf<C>, NSV>( 1989 collection: C, 1990 key: K, 1991 notSetValue: NSV 1992 ): $ValOf<C, K> | NSV; 1993 1994 declare function has(collection: Object, key: mixed): boolean; 1995 declare function remove<C>(collection: C, key: $KeyOf<C>): C; 1996 declare function set<C, K: $KeyOf<C>, V: $ValOf<C, K>>( 1997 collection: C, 1998 key: K, 1999 value: V 2000 ): C; 2001 declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>, NSV>( 2002 collection: C, 2003 key: K, 2004 notSetValue: NSV, 2005 updater: ($ValOf<C, K> | NSV) => V 2006 ): C; 2007 declare function update<C, K: $KeyOf<C>, V: $ValOf<C, K>>( 2008 collection: C, 2009 key: K, 2010 updater: ($ValOf<C, K>) => V 2011 ): C; 2012 2013 declare function getIn<C>(collection: C, keyPath: [], notSetValue?: mixed): C; 2014 declare function getIn<C, K: $KeyOf<C>, NSV>( 2015 collection: C, 2016 keyPath: [K], 2017 notSetValue: NSV 2018 ): $ValOf<C, K> | NSV; 2019 declare function getIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>, NSV>( 2020 collection: C, 2021 keyPath: [K, K2], 2022 notSetValue: NSV 2023 ): $ValOf<$ValOf<C, K>, K2> | NSV; 2024 declare function getIn< 2025 C, 2026 K: $KeyOf<C>, 2027 K2: $KeyOf<$ValOf<C, K>>, 2028 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2029 NSV 2030 >( 2031 collection: C, 2032 keyPath: [K, K2, K3], 2033 notSetValue: NSV 2034 ): $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV; 2035 declare function getIn< 2036 C, 2037 K: $KeyOf<C>, 2038 K2: $KeyOf<$ValOf<C, K>>, 2039 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2040 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2041 NSV 2042 >( 2043 collection: C, 2044 keyPath: [K, K2, K3, K4], 2045 notSetValue: NSV 2046 ): $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV; 2047 declare function getIn< 2048 C, 2049 K: $KeyOf<C>, 2050 K2: $KeyOf<$ValOf<C, K>>, 2051 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2052 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2053 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, 2054 NSV 2055 >( 2056 collection: C, 2057 keyPath: [K, K2, K3, K4, K5], 2058 notSetValue: NSV 2059 ): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV; 2060 2061 declare function hasIn(collection: Object, keyPath: Iterable<mixed>): boolean; 2062 2063 declare function removeIn<C>(collection: C, keyPath: []): void; 2064 declare function removeIn<C, K: $KeyOf<C>>(collection: C, keyPath: [K]): C; 2065 declare function removeIn<C, K: $KeyOf<C>, K2: $KeyOf<$ValOf<C, K>>>( 2066 collection: C, 2067 keyPath: [K, K2] 2068 ): C; 2069 declare function removeIn< 2070 C, 2071 K: $KeyOf<C>, 2072 K2: $KeyOf<$ValOf<C, K>>, 2073 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>> 2074 >( 2075 collection: C, 2076 keyPath: [K, K2, K3] 2077 ): C; 2078 declare function removeIn< 2079 C, 2080 K: $KeyOf<C>, 2081 K2: $KeyOf<$ValOf<C, K>>, 2082 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2083 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>> 2084 >( 2085 collection: C, 2086 keyPath: [K, K2, K3, K4] 2087 ): C; 2088 declare function removeIn< 2089 C, 2090 K: $KeyOf<C>, 2091 K2: $KeyOf<$ValOf<C, K>>, 2092 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2093 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2094 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>> 2095 >( 2096 collection: C, 2097 keyPath: [K, K2, K3, K4, K5] 2098 ): C; 2099 2100 declare function setIn<S>(collection: Object, keyPath: [], value: S): S; 2101 declare function setIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>( 2102 collection: C, 2103 keyPath: [K], 2104 value: S 2105 ): C; 2106 declare function setIn< 2107 C, 2108 K: $KeyOf<C>, 2109 K2: $KeyOf<$ValOf<C, K>>, 2110 S: $ValOf<$ValOf<C, K>, K2> 2111 >( 2112 collection: C, 2113 keyPath: [K, K2], 2114 value: S 2115 ): C; 2116 declare function setIn< 2117 C, 2118 K: $KeyOf<C>, 2119 K2: $KeyOf<$ValOf<C, K>>, 2120 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2121 S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> 2122 >( 2123 collection: C, 2124 keyPath: [K, K2, K3], 2125 value: S 2126 ): C; 2127 declare function setIn< 2128 C, 2129 K: $KeyOf<C>, 2130 K2: $KeyOf<$ValOf<C, K>>, 2131 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2132 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2133 S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> 2134 >( 2135 collection: C, 2136 keyPath: [K, K2, K3, K4], 2137 value: S 2138 ): C; 2139 declare function setIn< 2140 C, 2141 K: $KeyOf<C>, 2142 K2: $KeyOf<$ValOf<C, K>>, 2143 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2144 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2145 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, 2146 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> 2147 >( 2148 collection: C, 2149 keyPath: [K, K2, K3, K4, K5], 2150 value: S 2151 ): C; 2152 2153 declare function updateIn<C, S>( 2154 collection: C, 2155 keyPath: [], 2156 notSetValue: mixed, 2157 updater: (value: C) => S 2158 ): S; 2159 declare function updateIn<C, S>( 2160 collection: C, 2161 keyPath: [], 2162 updater: (value: C) => S 2163 ): S; 2164 declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>, NSV>( 2165 collection: C, 2166 keyPath: [K], 2167 notSetValue: NSV, 2168 updater: (value: $ValOf<C, K> | NSV) => S 2169 ): C; 2170 declare function updateIn<C, K: $KeyOf<C>, S: $ValOf<C, K>>( 2171 collection: C, 2172 keyPath: [K], 2173 updater: (value: $ValOf<C, K>) => S 2174 ): C; 2175 declare function updateIn< 2176 C, 2177 K: $KeyOf<C>, 2178 K2: $KeyOf<$ValOf<C, K>>, 2179 S: $ValOf<$ValOf<C, K>, K2>, 2180 NSV 2181 >( 2182 collection: C, 2183 keyPath: [K, K2], 2184 notSetValue: NSV, 2185 updater: (value: $ValOf<$ValOf<C, K>, K2> | NSV) => S 2186 ): C; 2187 declare function updateIn< 2188 C, 2189 K: $KeyOf<C>, 2190 K2: $KeyOf<$ValOf<C, K>>, 2191 S: $ValOf<$ValOf<C, K>, K2> 2192 >( 2193 collection: C, 2194 keyPath: [K, K2], 2195 updater: (value: $ValOf<$ValOf<C, K>, K2>) => S 2196 ): C; 2197 declare function updateIn< 2198 C, 2199 K: $KeyOf<C>, 2200 K2: $KeyOf<$ValOf<C, K>>, 2201 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2202 S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, 2203 NSV 2204 >( 2205 collection: C, 2206 keyPath: [K, K2, K3], 2207 notSetValue: NSV, 2208 updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> | NSV) => S 2209 ): C; 2210 declare function updateIn< 2211 C, 2212 K: $KeyOf<C>, 2213 K2: $KeyOf<$ValOf<C, K>>, 2214 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2215 S: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3> 2216 >( 2217 collection: C, 2218 keyPath: [K, K2, K3], 2219 updater: (value: $ValOf<$ValOf<$ValOf<C, K>, K2>, K3>) => S 2220 ): C; 2221 declare function updateIn< 2222 C, 2223 K: $KeyOf<C>, 2224 K2: $KeyOf<$ValOf<C, K>>, 2225 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2226 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2227 S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, 2228 NSV 2229 >( 2230 collection: C, 2231 keyPath: [K, K2, K3, K4], 2232 notSetValue: NSV, 2233 updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> | NSV) => S 2234 ): C; 2235 declare function updateIn< 2236 C, 2237 K: $KeyOf<C>, 2238 K2: $KeyOf<$ValOf<C, K>>, 2239 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2240 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2241 S: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4> 2242 >( 2243 collection: C, 2244 keyPath: [K, K2, K3, K4], 2245 updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>) => S 2246 ): C; 2247 declare function updateIn< 2248 C, 2249 K: $KeyOf<C>, 2250 K2: $KeyOf<$ValOf<C, K>>, 2251 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2252 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2253 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, 2254 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5>, 2255 NSV 2256 >( 2257 collection: C, 2258 keyPath: [K, K2, K3, K4, K5], 2259 notSetValue: NSV, 2260 updater: ( 2261 value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> | NSV 2262 ) => S 2263 ): C; 2264 declare function updateIn< 2265 C, 2266 K: $KeyOf<C>, 2267 K2: $KeyOf<$ValOf<C, K>>, 2268 K3: $KeyOf<$ValOf<$ValOf<C, K>, K2>>, 2269 K4: $KeyOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>>, 2270 K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>>, 2271 S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> 2272 >( 2273 collection: C, 2274 keyPath: [K, K2, K3, K4, K5], 2275 updater: ( 2276 value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf<C, K>, K2>, K3>, K4>, K5> 2277 ) => S 2278 ): C; 2279 2280 declare function merge<C>( 2281 collection: C, 2282 ...collections: Array< 2283 | $IterableOf<C> 2284 | $Shape<RecordValues<C>> 2285 | PlainObjInput<$KeyOf<C>, $ValOf<C>> 2286 > 2287 ): C; 2288 declare function mergeWith<C>( 2289 merger: (oldVal: $ValOf<C>, newVal: $ValOf<C>, key: $KeyOf<C>) => $ValOf<C>, 2290 collection: C, 2291 ...collections: Array< 2292 | $IterableOf<C> 2293 | $Shape<RecordValues<C>> 2294 | PlainObjInput<$KeyOf<C>, $ValOf<C>> 2295 > 2296 ): C; 2297 declare function mergeDeep<C>( 2298 collection: C, 2299 ...collections: Array< 2300 | $IterableOf<C> 2301 | $Shape<RecordValues<C>> 2302 | PlainObjInput<$KeyOf<C>, $ValOf<C>> 2303 > 2304 ): C; 2305 declare function mergeDeepWith<C>( 2306 merger: (oldVal: any, newVal: any, key: any) => mixed, 2307 collection: C, 2308 ...collections: Array< 2309 | $IterableOf<C> 2310 | $Shape<RecordValues<C>> 2311 | PlainObjInput<$KeyOf<C>, $ValOf<C>> 2312 > 2313 ): C; 2314 2315 export { 2316 Collection, 2317 Seq, 2318 List, 2319 Map, 2320 OrderedMap, 2321 OrderedSet, 2322 Range, 2323 Repeat, 2324 Record, 2325 Set, 2326 Stack, 2327 fromJS, 2328 is, 2329 hash, 2330 isImmutable, 2331 isCollection, 2332 isKeyed, 2333 isIndexed, 2334 isAssociative, 2335 isOrdered, 2336 isRecord, 2337 isValueObject, 2338 get, 2339 has, 2340 remove, 2341 set, 2342 update, 2343 getIn, 2344 hasIn, 2345 removeIn, 2346 setIn, 2347 updateIn, 2348 merge, 2349 mergeWith, 2350 mergeDeep, 2351 mergeDeepWith, 2352 }; 2353 2354 export default { 2355 Collection, 2356 Seq, 2357 2358 List, 2359 Map, 2360 OrderedMap, 2361 OrderedSet, 2362 PairSorting, 2363 Range, 2364 Repeat, 2365 Record, 2366 Set, 2367 Stack, 2368 2369 fromJS, 2370 is, 2371 hash, 2372 2373 isImmutable, 2374 isCollection, 2375 isKeyed, 2376 isIndexed, 2377 isAssociative, 2378 isOrdered, 2379 isRecord, 2380 isValueObject, 2381 2382 get, 2383 has, 2384 remove, 2385 set, 2386 update, 2387 getIn, 2388 hasIn, 2389 removeIn, 2390 setIn, 2391 updateIn, 2392 merge, 2393 mergeWith, 2394 mergeDeep, 2395 mergeDeepWith, 2396 }; 2397 2398 export type { 2399 Comparator, 2400 KeyedCollection, 2401 IndexedCollection, 2402 SetCollection, 2403 KeyedSeq, 2404 IndexedSeq, 2405 SetSeq, 2406 RecordFactory, 2407 RecordOf, 2408 RecordInstance, 2409 ValueObject, 2410 $KeyOf, 2411 $ValOf, 2412 };