diff --git a/index.d.ts b/index.d.ts index 2245b62..83c5ec9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,8 +2,11 @@ declare namespace rfdc { interface Options { proto?: boolean; circles?: boolean; + constructorHandlers?: ConstructorHandlerConfig[]; } } +type Constructor = {new(...args: any[]): T}; +type ConstructorHandlerConfig = [Constructor, (o: T) => T]; declare function rfdc(options?: rfdc.Options): (input: T) => T; diff --git a/index.test-d.ts b/index.test-d.ts index 765bc15..ea9595f 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -5,3 +5,9 @@ const clone = rfdc(); expectType(clone(5)); expectType<{ lorem: string }>(clone({ lorem: "ipsum" })); + +const cloneHandlers = rfdc({ + constructorHandlers: [ + [RegExp, (o) => new RegExp(o)], + ], +})