28
28
* Note that Immutable values implement the `ESIterable` interface.
29
29
*/
30
30
type ESIterable<T> = $Iterable<T,void,void>;
31
- type booleany = any;
32
31
33
- declare class Iterable<K,V> {
34
- static Keyed: Class<Object>;
35
- static Indexed: Class<Object>;
36
- static Set: Class<Object>;
32
+ declare class Iterable<K, V> extends _Iterable<K, V, typeof KeyedIterable, typeof IndexedIterable, typeof SetIterable> {}
33
+
34
+ declare class _Iterable<K,V, KI, II, SI> {
35
+ static Keyed: KI;
36
+ static Indexed: II;
37
+ static Set: SI;
37
38
38
39
static isIterable(maybeIterable: any): boolean;
39
40
static isKeyed(maybeKeyed: any): boolean;
@@ -78,12 +79,12 @@ declare class Iterable<K,V> {
78
79
entrySeq(): IndexedSeq<[K,V]>;
79
80
80
81
filter(
81
- predicate: (value: V, key: K, iter: this) => booleany ,
82
+ predicate: (value: V, key: K, iter: this) => mixed ,
82
83
context?: any
83
84
): this;
84
85
85
86
filterNot(
86
- predicate: (value: V, key: K, iter: this) => booleany ,
87
+ predicate: (value: V, key: K, iter: this) => mixed ,
87
88
context?: any
88
89
): this;
89
90
@@ -110,12 +111,12 @@ declare class Iterable<K,V> {
110
111
butLast(): this;
111
112
skip(amount: number): this;
112
113
skipLast(amount: number): this;
113
- skipWhile(predicate: (value: V, key: K, iter: this) => booleany , context?: any): this;
114
- skipUntil(predicate: (value: V, key: K, iter: this) => booleany , context?: any): this;
114
+ skipWhile(predicate: (value: V, key: K, iter: this) => mixed , context?: any): this;
115
+ skipUntil(predicate: (value: V, key: K, iter: this) => mixed , context?: any): this;
115
116
take(amount: number): this;
116
117
takeLast(amount: number): this;
117
- takeWhile(predicate: (value: V, key: K, iter: this) => booleany , context?: any): this;
118
- takeUntil(predicate: (value: V, key: K, iter: this) => booleany , context?: any): this;
118
+ takeWhile(predicate: (value: V, key: K, iter: this) => mixed , context?: any): this;
119
+ takeUntil(predicate: (value: V, key: K, iter: this) => mixed , context?: any): this;
119
120
flatten(depth?: number): /*this*/Iterable<any,any>;
120
121
flatten(shallow?: boolean): /*this*/Iterable<any,any>;
121
122
@@ -131,35 +132,35 @@ declare class Iterable<K,V> {
131
132
context?: any,
132
133
): R;
133
134
134
- every(predicate: (value: V, key: K, iter: this) => booleany , context?: any): boolean;
135
- some(predicate: (value: V, key: K, iter: this) => booleany , context?: any): boolean;
135
+ every(predicate: (value: V, key: K, iter: this) => mixed , context?: any): boolean;
136
+ some(predicate: (value: V, key: K, iter: this) => mixed , context?: any): boolean;
136
137
join(separator?: string): string;
137
138
isEmpty(): boolean;
138
- count(predicate?: (value: V, key: K, iter: this) => booleany , context?: any): number;
139
+ count(predicate?: (value: V, key: K, iter: this) => mixed , context?: any): number;
139
140
countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G,number>;
140
141
141
142
find<V_>(
142
- predicate: (value: V, key: K, iter: this) => booleany ,
143
+ predicate: (value: V, key: K, iter: this) => mixed ,
143
144
context: any,
144
145
notSetValue: V_
145
146
): V|V_;
146
147
find<V_>(
147
- predicate: (value: V, key: K, iter: this) => booleany ,
148
+ predicate: (value: V, key: K, iter: this) => mixed ,
148
149
context?: any,
149
150
): ?V;
150
151
151
152
findLast<V_>(
152
- predicate: (value: V, key: K, iter: this) => booleany ,
153
+ predicate: (value: V, key: K, iter: this) => mixed ,
153
154
context: any,
154
155
notSetValue: V_
155
156
): V|V_;
156
157
findLast<V_>(
157
- predicate: (value: V, key: K, iter: this) => booleany ,
158
+ predicate: (value: V, key: K, iter: this) => mixed ,
158
159
context?: any,
159
160
): ?V;
160
161
161
- findEntry(predicate: (value: V, key: K, iter: this) => booleany ): ?[K,V];
162
- findLastEntry(predicate: (value: V, key: K, iter: this) => booleany ): ?[K,V];
162
+ findEntry(predicate: (value: V, key: K, iter: this) => mixed ): ?[K,V];
163
+ findLastEntry(predicate: (value: V, key: K, iter: this) => mixed ): ?[K,V];
163
164
164
165
max(comparator?: (valueA: V, valueB: V) => number): V;
165
166
maxBy<C>(
@@ -198,8 +199,8 @@ declare class KeyedIterable<K,V> extends Iterable<K,V> {
198
199
199
200
keyOf(searchValue: V): ?K;
200
201
lastKeyOf(searchValue: V): ?K;
201
- findKey(predicate: (value: V, key: K, iter: this) => booleany , context?: any): ?K;
202
- findLastKey(predicate: (value: V, key: K, iter: this) => booleany , context?: any): ?K;
202
+ findKey(predicate: (value: V, key: K, iter: this) => mixed , context?: any): ?K;
203
+ findLastKey(predicate: (value: V, key: K, iter: this) => mixed , context?: any): ?K;
203
204
204
205
concat(...iters: ESIterable<[K,V]>[]): this;
205
206
@@ -298,11 +299,11 @@ declare class IndexedIterable<T> extends Iterable<number,T> {
298
299
indexOf(searchValue: T): number;
299
300
lastIndexOf(searchValue: T): number;
300
301
findIndex(
301
- predicate: (value: T, index: number, iter: this) => booleany ,
302
+ predicate: (value: T, index: number, iter: this) => mixed ,
302
303
context?: any
303
304
): number;
304
305
findLastIndex(
305
- predicate: (value: T, index: number, iter: this) => booleany ,
306
+ predicate: (value: T, index: number, iter: this) => mixed ,
306
307
context?: any
307
308
): number;
308
309
@@ -342,11 +343,7 @@ declare class SetIterable<T> extends Iterable<T,T> {
342
343
): /*this*/SetIterable<U>;
343
344
}
344
345
345
- declare class Collection<K,V> extends Iterable<K,V> {
346
- static Keyed: Class<Object>;
347
- static Indexed: Class<Object>;
348
- static Set: Class<Object>;
349
-
346
+ declare class Collection<K,V> extends _Iterable<K,V, typeof KeyedCollection, typeof IndexedCollection, typeof SetCollection> {
350
347
size: number;
351
348
}
352
349
@@ -362,11 +359,7 @@ declare class SetCollection<T> extends Collection<T,T> mixins SetIterable<T> {
362
359
toSeq(): SetSeq<T>;
363
360
}
364
361
365
- declare class Seq<K,V> extends Iterable<K,V> {
366
- static Keyed: Class<Object>;
367
- static Indexed: Class<Object>;
368
- static Set: Class<Object>;
369
-
362
+ declare class Seq<K,V> extends _Iterable<K,V, typeof KeyedSeq, typeof IndexedSeq, typeof SetSeq> {
370
363
static <K,V>(iter: KeyedSeq<K,V>): KeyedSeq<K,V>;
371
364
static <T> (iter: SetSeq<T>): SetSeq<K,V>;
372
365
static <T> (iter?: ESIterable<T>): IndexedSeq<T>;
@@ -524,8 +517,9 @@ declare class Map<K,V> extends KeyedCollection<K,V> {
524
517
): Map<K_,V>;
525
518
}
526
519
520
+ // OrderedMaps have nothing that Maps do not have. We do not need to override constructor & other statics
527
521
declare class OrderedMap<K,V> extends Map<K,V> {
528
- // TODO: can we just use the inherited constructor?
522
+ static isOrderedMap(maybeOrderedMap: any): bool;
529
523
}
530
524
531
525
declare class Set<T> extends SetCollection<T> {
@@ -562,7 +556,10 @@ declare class Set<T> extends SetCollection<T> {
562
556
): Set<M>;
563
557
}
564
558
565
- declare class OrderedSet<T> extends Set<T> {}
559
+ // OrderedSets have nothing that Sets do not have. We do not need to override constructor & other statics
560
+ declare class OrderedSet<T> extends Set<T> {
561
+ static isOrderedSet(maybeOrderedSet: any): bool;
562
+ }
566
563
567
564
declare class Stack<T> extends IndexedCollection<T> {
568
565
static <T>(iterable?: ESIterable<T>): Stack<T>;
@@ -599,11 +596,13 @@ declare class Stack<T> extends IndexedCollection<T> {
599
596
declare function Range(start?: number, end?: number, step?: number): IndexedSeq<number>;
600
597
declare function Repeat<T>(value: T, times?: number): IndexedSeq<T>;
601
598
602
- declare class Record<T:Object> {
603
- static <T:Object>(spec: T, name?: string): (values: $Shape<T>) => (T & Record<T>);
599
+ //TODO: Once flow can extend normal Objects we can change this back to actually reflect Record behavior.
600
+ // For now fallback to any to not break existing Code
601
+ declare class Record<T: Object> {
602
+ static <T: Object>(spec: T, name?: string): /*T & Record<T>*/any;
604
603
get<A>(key: $Keys<T>): A;
605
- set<A>(key: $Keys<T>, value: A): T & Record<T>;
606
- remove(key: $Keys<T>): T & Record<T>;
604
+ set<A>(key: $Keys<T>, value: A): /* T & Record<T>*/this ;
605
+ remove(key: $Keys<T>): /* T & Record<T>*/this ;
607
606
}
608
607
609
608
declare function fromJS(json: Object, reviver?: (k: any, v: Iterable<any,any>) => any): any;
0 commit comments