0.1.2 #3
@@ -2,7 +2,7 @@ import { Trait, TraitExpressionBuilder } from "@thilawyn/traitify-ts"
|
||||
import { AbstractClass, Simplify } from "type-fest"
|
||||
import { JsonifiableObject } from "type-fest/source/jsonifiable"
|
||||
import { z } from "zod"
|
||||
import { ZodSchemaClass } from "./shapes/ZodSchemaClass"
|
||||
import { ZodSchemaAbstractClass } from "./shapes/ZodSchemaClass"
|
||||
import { ExtendableZodSchemaObject } from "./traits/ExtendableZodSchemaObject"
|
||||
import { InstantiableZodSchemaObject } from "./traits/InstantiableZodSchemaObject"
|
||||
import { Extend, StaticMembers } from "./util"
|
||||
@@ -78,7 +78,8 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
||||
}
|
||||
|
||||
jsonifiable<
|
||||
Superclass extends ZodSchemaClass<Instance, SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
Superclass extends ZodSchemaAbstractClass<Instance, SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>
|
||||
& { jsonifySchema?: never, dejsonifySchema?: never },
|
||||
Instance extends Values,
|
||||
|
||||
SchemaT extends z.ZodRawShape,
|
||||
@@ -99,7 +100,7 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
||||
DejsonifySchemaCatchall extends z.ZodTypeAny,
|
||||
>(
|
||||
this: ZodSchemaClassBuilder<
|
||||
Superclass | ZodSchemaClass<Instance, SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
Superclass | ZodSchemaAbstractClass<Instance, SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
Traits
|
||||
>,
|
||||
|
||||
@@ -130,18 +131,7 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
||||
}
|
||||
|
||||
return new ZodSchemaClassBuilder(
|
||||
JsonifiableSchemas as unknown as (
|
||||
AbstractClass<
|
||||
InstanceType<Superclass>,
|
||||
ConstructorParameters<Superclass>
|
||||
> &
|
||||
Simplify<
|
||||
Extend<[
|
||||
StaticMembers<Superclass>,
|
||||
StaticMembers<typeof JsonifiableSchemas>,
|
||||
]>
|
||||
>
|
||||
),
|
||||
JsonifiableSchemas as unknown as Superclass & StaticMembers<typeof JsonifiableSchemas>,
|
||||
|
||||
[
|
||||
...this.expressionTraits,
|
||||
|
||||
@@ -14,6 +14,10 @@ const newTestExp = new ZodSchemaClassBuilder(TraitExpression.NullSuperclass, [])
|
||||
|
||||
defaultValues: { id: -1n },
|
||||
})
|
||||
.jsonifiable({
|
||||
jsonifySchema: ({ schema }) => schema.extend({}),
|
||||
dejsonifySchema: ({ schema }) => schema.extend({}),
|
||||
})
|
||||
.expresses(ObservableZodSchemaObject)
|
||||
.build()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user