Fixed InstantiableZodSchemaObject
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
31
src/tests.ts
31
src/tests.ts
@@ -11,23 +11,32 @@ class Test extends ZodSchemaClass({
|
||||
defaultValues: { id: -1n },
|
||||
}) {}
|
||||
|
||||
const Test2 = ZodSchemaClass({
|
||||
schema: z.object({
|
||||
id: z.bigint(),
|
||||
name: z.string(),
|
||||
}),
|
||||
|
||||
defaultValues: { id: -1n },
|
||||
})
|
||||
|
||||
Test.defaultValues
|
||||
const inst = await Test.createPromise({ id: 1n, name: "" })
|
||||
const inst = Test.create({ id: 1n, name: "" })
|
||||
|
||||
|
||||
class SubTest extends Test.extend({
|
||||
schema: ({ schema }) => schema.extend({
|
||||
prout: z.string()
|
||||
}),
|
||||
// class SubTest extends Test.extend({
|
||||
// schema: ({ schema }) => schema.extend({
|
||||
// prout: z.string()
|
||||
// }),
|
||||
|
||||
defaultValues: defaultValues => defineDefaultValues({
|
||||
...defaultValues
|
||||
}),
|
||||
}) {}
|
||||
// defaultValues: defaultValues => defineDefaultValues({
|
||||
// ...defaultValues
|
||||
// }),
|
||||
// }) {}
|
||||
|
||||
const subInst = await SubTest.createPromise({ name: "", prout: "" })
|
||||
// const subInst = await SubTest.createPromise({ name: "", prout: "" })
|
||||
|
||||
console.log(subInst)
|
||||
// console.log(subInst)
|
||||
|
||||
// class ChildTest extends Test {}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { NewZodSchemaInstanceArgs, NewZodSchemaInstanceInput } from ".."
|
||||
import { parseZodTypeEffect } from "../util"
|
||||
|
||||
|
||||
type ZodSchemaClassStatic<
|
||||
export type ZodSchemaClassStatic<
|
||||
SchemaT extends z.ZodRawShape,
|
||||
SchemaUnknownKeys extends z.UnknownKeysParam,
|
||||
SchemaCatchall extends z.ZodTypeAny,
|
||||
@@ -33,7 +33,7 @@ export const InstantiableZodSchemaObject = trait(
|
||||
Values extends {},
|
||||
DefaultValues extends Partial<Values>,
|
||||
>(
|
||||
this: Self,
|
||||
this: Self | Class<any, any[]> & ZodSchemaClassStatic<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
|
||||
...[values, params]: NewZodSchemaInstanceArgs<
|
||||
NewZodSchemaInstanceInput<Values, DefaultValues>
|
||||
@@ -54,7 +54,7 @@ export const InstantiableZodSchemaObject = trait(
|
||||
Values extends {},
|
||||
DefaultValues extends Partial<Values>,
|
||||
>(
|
||||
this: Self,
|
||||
this: Self | Class<any, any[]> & ZodSchemaClassStatic<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
|
||||
...[values, params]: NewZodSchemaInstanceArgs<
|
||||
NewZodSchemaInstanceInput<Values, DefaultValues>
|
||||
@@ -75,7 +75,7 @@ export const InstantiableZodSchemaObject = trait(
|
||||
Values extends {},
|
||||
DefaultValues extends Partial<Values>,
|
||||
>(
|
||||
this: Self,
|
||||
this: Self | Class<any, any[]> & ZodSchemaClassStatic<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, DefaultValues>,
|
||||
|
||||
...[values, params]: NewZodSchemaInstanceArgs<
|
||||
NewZodSchemaInstanceInput<Values, DefaultValues>
|
||||
|
||||
Reference in New Issue
Block a user