From 4f6dcf9e1d5adabba8525345bb642f5690c5f588 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Mon, 10 Jul 2017 15:36:03 +0800 Subject: [PATCH] fix(type): reverse the overload sequence of ComposeSignature Without this fix, it will get typescript compiler error with typescript v2.4.1 when `compose` has more than three args passed in. As in https://www.typescriptlang.org/docs/handbook/functions.html, the office example also places the signature with most args at the front. Here we follow the example and make compiler find the best match. --- src/compose.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compose.ts b/src/compose.ts index 5d7fce9..ec83ccc 100644 --- a/src/compose.ts +++ b/src/compose.ts @@ -1,10 +1,10 @@ export interface ComposeSignature { - (): (i: A) => A; - (b: (i: A) => B): (i: A) => B; - (c: (i: B) => C, b: (i: A) => B): (i: A) => C; - (d: (i: C) => D, c: (i: B) => C, b: (i: A) => B): (i: A) => D; - (e: (i: D) => E, d: (i: C) => D, c: (i: B) => C, b: (i: A) => B): (i: A) => E; (f: (i: E) => F, e: (i: D) => E, d: (i: C) => D, c: (i: B) => C, b: (i: A) => B): (i: A) => F; + (e: (i: D) => E, d: (i: C) => D, c: (i: B) => C, b: (i: A) => B): (i: A) => E; + (d: (i: C) => D, c: (i: B) => C, b: (i: A) => B): (i: A) => D; + (c: (i: B) => C, b: (i: A) => B): (i: A) => C; + (b: (i: A) => B): (i: A) => B; + (): (i: A) => A; (...fns: any[]): (input: any) => any; } @@ -20,4 +20,4 @@ export const compose: ComposeSignature = (...functions) => { return rest.reduceRight((composed, fn) => fn(composed), last(arg)); } -} \ No newline at end of file +}