drizzle-zod failing

the createInsertSchema function is throwing errors when being used with @hookform/resolvers/zod, it's weird

// Form component
...
  const form = useForm<NewComputer>({
    resolver: zodResolver(insertComputerSchema),
  });
...

throws this
Argument of type 'ZodObject<{ id: ZodString; brand: ZodString; cores: ZodNumber; }, UnknownKeysParam, ZodTypeAny, { id: string; brand: string; cores: number; }, { ...; }>' is not assignable to parameter of type 'ZodType<any, any, any>'.
  The types of 'refine(...)._def.typeName' are incompatible between these types.
    Type 'Zod.ZodFirstPartyTypeKind.ZodEffects' is not assignable to type 


schema and insertSchema declarations

export const computers = mysqlTable("computers", {
  id: varchar("id", { length: 36 }).notNull().primaryKey(),
  brand: varchar("brand", { length: 256 }).notNull(),
  cores: int("cores").notNull(),
});

// Schema for CRUD - used to validate API requests
export const insertComputerSchema = createInsertSchema(computers);
Was this page helpful?