From 6094738eff45dadd052e5fe5a890c3d1d3cfef3a Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Wed, 3 Oct 2018 12:07:28 +0100 Subject: [PATCH] feat(defmulti): add varargs support --- packages/defmulti/src/index.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/defmulti/src/index.ts b/packages/defmulti/src/index.ts index 4971ec70ca..3c1f974da4 100644 --- a/packages/defmulti/src/index.ts +++ b/packages/defmulti/src/index.ts @@ -5,24 +5,24 @@ import { illegalArity } from "@thi.ng/errors/illegal-arity"; export const DEFAULT: unique symbol = Symbol(); export type DispatchFn = (...args) => PropertyKey; -export type DispatchFn1 = (a: A) => PropertyKey; -export type DispatchFn2 = (a: A, b: B) => PropertyKey; -export type DispatchFn3 = (a: A, b: B, c: C) => PropertyKey; -export type DispatchFn4 = (a: A, b: B, c: C, d: D) => PropertyKey; -export type DispatchFn5 = (a: A, b: B, c: C, d: D, e: E) => PropertyKey; -export type DispatchFn6 = (a: A, b: B, c: C, d: D, e: E, f: F) => PropertyKey; -export type DispatchFn7 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => PropertyKey; -export type DispatchFn8 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => PropertyKey; +export type DispatchFn1 = (a: A, ...xs: any[]) => PropertyKey; +export type DispatchFn2 = (a: A, b: B, ...xs: any[]) => PropertyKey; +export type DispatchFn3 = (a: A, b: B, c: C, ...xs: any[]) => PropertyKey; +export type DispatchFn4 = (a: A, b: B, c: C, d: D, ...xs: any[]) => PropertyKey; +export type DispatchFn5 = (a: A, b: B, c: C, d: D, e: E, ...xs: any[]) => PropertyKey; +export type DispatchFn6 = (a: A, b: B, c: C, d: D, e: E, f: F, ...xs: any[]) => PropertyKey; +export type DispatchFn7 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, ...xs: any[]) => PropertyKey; +export type DispatchFn8 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, ...xs: any[]) => PropertyKey; export type Implementation = (...args: any[]) => T; -export type Implementation1 = (a: A) => T; -export type Implementation2 = (a: A, b: B) => T; -export type Implementation3 = (a: A, b: B, c: C) => T; -export type Implementation4 = (a: A, b: B, c: C, d: D) => T; -export type Implementation5 = (a: A, b: B, c: C, d: D, e: E) => T; -export type Implementation6 = (a: A, b: B, c: C, d: D, e: E, f: F) => T; -export type Implementation7 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G) => T; -export type Implementation8 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) => T; +export type Implementation1 = (a: A, ...xs: any[]) => T; +export type Implementation2 = (a: A, b: B, ...xs: any[]) => T; +export type Implementation3 = (a: A, b: B, c: C, ...xs: any[]) => T; +export type Implementation4 = (a: A, b: B, c: C, d: D, ...xs: any[]) => T; +export type Implementation5 = (a: A, b: B, c: C, d: D, e: E, ...xs: any[]) => T; +export type Implementation6 = (a: A, b: B, c: C, d: D, e: E, f: F, ...xs: any[]) => T; +export type Implementation7 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, ...xs: any[]) => T; +export type Implementation8 = (a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, ...xs: any[]) => T; export interface MultiFn extends Implementation { add: (id: PropertyKey, g: Implementation) => boolean;