diff --git a/type-definitions/immutable.js.flow b/type-definitions/immutable.js.flow index c94708ee7..3cb684496 100644 --- a/type-definitions/immutable.js.flow +++ b/type-definitions/immutable.js.flow @@ -29,9 +29,9 @@ */ type ESIterable = $Iterable; -declare class Iterable extends _Iterable {} +declare class Iterable extends _Iterable {} -declare class _Iterable { +declare class _Iterable { static Keyed: KI; static Indexed: II; static Set: SI; @@ -44,8 +44,8 @@ declare class _Iterable { equals(other: Iterable): boolean; hashCode(): number; + get(key: K): V; get(key: K, notSetValue: V_): V|V_; - get(key: K): ?V; has(key: K): boolean; includes(value: V): boolean; contains(value: V): boolean; @@ -53,7 +53,7 @@ declare class _Iterable { last(): V; getIn(searchKeyPath: ESIterable, notSetValue: T): T; - getIn(searchKeyPath: ESIterable): ?T; + getIn(searchKeyPath: ESIterable): T; hasIn(searchKeyPath: ESIterable): boolean; toJS(): any; @@ -78,16 +78,6 @@ declare class _Iterable { valueSeq(): IndexedSeq; entrySeq(): IndexedSeq<[K,V]>; - filter( - predicate: (value: V, key: K, iter: this) => mixed, - context?: any - ): this; - - filterNot( - predicate: (value: V, key: K, iter: this) => mixed, - context?: any - ): this; - reverse(): this; sort(comparator?: (valueA: V, valueB: V) => number): this; @@ -120,6 +110,16 @@ declare class _Iterable { flatten(depth?: number): /*this*/Iterable; flatten(shallow?: boolean): /*this*/Iterable; + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: any + ): this; + + filterNot( + predicate: (value: V, key: K, iter: this) => mixed, + context?: any + ): this; + reduce( reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction?: R, @@ -139,25 +139,26 @@ declare class _Iterable { count(predicate?: (value: V, key: K, iter: this) => mixed, context?: any): number; countBy(grouper: (value: V, key: K, iter: this) => G, context?: any): Map; + find( + predicate: (value: V, key: K, iter: this) => mixed, + context?: any, + ): ?V; find( predicate: (value: V, key: K, iter: this) => mixed, context: any, notSetValue: V_ ): V|V_; - find( + + findLast( predicate: (value: V, key: K, iter: this) => mixed, context?: any, ): ?V; - findLast( predicate: (value: V, key: K, iter: this) => mixed, context: any, notSetValue: V_ ): V|V_; - findLast( - predicate: (value: V, key: K, iter: this) => mixed, - context?: any, - ): ?V; + findEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V]; findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): ?[K,V]; @@ -214,6 +215,9 @@ declare class KeyedIterable extends Iterable { mapper: (value: V, key: K, iter: this) => ESIterable<[K_,V_]>, context?: any ): /*this*/KeyedIterable; + + flatten(depth?: number): /*this*/KeyedIterable; + flatten(shallow?: boolean): /*this*/KeyedIterable; } declare class IndexedIterable extends Iterable { @@ -319,6 +323,9 @@ declare class IndexedIterable extends Iterable { mapper: (value: T, index: number, iter: this) => ESIterable, context?: any ): /*this*/IndexedIterable; + + flatten(depth?: number): /*this*/IndexedIterable; + flatten(shallow?: boolean): /*this*/IndexedIterable; } declare class SetIterable extends Iterable { @@ -342,9 +349,12 @@ declare class SetIterable extends Iterable { mapper: (value: T, value: T, iter: this) => ESIterable, context?: any ): /*this*/SetIterable; + + flatten(depth?: number): /*this*/SetIterable; + flatten(shallow?: boolean): /*this*/SetIterable; } -declare class Collection extends _Iterable { +declare class Collection extends _Iterable { size: number; } @@ -390,7 +400,7 @@ declare class SetSeq extends Seq mixins SetIterable { } declare class List extends IndexedCollection { - static (iterable?: ESIterable): List; + static (iterable?: ESIterable): List; static isList(maybeList: any): boolean; static of(...values: T[]): List; @@ -439,7 +449,6 @@ declare class List extends IndexedCollection { asImmutable(): this; // Overrides that specialize return types - map( mapper: (value: T, index: number, iter: this) => M, context?: any @@ -449,15 +458,19 @@ declare class List extends IndexedCollection { mapper: (value: T, index: number, iter: this) => ESIterable, context?: any ): List; + + flatten(depth?: number): /*this*/List; + flatten(shallow?: boolean): /*this*/List; } declare class Map extends KeyedCollection { + static (): Map; static (obj?: {[key: string]: V}): Map; static (iterable?: ESIterable<[K,V]>): Map; static isMap(maybeMap: any): boolean; - set(key: K_, value: V_): Map; + set(key: K_, value: V_): Map; delete(key: K): this; remove(key: K): this; clear(): this; @@ -516,6 +529,9 @@ declare class Map extends KeyedCollection { mapper: (key: K, value: V, iter: this) => K_, context?: any ): Map; + + flatten(depth?: number): /*this*/Map; + flatten(shallow?: boolean): /*this*/Map; } // OrderedMaps have nothing that Maps do not have. We do not need to override constructor & other statics @@ -555,6 +571,9 @@ declare class Set extends SetCollection { mapper: (value: T, value: T, iter: this) => ESIterable, context?: any ): Set; + + flatten(depth?: number): /*this*/Set; + flatten(shallow?: boolean): /*this*/Set; } // OrderedSets have nothing that Sets do not have. We do not need to override constructor & other statics @@ -592,6 +611,9 @@ declare class Stack extends IndexedCollection { mapper: (value: T, index: number, iter: this) => ESIterable, context?: any ): Stack; + + flatten(depth?: number): /*this*/Stack; + flatten(shallow?: boolean): /*this*/Stack; } declare function Range(start?: number, end?: number, step?: number): IndexedSeq;