auto-form icon indicating copy to clipboard operation
auto-form copied to clipboard

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

Open DystopianDisco opened this issue 2 years ago • 1 comments

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?

DystopianDisco avatar Aug 06 '23 04:08 DystopianDisco

//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); } }

JheanAntunes avatar Aug 17 '23 21:08 JheanAntunes