Skip to content

Commit 9948c04

Browse files
committed
fix typings
1 parent 27f7193 commit 9948c04

File tree

13 files changed

+28
-26
lines changed

13 files changed

+28
-26
lines changed

src/array/toArray.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import isArray from '../is/array';
22
import isArrayLike from '../is/arrayLike';
33

44
interface ToArray {
5-
<T>(v: Array<T>): T[];
65
<T>(v: ArrayLike<T>): T[];
7-
<T>(v: T): [T];
6+
<T>(v: T): T extends Array<any> ? T : T[];
87
}
98

109
/**

src/function/compose.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Func } from '../typings/types';
2+
13
interface Compose {
24
<V0, T1>(fn0: (x0: V0) => T1): (x0: V0) => T1;
35
<V0, V1, T1>(fn0: (x0: V0, x1: V1) => T1): (x0: V0, x1: V1) => T1;
@@ -73,6 +75,7 @@ interface Compose {
7375
fn1: (x: T1) => T2,
7476
fn0: (x0: V0, x1: V1, x2: V2) => T1
7577
): (x0: V0, x1: V1, x2: V2) => T6;
78+
(...fns: Array<Func>): Func;
7679
}
7780
/**
7881
* Performs right-to-left function composition. The rightmost function may have

src/object/all.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import curryN from '../function/curryN';
2-
import { ObjPred, Prop } from '../typings/types';
2+
import { ObjPred } from '../typings/types';
33

44
interface AllObject {
5-
<K extends Prop, V>(fn: ObjPred<K, V>, obj: Record<K, V>): boolean;
6-
<K extends Prop, V>(fn: ObjPred<K, V>): (obj: Record<K, V>) => boolean;
5+
<K extends string, V>(fn: ObjPred<K, V>, obj: Record<K, V>): boolean;
6+
<K extends string, V>(fn: ObjPred<K, V>): (obj: Record<K, V>) => boolean;
77
}
88

99
/**
@@ -24,7 +24,7 @@ interface AllObject {
2424
* all(isBiggerThanZero)({ a: 0, b: 0, c: 0 }); //=> false
2525
* all(isBiggerThanZero)({ a: 1, b: 0, c: 1 }); //=> false
2626
*/
27-
export default curryN(2, <K extends Prop, V>(fn: ObjPred<K, V>, obj: Record<K, V> = {} as any) => {
27+
export default curryN(2, <K extends string, V>(fn: ObjPred<K, V>, obj: Record<K, V> = {} as any) => {
2828
for (const key in obj) {
2929
if (Object.prototype.hasOwnProperty.call(obj, key) && !fn(obj[key], key, obj)) {
3030
return false;

src/object/any.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import curryN from '../function/curryN';
2-
import { ObjPred, Prop } from '../typings/types';
2+
import { ObjPred } from '../typings/types';
33

44
interface AnyObject {
5-
<K extends Prop, V>(fn: ObjPred<K, V>, obj: Record<K, V>): boolean;
6-
<K extends Prop, V>(fn: ObjPred<K, V>): (obj: Record<K, V>) => boolean;
5+
<K extends string, V>(fn: ObjPred<K, V>, obj: Record<K, V>): boolean;
6+
<K extends string, V>(fn: ObjPred<K, V>): (obj: Record<K, V>) => boolean;
77
}
88

99
/**
@@ -23,7 +23,7 @@ interface AnyObject {
2323
* any(isBiggerThanZero)({ a: 0, b: 0, c: 0 }); //=> false
2424
* any(isBiggerThanZero)({ a: 0, b: 1, c: 0 }); //=> true
2525
*/
26-
export default curryN(2, <K extends Prop, V>(fn: ObjPred<K, V>, obj: Record<K, V> = {} as any) => {
26+
export default curryN(2, <K extends string, V>(fn: ObjPred<K, V>, obj: Record<K, V> = {} as any) => {
2727
for (const key in obj) {
2828
if (Object.prototype.hasOwnProperty.call(obj, key) && fn(obj[key], key, obj)) {
2929
return true;

src/object/each.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import curryN from '../function/curryN';
2-
import { Prop, ObjVoid } from '../typings/types';
2+
import { ObjVoid } from '../typings/types';
33

44
interface EachObj {
55
<O extends Record<any, any>>(fn: ObjVoid<keyof O, O[keyof O]>, obj: O): void;
6-
<K extends Prop, V>(fn: ObjVoid<K, V>): (obj: Record<K, V>) => void;
6+
<K extends string, V>(fn: ObjVoid<K, V>): (obj: Record<K, V>) => void;
77
}
88

99
/**
@@ -20,7 +20,7 @@ interface EachObj {
2020
* // logs x:1
2121
* // logs y:2
2222
*/
23-
export default curryN(2, <K extends Prop, V>(fn: ObjVoid<K, V>, obj: Record<K, V> = {} as any) => {
23+
export default curryN(2, <K extends string, V>(fn: ObjVoid<K, V>, obj: Record<K, V> = {} as any) => {
2424
for (const key in obj) {
2525
if (Object.prototype.hasOwnProperty.call(obj, key)) {
2626
fn(obj[key], key, obj);

src/object/filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import curryN from '../function/curryN';
22
import objectKeys from './keys';
3-
import { Prop, ObjPred } from '../typings/types';
3+
import { ObjPred } from '../typings/types';
44

55
interface FilterObj {
66
<O extends Record<any, any>>(fn: ObjPred<keyof O, O[keyof O]>, obj: O): Partial<O>;
7-
<K extends Prop, V>(fn: ObjPred<K, V>): <O extends Record<K, V>>(obj: O) => Partial<O>;
7+
<K extends string, V>(fn: ObjPred<K, V>): <O extends Record<K, V>>(obj: O) => Partial<O>;
88
}
99

1010
/**

src/object/findKey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import curryN from '../function/curryN';
2-
import { Prop, ObjPred } from '../typings/types';
2+
import { ObjPred } from '../typings/types';
33

44
interface FindKey {
55
<O extends Record<any, any>>(fn: ObjPred<keyof O, O[keyof O]>, obj: O): keyof O | void;
6-
<K extends Prop, V>(fn: ObjPred<K, V>): <O extends Record<K, V>>(obj: O) => keyof O | void;
6+
<K extends string, V>(fn: ObjPred<K, V>): <O extends Record<K, V>>(obj: O) => keyof O | void;
77
}
88

99
/**

src/object/groupBy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import curryN from '../function/curryN';
22
import objectKeys from './keys';
3-
import { Prop, ObjBaseBy, ObjBase } from '../typings/types';
3+
import { ObjBaseBy, ObjBase } from '../typings/types';
44

55
interface GroupBy {
66
<O, KT extends string>(fn: ObjBaseBy<O, KT>, obj: O): Record<KT, O[keyof O][]>;
7-
<K extends Prop, V, KT extends string>(fn: ObjBase<K, V, KT>): <O extends Record<K, V>>(
7+
<K extends string, V, KT extends string>(fn: ObjBase<K, V, KT>): <O extends Record<K, V>>(
88
obj: O
99
) => Record<KT, O[keyof O][]>;
1010
}

src/object/keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import isObject from '../is/object';
22

33
interface Keys {
44
<T extends Record<any, any>>(x: T): Array<keyof T>;
5-
(x): string[];
5+
<T>(x: T): string[];
66
}
77

88
/**

src/object/map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import curryN from '../function/curryN';
2-
import { Prop, ObjBaseBy, ObjBase } from '../typings/types';
2+
import { ObjBaseBy, ObjBase } from '../typings/types';
33

44
interface MapObject {
55
<O extends Record<any, any>, R>(fn: ObjBaseBy<O, R>, obj: O): Record<keyof O, R>;
6-
<K extends Prop, V, R>(fn: ObjBase<K, V, R>): <O extends Record<any, any>>(obj: O) => Record<keyof O, R>;
6+
<K extends string, V, R>(fn: ObjBase<K, V, R>): <O extends Record<any, any>>(obj: O) => Record<keyof O, R>;
77
}
88

99
/**

0 commit comments

Comments
 (0)