Skip to content

Commit

Permalink
Fix typings for compose function to accept single rest argument (re…
Browse files Browse the repository at this point in the history
  • Loading branch information
aikoven authored and seantcoyote committed Jan 14, 2018
1 parent c260b6a commit 030fce4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ export function compose<A, B, C, T1, T2, T3, R>(
): Func3<T1, T2, T3, R>;

/* rest */
export function compose<A, B, C, R>(
f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B,
...funcs: Function[]
export function compose<R>(
f1: (b: any) => R, ...funcs: Function[]
): (...args: any[]) => R;

export function compose<R>(...funcs: Function[]): (...args: any[]) => R;
4 changes: 4 additions & 0 deletions test/typescript/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ const t10: string = compose(numberToString, stringToNumber,

const t11: number = compose(stringToNumber, numberToString, stringToNumber,
multiArgFn)('bar', 42, true);


const funcs = [stringToNumber, numberToString, stringToNumber];
const t12 = compose(...funcs)('bar', 42, true);

0 comments on commit 030fce4

Please sign in to comment.