Closed marvkr closed 1 year ago
Hey in the Form component when creating a new schema that contains a date:
`const form = useForm<z.infer<typeof insertAmenitieParams>>({ // latest Zod release has introduced a TS error with zodResolver // open issue: https://github.com/colinhacks/zod/issues/2663 // errors locally but not in production resolver: zodResolver(insertAmenitieParams), defaultValues: amenitie ?? { name: "", imageUrl: "", listingId: "", category: "", createdAt: "", updatedAt: "" },`
throws a typescript error, which I fixed with:
const form = useForm<z.infer<typeof insertAmenitieParams>>({ resolver: zodResolver(insertAmenitieParams), defaultValues: amenitie ? { ...amenitie, createdAt: amenitie.createdAt.toISOString(), updatedAt: amenitie.updatedAt.toISOString(), } : { name: "", imageUrl: "", listingId: "", category: "", createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), }, });
Hey in the Form component when creating a new schema that contains a date:
throws a typescript error, which I fixed with: