vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
2.29k stars 81 forks source link

Property 'innerType' does not exist on type 'ZodAnyDef'. #22

Open DystopianDisco opened 11 months ago

DystopianDisco commented 11 months ago

great component. works smoothly locally but but not deploying due to two issues in the auto-form.tsx

  1. Property 'innerType' does not exist on type 'ZodAnyDef'.
  2. Property 'schema' does not exist on type 'ZodAnyDef'.

related to line 62 and 66:

"function getBaseSchema(schema: z.ZodAny): z.ZodAny { if ("innerType" in schema._def) {

return getBaseSchema(schema._def.innerType as z.ZodAny);

} if ("schema" in schema._def) {

return getBaseSchema(schema._def.schema as z.ZodAny);

} return schema; }"

Building on Next.js 13 using Shadcn Taxonomy. Any ideas how to fix?

JheanAntunes commented 10 months ago

//explaining @DystopianDisco kkkk, I have the same problem... In order not to comment on this part, I used this alternative (The error stopped, but this does not confirm that it is correct!) const schemanew: any = { ...schema }; //spread Operator (Get all properties) and added a type any if ("_def" in schemanew && "innerType" in schemanew._def) { // if these properties exist; schemanew._def.innerType as z.ZodAny;//I changed the type of the property and then passed it as an argument; return getBaseSchema(schemanew._def.innerType); } //código if ("innerType" in schema._def) { const schemanew: any = { ...schema }; if ("_def" in schemanew && "innerType" in schemanew._def) { schemanew._def.innerType as z.ZodAny; return getBaseSchema(schemanew._def.innerType); } }