• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// @skipLibCheck: true
2// @lib: es6
3// @Filename: complex.ts
4interface Ara<T> { t: T }
5interface Collection<K, V> {
6    map<M>(mapper: (value: V, key: K, iter: this) => M): Collection<K, M>;
7    flatMap<M>(mapper: (value: V, key: K, iter: this) => Ara<M>, context?: any): Collection<K, M>;
8    // these seem necessary to push it over the top for memory usage
9    reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
10    reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
11    toSeq(): Seq<K, V>;
12}
13interface Seq<K, V> extends Collection<K, V> {
14}
15interface N1<T> extends Collection<void, T> {
16    map<M>(mapper: (value: T, key: void, iter: this) => M): N1<M>;
17    flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N1<M>;
18}
19interface N2<T> extends N1<T> {
20    map<M>(mapper: (value: T, key: void, iter: this) => M): N2<M>;
21    flatMap<M>(mapper: (value: T, key: void, iter: this) => Ara<M>, context?: any): N2<M>;
22    toSeq(): N2<T>;
23}
24// @Filename: immutable.ts
25// Test that complex recursive collections can pass the `extends` assignability check without
26// running out of memory. This bug was exposed in Typescript 2.4 when more generic signatures
27// started being checked.
28declare module Immutable {
29  export function fromJS(jsValue: any, reviver?: (key: string | number, sequence: Collection.Keyed<string, any> | Collection.Indexed<any>, path?: Array<string | number>) => any): any;
30  export function is(first: any, second: any): boolean;
31  export function hash(value: any): number;
32  export function isImmutable(maybeImmutable: any): maybeImmutable is Collection<any, any>;
33  export function isCollection(maybeCollection: any): maybeCollection is Collection<any, any>;
34  export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
35  export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
36  export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
37  export function isOrdered(maybeOrdered: any): boolean;
38  export function isValueObject(maybeValue: any): maybeValue is ValueObject;
39  export interface ValueObject {
40    equals(other: any): boolean;
41    hashCode(): number;
42  }
43  export module List {
44    function isList(maybeList: any): maybeList is List<any>;
45    function of<T>(...values: Array<T>): List<T>;
46  }
47  export function List(): List<any>;
48  export function List<T>(): List<T>;
49  export function List<T>(collection: Iterable<T>): List<T>;
50  export interface List<T> extends Collection.Indexed<T> {
51    // Persistent changes
52    set(index: number, value: T): List<T>;
53    delete(index: number): List<T>;
54    remove(index: number): List<T>;
55    insert(index: number, value: T): List<T>;
56    clear(): List<T>;
57    push(...values: Array<T>): List<T>;
58    pop(): List<T>;
59    unshift(...values: Array<T>): List<T>;
60    shift(): List<T>;
61    update(index: number, notSetValue: T, updater: (value: T) => T): this;
62    update(index: number, updater: (value: T) => T): this;
63    update<R>(updater: (value: this) => R): R;
64    merge(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
65    mergeWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
66    mergeDeep(...collections: Array<Collection.Indexed<T> | Array<T>>): this;
67    mergeDeepWith(merger: (oldVal: T, newVal: T, key: number) => T, ...collections: Array<Collection.Indexed<T> | Array<T>>): this;
68    setSize(size: number): List<T>;
69    // Deep persistent changes
70    setIn(keyPath: Iterable<any>, value: any): this;
71    deleteIn(keyPath: Iterable<any>): this;
72    removeIn(keyPath: Iterable<any>): this;
73    updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
74    updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
75    mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
76    mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
77    // Transient changes
78    withMutations(mutator: (mutable: this) => any): this;
79    asMutable(): this;
80    asImmutable(): this;
81    // Sequence algorithms
82    concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): List<T | C>;
83    map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): List<M>;
84    flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): List<M>;
85    filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): List<F>;
86    filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
87  }
88  export module Map {
89    function isMap(maybeMap: any): maybeMap is Map<any, any>;
90    function of(...keyValues: Array<any>): Map<any, any>;
91  }
92  export function Map<K, V>(collection: Iterable<[K, V]>): Map<K, V>;
93  export function Map<T>(collection: Iterable<Iterable<T>>): Map<T, T>;
94  export function Map<V>(obj: {[key: string]: V}): Map<string, V>;
95  export function Map<K, V>(): Map<K, V>;
96  export function Map(): Map<any, any>;
97  export interface Map<K, V> extends Collection.Keyed<K, V> {
98    // Persistent changes
99    set(key: K, value: V): this;
100    delete(key: K): this;
101    remove(key: K): this;
102    deleteAll(keys: Iterable<K>): this;
103    removeAll(keys: Iterable<K>): this;
104    clear(): this;
105    update(key: K, notSetValue: V, updater: (value: V) => V): this;
106    update(key: K, updater: (value: V) => V): this;
107    update<R>(updater: (value: this) => R): R;
108    merge(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
109    mergeWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
110    mergeDeep(...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
111    mergeDeepWith(merger: (oldVal: V, newVal: V, key: K) => V, ...collections: Array<Collection<K, V> | {[key: string]: V}>): this;
112    // Deep persistent changes
113    setIn(keyPath: Iterable<any>, value: any): this;
114    deleteIn(keyPath: Iterable<any>): this;
115    removeIn(keyPath: Iterable<any>): this;
116    updateIn(keyPath: Iterable<any>, notSetValue: any, updater: (value: any) => any): this;
117    updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
118    mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
119    mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
120    // Transient changes
121    withMutations(mutator: (mutable: this) => any): this;
122    asMutable(): this;
123    asImmutable(): this;
124    // Sequence algorithms
125    concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Map<K | KC, V | VC>;
126    concat<C>(...collections: Array<{[key: string]: C}>): Map<K | string, V | C>;
127    map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Map<K, M>;
128    mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Map<M, V>;
129    mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Map<KM, VM>;
130    flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Map<any, any>;
131    filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Map<K, F>;
132    filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
133  }
134  export module OrderedMap {
135    function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap<any, any>;
136  }
137  export function OrderedMap<K, V>(collection: Iterable<[K, V]>): OrderedMap<K, V>;
138  export function OrderedMap<T>(collection: Iterable<Iterable<T>>): OrderedMap<T, T>;
139  export function OrderedMap<V>(obj: {[key: string]: V}): OrderedMap<string, V>;
140  export function OrderedMap<K, V>(): OrderedMap<K, V>;
141  export function OrderedMap(): OrderedMap<any, any>;
142  export interface OrderedMap<K, V> extends Map<K, V> {
143    // Sequence algorithms
144    concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): OrderedMap<K | KC, V | VC>;
145    concat<C>(...collections: Array<{[key: string]: C}>): OrderedMap<K | string, V | C>;
146    map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): OrderedMap<K, M>;
147    mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): OrderedMap<M, V>;
148    mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): OrderedMap<KM, VM>;
149    flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): OrderedMap<any, any>;
150    filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): OrderedMap<K, F>;
151    filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
152  }
153  export module Set {
154    function isSet(maybeSet: any): maybeSet is Set<any>;
155    function of<T>(...values: Array<T>): Set<T>;
156    function fromKeys<T>(iter: Collection<T, any>): Set<T>;
157    function fromKeys(obj: {[key: string]: any}): Set<string>;
158    function intersect<T>(sets: Iterable<Iterable<T>>): Set<T>;
159    function union<T>(sets: Iterable<Iterable<T>>): Set<T>;
160  }
161  export function Set(): Set<any>;
162  export function Set<T>(): Set<T>;
163  export function Set<T>(collection: Iterable<T>): Set<T>;
164  export interface Set<T> extends Collection.Set<T> {
165    // Persistent changes
166    add(value: T): this;
167    delete(value: T): this;
168    remove(value: T): this;
169    clear(): this;
170    union(...collections: Array<Collection<any, T> | Array<T>>): this;
171    merge(...collections: Array<Collection<any, T> | Array<T>>): this;
172    intersect(...collections: Array<Collection<any, T> | Array<T>>): this;
173    subtract(...collections: Array<Collection<any, T> | Array<T>>): this;
174    // Transient changes
175    withMutations(mutator: (mutable: this) => any): this;
176    asMutable(): this;
177    asImmutable(): this;
178    // Sequence algorithms
179    concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Set<T | C>;
180    map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Set<M>;
181    flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Set<M>;
182    filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Set<F>;
183    filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
184  }
185  export module OrderedSet {
186    function isOrderedSet(maybeOrderedSet: any): boolean;
187    function of<T>(...values: Array<T>): OrderedSet<T>;
188    function fromKeys<T>(iter: Collection<T, any>): OrderedSet<T>;
189    function fromKeys(obj: {[key: string]: any}): OrderedSet<string>;
190  }
191  export function OrderedSet(): OrderedSet<any>;
192  export function OrderedSet<T>(): OrderedSet<T>;
193  export function OrderedSet<T>(collection: Iterable<T>): OrderedSet<T>;
194  export interface OrderedSet<T> extends Set<T> {
195    // Sequence algorithms
196    concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): OrderedSet<T | C>;
197    map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): OrderedSet<M>;
198    flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): OrderedSet<M>;
199    filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): OrderedSet<F>;
200    filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
201    zip(...collections: Array<Collection<any, any>>): OrderedSet<any>;
202    zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): OrderedSet<Z>;
203    zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): OrderedSet<Z>;
204    zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): OrderedSet<Z>;
205  }
206  export module Stack {
207    function isStack(maybeStack: any): maybeStack is Stack<any>;
208    function of<T>(...values: Array<T>): Stack<T>;
209  }
210  export function Stack(): Stack<any>;
211  export function Stack<T>(): Stack<T>;
212  export function Stack<T>(collection: Iterable<T>): Stack<T>;
213  export interface Stack<T> extends Collection.Indexed<T> {
214    // Reading values
215    peek(): T | undefined;
216    // Persistent changes
217    clear(): Stack<T>;
218    unshift(...values: Array<T>): Stack<T>;
219    unshiftAll(iter: Iterable<T>): Stack<T>;
220    shift(): Stack<T>;
221    push(...values: Array<T>): Stack<T>;
222    pushAll(iter: Iterable<T>): Stack<T>;
223    pop(): Stack<T>;
224    // Transient changes
225    withMutations(mutator: (mutable: this) => any): this;
226    asMutable(): this;
227    asImmutable(): this;
228    // Sequence algorithms
229    concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Stack<T | C>;
230    map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Stack<M>;
231    flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Stack<M>;
232    filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Set<F>;
233    filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
234  }
235  export function Range(start?: number, end?: number, step?: number): Seq.Indexed<number>;
236  export function Repeat<T>(value: T, times?: number): Seq.Indexed<T>;
237  export module Record {
238    export function isRecord(maybeRecord: any): maybeRecord is Record.Instance<any>;
239    export function getDescriptiveName(record: Instance<any>): string;
240    export interface Class<T extends Object> {
241      (values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
242      new (values?: Partial<T> | Iterable<[string, any]>): Instance<T> & Readonly<T>;
243    }
244    export interface Instance<T extends Object> {
245      readonly size: number;
246      // Reading values
247      has(key: string): boolean;
248      get<K extends keyof T>(key: K): T[K];
249      // Reading deep values
250      hasIn(keyPath: Iterable<any>): boolean;
251      getIn(keyPath: Iterable<any>): any;
252      // Value equality
253      equals(other: any): boolean;
254      hashCode(): number;
255      // Persistent changes
256      set<K extends keyof T>(key: K, value: T[K]): this;
257      update<K extends keyof T>(key: K, updater: (value: T[K]) => T[K]): this;
258      merge(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
259      mergeDeep(...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
260      mergeWith(merger: (oldVal: any, newVal: any, key: keyof T) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
261      mergeDeepWith(merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array<Partial<T> | Iterable<[string, any]>>): this;
262      delete<K extends keyof T>(key: K): this;
263      remove<K extends keyof T>(key: K): this;
264      clear(): this;
265      // Deep persistent changes
266      setIn(keyPath: Iterable<any>, value: any): this;
267      updateIn(keyPath: Iterable<any>, updater: (value: any) => any): this;
268      mergeIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
269      mergeDeepIn(keyPath: Iterable<any>, ...collections: Array<any>): this;
270      deleteIn(keyPath: Iterable<any>): this;
271      removeIn(keyPath: Iterable<any>): this;
272      // Conversion to JavaScript types
273      toJS(): { [K in keyof T]: any };
274      toJSON(): T;
275      toObject(): T;
276      // Transient changes
277      withMutations(mutator: (mutable: this) => any): this;
278      asMutable(): this;
279      asImmutable(): this;
280      // Sequence algorithms
281      toSeq(): Seq.Keyed<keyof T, T[keyof T]>;
282      [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
283    }
284  }
285  export function Record<T>(defaultValues: T, name?: string): Record.Class<T>;
286  export module Seq {
287    function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed<any> | Seq.Keyed<any, any>;
288    function of<T>(...values: Array<T>): Seq.Indexed<T>;
289    export module Keyed {}
290    export function Keyed<K, V>(collection: Iterable<[K, V]>): Seq.Keyed<K, V>;
291    export function Keyed<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
292    export function Keyed<K, V>(): Seq.Keyed<K, V>;
293    export function Keyed(): Seq.Keyed<any, any>;
294    export interface Keyed<K, V> extends Seq<K, V>, Collection.Keyed<K, V> {
295      toJS(): Object;
296      toJSON(): { [key: string]: V };
297      toSeq(): this;
298      concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Seq.Keyed<K | KC, V | VC>;
299      concat<C>(...collections: Array<{[key: string]: C}>): Seq.Keyed<K | string, V | C>;
300      map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq.Keyed<K, M>;
301      mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Seq.Keyed<M, V>;
302      mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Seq.Keyed<KM, VM>;
303      flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq.Keyed<any, any>;
304      filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq.Keyed<K, F>;
305      filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
306    }
307    module Indexed {
308      function of<T>(...values: Array<T>): Seq.Indexed<T>;
309    }
310    export function Indexed(): Seq.Indexed<any>;
311    export function Indexed<T>(): Seq.Indexed<T>;
312    export function Indexed<T>(collection: Iterable<T>): Seq.Indexed<T>;
313    export interface Indexed<T> extends Seq<number, T>, Collection.Indexed<T> {
314      toJS(): Array<any>;
315      toJSON(): Array<T>;
316      toSeq(): this;
317      concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Indexed<T | C>;
318      map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Seq.Indexed<M>;
319      flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Seq.Indexed<M>;
320      filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Seq.Indexed<F>;
321      filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
322    }
323    export module Set {
324      function of<T>(...values: Array<T>): Seq.Set<T>;
325    }
326    export function Set(): Seq.Set<any>;
327    export function Set<T>(): Seq.Set<T>;
328    export function Set<T>(collection: Iterable<T>): Seq.Set<T>;
329    export interface Set<T> extends Seq<never, T>, Collection.Set<T> {
330      toJS(): Array<any>;
331      toJSON(): Array<T>;
332      toSeq(): this;
333      concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Seq.Set<T | C>;
334      map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Seq.Set<M>;
335      flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any): Seq.Set<M>;
336      filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Seq.Set<F>;
337      filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
338    }
339  }
340  export function Seq<S extends Seq<any, any>>(seq: S): S;
341  export function Seq<K, V>(collection: Collection.Keyed<K, V>): Seq.Keyed<K, V>;
342  export function Seq<T>(collection: Collection.Indexed<T>): Seq.Indexed<T>;
343  export function Seq<T>(collection: Collection.Set<T>): Seq.Set<T>;
344  export function Seq<T>(collection: Iterable<T>): Seq.Indexed<T>;
345  export function Seq<V>(obj: {[key: string]: V}): Seq.Keyed<string, V>;
346  export function Seq(): Seq<any, any>;
347  export interface Seq<K, V> extends Collection<K, V> {
348    readonly size: number | undefined;
349    // Force evaluation
350    cacheResult(): this;
351    // Sequence algorithms
352    map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Seq<K, M>;
353    flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Seq<K, M>;
354    filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Seq<K, F>;
355    filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
356  }
357  export module Collection {
358    function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed<any, any>;
359    function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed<any>;
360    function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed<any, any> | Collection.Indexed<any>;
361    function isOrdered(maybeOrdered: any): boolean;
362    export module Keyed {}
363    export function Keyed<K, V>(collection: Iterable<[K, V]>): Collection.Keyed<K, V>;
364    export function Keyed<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
365    export interface Keyed<K, V> extends Collection<K, V> {
366      toJS(): Object;
367      toJSON(): { [key: string]: V };
368      toSeq(): Seq.Keyed<K, V>;
369      // Sequence functions
370      flip(): this;
371      concat<KC, VC>(...collections: Array<Iterable<[KC, VC]>>): Collection.Keyed<K | KC, V | VC>;
372      concat<C>(...collections: Array<{[key: string]: C}>): Collection.Keyed<K | string, V | C>;
373      map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection.Keyed<K, M>;
374      mapKeys<M>(mapper: (key: K, value: V, iter: this) => M, context?: any): Collection.Keyed<M, V>;
375      mapEntries<KM, VM>(mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], context?: any): Collection.Keyed<KM, VM>;
376      flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection.Keyed<any, any>;
377      filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection.Keyed<K, F>;
378      filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
379      [Symbol.iterator](): IterableIterator<[K, V]>;
380    }
381    export module Indexed {}
382    export function Indexed<T>(collection: Iterable<T>): Collection.Indexed<T>;
383    export interface Indexed<T> extends Collection<number, T> {
384      toJS(): Array<any>;
385      toJSON(): Array<T>;
386      // Reading values
387      get<NSV>(index: number, notSetValue: NSV): T | NSV;
388      get(index: number): T | undefined;
389      // Conversion to Seq
390      toSeq(): Seq.Indexed<T>;
391      fromEntrySeq(): Seq.Keyed<any, any>;
392      // Combination
393      interpose(separator: T): this;
394      interleave(...collections: Array<Collection<any, T>>): this;
395      splice(index: number, removeNum: number, ...values: Array<T>): this;
396      zip(...collections: Array<Collection<any, any>>): Collection.Indexed<any>;
397      zipWith<U, Z>(zipper: (value: T, otherValue: U) => Z, otherCollection: Collection<any, U>): Collection.Indexed<Z>;
398      zipWith<U, V, Z>(zipper: (value: T, otherValue: U, thirdValue: V) => Z, otherCollection: Collection<any, U>, thirdCollection: Collection<any, V>): Collection.Indexed<Z>;
399      zipWith<Z>(zipper: (...any: Array<any>) => Z, ...collections: Array<Collection<any, any>>): Collection.Indexed<Z>;
400      // Search for value
401      indexOf(searchValue: T): number;
402      lastIndexOf(searchValue: T): number;
403      findIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
404      findLastIndex(predicate: (value: T, index: number, iter: this) => boolean, context?: any): number;
405      // Sequence algorithms
406      concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Indexed<T | C>;
407      map<M>(mapper: (value: T, key: number, iter: this) => M, context?: any): Collection.Indexed<M>;
408      flatMap<M>(mapper: (value: T, key: number, iter: this) => Iterable<M>, context?: any): Collection.Indexed<M>;
409      filter<F extends T>(predicate: (value: T, index: number, iter: this) => value is F, context?: any): Collection.Indexed<F>;
410      filter(predicate: (value: T, index: number, iter: this) => any, context?: any): this;
411      [Symbol.iterator](): IterableIterator<T>;
412    }
413    export module Set {}
414    export function Set<T>(collection: Iterable<T>): Collection.Set<T>;
415    export interface Set<T> extends Collection<never, T> {
416      toJS(): Array<any>;
417      toJSON(): Array<T>;
418      toSeq(): Seq.Set<T>;
419      // Sequence algorithms
420      concat<C>(...valuesOrCollections: Array<Iterable<C> | C>): Collection.Set<T | C>;
421      map<M>(mapper: (value: T, key: never, iter: this) => M, context?: any): Collection.Set<M>;
422      flatMap<M>(mapper: (value: T, key: never, iter: this) => Iterable<M>, context?: any):  Collection.Set<M>;
423      filter<F extends T>(predicate: (value: T, key: never, iter: this) => value is F, context?: any): Collection.Set<F>;
424      filter(predicate: (value: T, key: never, iter: this) => any, context?: any): this;
425      [Symbol.iterator](): IterableIterator<T>;
426    }
427  }
428  export function Collection<I extends Collection<any, any>>(collection: I): I;
429  export function Collection<T>(collection: Iterable<T>): Collection.Indexed<T>;
430  export function Collection<V>(obj: {[key: string]: V}): Collection.Keyed<string, V>;
431  export interface Collection<K, V> extends ValueObject {
432    // Value equality
433    equals(other: any): boolean;
434    hashCode(): number;
435    // Reading values
436    get<NSV>(key: K, notSetValue: NSV): V | NSV;
437    get(key: K): V | undefined;
438    has(key: K): boolean;
439    includes(value: V): boolean;
440    contains(value: V): boolean;
441    first(): V | undefined;
442    last(): V | undefined;
443    // Reading deep values
444    getIn(searchKeyPath: Iterable<any>, notSetValue?: any): any;
445    hasIn(searchKeyPath: Iterable<any>): boolean;
446    // Persistent changes
447    update<R>(updater: (value: this) => R): R;
448    // Conversion to JavaScript types
449    toJS(): Array<any> | { [key: string]: any };
450    toJSON(): Array<V> | { [key: string]: V };
451    toArray(): Array<V>;
452    toObject(): { [key: string]: V };
453    // Conversion to Collections
454    toMap(): Map<K, V>;
455    toOrderedMap(): OrderedMap<K, V>;
456    toSet(): Set<V>;
457    toOrderedSet(): OrderedSet<V>;
458    toList(): List<V>;
459    toStack(): Stack<V>;
460    // Conversion to Seq
461    toSeq(): this;
462    toKeyedSeq(): Seq.Keyed<K, V>;
463    toIndexedSeq(): Seq.Indexed<V>;
464    toSetSeq(): Seq.Set<V>;
465    // Iterators
466    keys(): IterableIterator<K>;
467    values(): IterableIterator<V>;
468    entries(): IterableIterator<[K, V]>;
469    // Collections (Seq)
470    keySeq(): Seq.Indexed<K>;
471    valueSeq(): Seq.Indexed<V>;
472    entrySeq(): Seq.Indexed<[K, V]>;
473    // Sequence algorithms
474    map<M>(mapper: (value: V, key: K, iter: this) => M, context?: any): Collection<K, M>;
475    filter<F extends V>(predicate: (value: V, key: K, iter: this) => value is F, context?: any): Collection<K, F>;
476    filter(predicate: (value: V, key: K, iter: this) => any, context?: any): this;
477    filterNot(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
478    reverse(): this;
479    sort(comparator?: (valueA: V, valueB: V) => number): this;
480    sortBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): this;
481    groupBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): /*Map*/Seq.Keyed<G, /*this*/Collection<K, V>>;
482    // Side effects
483    forEach(sideEffect: (value: V, key: K, iter: this) => any, context?: any): number;
484    // Creating subsets
485    slice(begin?: number, end?: number): this;
486    rest(): this;
487    butLast(): this;
488    skip(amount: number): this;
489    skipLast(amount: number): this;
490    skipWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
491    skipUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
492    take(amount: number): this;
493    takeLast(amount: number): this;
494    takeWhile(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
495    takeUntil(predicate: (value: V, key: K, iter: this) => boolean, context?: any): this;
496    // Combination
497    concat(...valuesOrCollections: Array<any>): Collection<any, any>;
498    flatten(depth?: number): Collection<any, any>;
499    flatten(shallow?: boolean): Collection<any, any>;
500    flatMap<M>(mapper: (value: V, key: K, iter: this) => Iterable<M>, context?: any): Collection<K, M>;
501    // Reducing a value
502    reduce<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
503    reduce<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
504    reduceRight<R>(reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, context?: any): R;
505    reduceRight<R>(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R;
506    every(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
507    some(predicate: (value: V, key: K, iter: this) => boolean, context?: any): boolean;
508    join(separator?: string): string;
509    isEmpty(): boolean;
510    count(): number;
511    count(predicate: (value: V, key: K, iter: this) => boolean, context?: any): number;
512    countBy<G>(grouper: (value: V, key: K, iter: this) => G, context?: any): Map<G, number>;
513    // Search for value
514    find(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
515    findLast(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): V | undefined;
516    findEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
517    findLastEntry(predicate: (value: V, key: K, iter: this) => boolean, context?: any, notSetValue?: V): [K, V] | undefined;
518    findKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
519    findLastKey(predicate: (value: V, key: K, iter: this) => boolean, context?: any): K | undefined;
520    keyOf(searchValue: V): K | undefined;
521    lastKeyOf(searchValue: V): K | undefined;
522    max(comparator?: (valueA: V, valueB: V) => number): V | undefined;
523    maxBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
524    min(comparator?: (valueA: V, valueB: V) => number): V | undefined;
525    minBy<C>(comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number): V | undefined;
526    // Comparison
527    isSubset(iter: Iterable<V>): boolean;
528    isSuperset(iter: Iterable<V>): boolean;
529    readonly size: number;
530  }
531}
532declare module "immutable" {
533  export = Immutable
534}
535