Skip to content

Commit f8ec3ef

Browse files
aikoventimdorr
authored andcommitted
Fix typings for compose function to accept single rest argument (#1936)
1 parent 3e114f8 commit f8ec3ef

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

index.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ export function compose<A, B, C, T1, T2, T3, R>(
419419
): Func3<T1, T2, T3, R>;
420420

421421
/* rest */
422-
export function compose<A, B, C, R>(
423-
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B,
424-
...funcs: Function[]
422+
export function compose<R>(
423+
f1: (b: any) => R, ...funcs: Function[]
425424
): (...args: any[]) => R;
425+
426+
export function compose<R>(...funcs: Function[]): (...args: any[]) => R;

test/typescript/compose.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ const t10: string = compose(numberToString, stringToNumber,
3333

3434
const t11: number = compose(stringToNumber, numberToString, stringToNumber,
3535
multiArgFn)('bar', 42, true);
36+
37+
38+
const funcs = [stringToNumber, numberToString, stringToNumber];
39+
const t12 = compose(...funcs)('bar', 42, true);

0 commit comments

Comments
 (0)