extendSchemable work
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2024-01-08 07:17:05 +01:00
parent d28f95af82
commit 9467453042

View File

@@ -33,7 +33,7 @@ type SchemableClass<
) )
export function extendWithZodSchema< export function extendSchemable<
C extends SchemableClass< C extends SchemableClass<
ExtendSchemaT, ExtendSchemaT,
ExtendSchemaUnknownKeys, ExtendSchemaUnknownKeys,
@@ -71,12 +71,16 @@ export function extendWithZodSchema<
readonly schema = schema readonly schema = schema
} as unknown as ( } as unknown as (
Class< Class<
Omit<C, "schema"> & Omit<
Omit<C, "schema">,
keyof ExtendSchemaValues
> &
{ readonly schema: typeof schema } & { readonly schema: typeof schema } &
SchemaValues, SchemaValues,
ConstructorParameters<C> ConstructorParameters<C>
> & > &
Omit<StaticMembers<C>, "schema"> & Omit<StaticMembers<C>, "schema"> &
{ readonly schema: typeof schema } { readonly schema: typeof schema }
) )
@@ -92,7 +96,7 @@ class Test1 {
} }
const Test2Schema = Test1.schema.extend({ prout: z.literal("ruquier"), ruquier: z.number() }) const Test2Schema = Test1.schema.extend({ prout: z.literal("ruquier"), ruquier: z.number() })
const Test2 = extendWithZodSchema(Test1, Test2Schema) const Test2 = extendSchemable(Test1, Test2Schema)
Test2.schema Test2.schema
new Test2().prout new Test2().prout