We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
constructorHandlers
1 parent 228fc35 commit 6330dc0Copy full SHA for 6330dc0
index.d.ts
@@ -2,8 +2,11 @@ declare namespace rfdc {
2
interface Options {
3
proto?: boolean;
4
circles?: boolean;
5
+ constructorHandlers?: ConstructorHandlerConfig[];
6
}
7
8
+type Constructor<T> = {new(...args: any[]): T};
9
+type ConstructorHandlerConfig<T = any> = [Constructor<T>, (o: T) => T];
10
11
declare function rfdc(options?: rfdc.Options): <T>(input: T) => T;
12
index.test-d.ts
@@ -5,3 +5,9 @@ const clone = rfdc();
expectType<number>(clone(5));
expectType<{ lorem: string }>(clone({ lorem: "ipsum" }));
+
+const cloneHandlers = rfdc({
+ constructorHandlers: [
+ [RegExp, (o) => new RegExp(o)],
+ ],
13
+})
0 commit comments