diff --git a/type-definitions/immutable.d.ts b/type-definitions/immutable.d.ts index 5882a7b0e..abf285e93 100644 --- a/type-definitions/immutable.d.ts +++ b/type-definitions/immutable.d.ts @@ -215,7 +215,9 @@ declare namespace Immutable { */ function List(collection?: Iterable | ArrayLike): List; - interface List extends Collection.Indexed { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface List = List> + extends Collection.Indexed { /** * The number of items in this List. */ @@ -502,7 +504,7 @@ declare namespace Immutable { filter( predicate: (value: T, index: number, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new List with the values for which the `predicate` @@ -718,7 +720,9 @@ declare namespace Immutable { ? P : RetrievePathReducer, Tail

>; - interface Map extends Collection.Keyed { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Map = Map> + extends Collection.Keyed { /** * The number of entries in this Map. */ @@ -1103,7 +1107,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new Map with the values for which the `predicate` @@ -1143,7 +1147,7 @@ declare namespace Immutable { * * Note: This is always an eager operation. */ - sort(comparator?: Comparator): this & OrderedMap; + sort(comparator?: Comparator): Self & OrderedMap; /** * Like `sort`, but also accepts a `comparatorValueMapper` which allows for @@ -1157,7 +1161,7 @@ declare namespace Immutable { sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: (valueA: C, valueB: C) => number - ): this & OrderedMap; + ): Self & OrderedMap; } /** @@ -1198,7 +1202,13 @@ declare namespace Immutable { function OrderedMap(collection?: Iterable<[K, V]>): OrderedMap; function OrderedMap(obj: { [key: string]: V }): OrderedMap; - interface OrderedMap extends Map, OrderedCollection<[K, V]> { + interface OrderedMap< + K, + V, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Self extends OrderedMap = OrderedMap, + > extends Map, + OrderedCollection<[K, V]> { /** * The number of entries in this OrderedMap. */ @@ -1316,7 +1326,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new OrderedMap with the values for which the `predicate` @@ -1407,7 +1417,9 @@ declare namespace Immutable { */ function Set(collection?: Iterable | ArrayLike): Set; - interface Set extends Collection.Set { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Set = Set> + extends Collection.Set { /** * The number of items in this Set. */ @@ -1537,7 +1549,7 @@ declare namespace Immutable { filter( predicate: (value: T, key: T, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new Set with the values for which the `predicate` function @@ -1572,7 +1584,7 @@ declare namespace Immutable { * * Note: This is always an eager operation. */ - sort(comparator?: Comparator): this & OrderedSet; + sort(comparator?: Comparator): Self & OrderedSet; /** * Like `sort`, but also accepts a `comparatorValueMapper` which allows for @@ -1586,7 +1598,7 @@ declare namespace Immutable { sortBy( comparatorValueMapper: (value: T, key: T, iter: this) => C, comparator?: (valueA: C, valueB: C) => number - ): this & OrderedSet; + ): Self & OrderedSet; } /** @@ -1688,7 +1700,7 @@ declare namespace Immutable { filter( predicate: (value: T, key: T, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new OrderedSet with the values for which the `predicate` @@ -1951,7 +1963,7 @@ declare namespace Immutable { filter( predicate: (value: T, index: number, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a Stack "zipped" with the provided collections. @@ -2514,7 +2526,10 @@ declare namespace Immutable { function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; function Keyed(obj: { [key: string]: V }): Seq.Keyed; - interface Keyed extends Seq, Collection.Keyed { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Keyed = Keyed> + extends Seq, + Collection.Keyed { /** * Deeply converts this Keyed Seq to equivalent native JavaScript Object. * @@ -2614,7 +2629,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new keyed Seq with the values for which the `predicate` @@ -2658,7 +2673,10 @@ declare namespace Immutable { collection?: Iterable | ArrayLike ): Seq.Indexed; - interface Indexed extends Seq, Collection.Indexed { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Indexed = Indexed> + extends Seq, + Collection.Indexed { /** * Deeply converts this Indexed Seq to equivalent native JavaScript Array. */ @@ -2728,7 +2746,7 @@ declare namespace Immutable { filter( predicate: (value: T, index: number, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new indexed Seq with the values for which the `predicate` @@ -2833,7 +2851,10 @@ declare namespace Immutable { */ function Set(collection?: Iterable | ArrayLike): Seq.Set; - interface Set extends Seq, Collection.Set { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Set = Set> + extends Seq, + Collection.Set { /** * Deeply converts this Set Seq to equivalent native JavaScript Array. */ @@ -2903,7 +2924,7 @@ declare namespace Immutable { filter( predicate: (value: T, key: T, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new set Seq with the values for which the `predicate` @@ -2950,7 +2971,9 @@ declare namespace Immutable { function Seq(obj: { [key: string]: V }): Seq.Keyed; function Seq(): Seq; - interface Seq extends Collection { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Seq = Seq> + extends Collection { /** * Some Seqs can describe their size lazily. When this is the case, * size will be an integer. Otherwise it will be undefined. @@ -3061,7 +3084,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new Seq with the values for which the `predicate` function @@ -3122,7 +3145,9 @@ declare namespace Immutable { function Keyed(collection?: Iterable<[K, V]>): Collection.Keyed; function Keyed(obj: { [key: string]: V }): Collection.Keyed; - interface Keyed extends Collection { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Keyed = Keyed> + extends Collection { /** * Deeply converts this Keyed collection to equivalent native JavaScript Object. * @@ -3238,7 +3263,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new keyed Collection with the values for which the @@ -3284,7 +3309,12 @@ declare namespace Immutable { collection?: Iterable | ArrayLike ): Collection.Indexed; - interface Indexed extends Collection, OrderedCollection { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Indexed = Indexed> + extends Collection, + OrderedCollection { + ['@@__IMMUTABLE_INDEXED__@@']: true; + /** * Deeply converts this Indexed collection to equivalent native JavaScript Array. */ @@ -3502,7 +3532,7 @@ declare namespace Immutable { filter( predicate: (value: T, index: number, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new indexed Collection with the values for which the @@ -3548,7 +3578,9 @@ declare namespace Immutable { */ function Set(collection?: Iterable | ArrayLike): Collection.Set; - interface Set extends Collection { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + interface Set = Set> + extends Collection { /** * Deeply converts this Set collection to equivalent native JavaScript Array. */ @@ -3618,7 +3650,7 @@ declare namespace Immutable { filter( predicate: (value: T, key: T, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new set Collection with the values for which the @@ -3669,7 +3701,12 @@ declare namespace Immutable { }): Collection.Keyed; function Collection(): Collection; - interface Collection extends ValueObject { + interface Collection< + K, + V, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Self extends Collection = Collection, + > extends ValueObject { // Value equality /** @@ -3970,7 +4007,7 @@ declare namespace Immutable { filter( predicate: (value: V, key: K, iter: this) => unknown, context?: unknown - ): this; + ): Self; /** * Returns a new Collection of the same type with only the entries for which @@ -3982,7 +4019,7 @@ declare namespace Immutable { filterNot( predicate: (value: V, key: K, iter: this) => boolean, context?: unknown - ): this; + ): Self; /** * Returns a new Collection with the values for which the `predicate` @@ -4000,7 +4037,7 @@ declare namespace Immutable { /** * Returns a new Collection of the same type in reverse order. */ - reverse(): this; + reverse(): Self; /** * Returns a new Collection of the same type which includes the same entries, @@ -4025,7 +4062,7 @@ declare namespace Immutable { * * Note: This is always an eager operation. */ - sort(comparator?: Comparator): this; + sort(comparator?: Comparator): Self; /** * Like `sort`, but also accepts a `comparatorValueMapper` which allows for @@ -4039,7 +4076,7 @@ declare namespace Immutable { sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, comparator?: Comparator - ): this; + ): Self; /** * Returns a `Map` of `Collection`, grouped by the return @@ -4084,31 +4121,31 @@ declare namespace Immutable { * If the requested slice is equivalent to the current Collection, then it * will return itself. */ - slice(begin?: number, end?: number): this; + slice(begin?: number, end?: number): Self; /** * Returns a new Collection of the same type containing all entries except * the first. */ - rest(): this; + rest(): Self; /** * Returns a new Collection of the same type containing all entries except * the last. */ - butLast(): this; + butLast(): Self; /** * Returns a new Collection of the same type which excludes the first `amount` * entries from this Collection. */ - skip(amount: number): this; + skip(amount: number): Self; /** * Returns a new Collection of the same type which excludes the last `amount` * entries from this Collection. */ - skipLast(amount: number): this; + skipLast(amount: number): Self; /** * Returns a new Collection of the same type which includes entries starting @@ -4117,7 +4154,7 @@ declare namespace Immutable { skipWhile( predicate: (value: V, key: K, iter: this) => boolean, context?: unknown - ): this; + ): Self; /** * Returns a new Collection of the same type which includes entries starting @@ -4126,19 +4163,19 @@ declare namespace Immutable { skipUntil( predicate: (value: V, key: K, iter: this) => boolean, context?: unknown - ): this; + ): Self; /** * Returns a new Collection of the same type which includes the first `amount` * entries from this Collection. */ - take(amount: number): this; + take(amount: number): Self; /** * Returns a new Collection of the same type which includes the last `amount` * entries from this Collection. */ - takeLast(amount: number): this; + takeLast(amount: number): Self; /** * Returns a new Collection of the same type which includes entries from this @@ -4147,7 +4184,7 @@ declare namespace Immutable { takeWhile( predicate: (value: V, key: K, iter: this) => boolean, context?: unknown - ): this; + ): Self; /** * Returns a new Collection of the same type which includes entries from this @@ -4156,7 +4193,7 @@ declare namespace Immutable { takeUntil( predicate: (value: V, key: K, iter: this) => boolean, context?: unknown - ): this; + ): Self; // Combination