From d28f95af8263741a6e70332516a96118b1a49a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Mon, 8 Jan 2024 06:40:35 +0100 Subject: [PATCH] extendWithZodSchema work --- src/extendWithZodSchema.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/extendWithZodSchema.ts b/src/extendWithZodSchema.ts index 3323a94..7dd3f1f 100644 --- a/src/extendWithZodSchema.ts +++ b/src/extendWithZodSchema.ts @@ -66,13 +66,10 @@ export function extendWithZodSchema< SchemaValues >, ) { - - const class_ = class extends extend { + return class extends extend { static readonly schema = schema - readonly schema = schema - } - - return class_ as unknown as ( + readonly schema = schema + } as unknown as ( Class< Omit & { readonly schema: typeof schema } & @@ -83,7 +80,6 @@ export function extendWithZodSchema< Omit, "schema"> & { readonly schema: typeof schema } ) - } @@ -99,4 +95,4 @@ const Test2Schema = Test1.schema.extend({ prout: z.literal("ruquier"), ruquier: const Test2 = extendWithZodSchema(Test1, Test2Schema) Test2.schema -new Test2().schema +new Test2().prout