remix-validated-form
remix-validated-form copied to clipboard
[Bug]: zfd `.error.flatten()` no longer matches `z.inferFlattenedErrors<typeof schema>`
Which packages are impacted?
- [ ]
remix-validated-form - [ ]
@remix-validated-form/with-zod - [ ]
@remix-validated-form/with-yup - [X]
zod-form-data
What version of these packages are you using?
- "zod": "^3.20.6",
- "zod-form-data": "^2.0.0"
Please provide a link to a minimal reproduction of the issue.
https://codesandbox.io/s/silly-raman-8dsex1?file=/src/index.tsx
Steps to Reproduce the Bug or Issue
Note the type error on line 13:
Type 'typeToFlattenedError<FormDataLikeInput, string>' is not assignable to type 'ValidationErrors'.
Types of property 'fieldErrors' are incompatible.
Type '{ [iterator]?: string[] | undefined; entries?: string[] | undefined; }' has no properties in common with type '{ field?: string[] | undefined; }'.ts(2322)
Expected behavior
Was hoping to keep using z.inferFlattenedErrors but LMK if there is an alternative I should use
Screenshots or Videos
No response
Platform
N/A
Additional context
No response
Looks like this issue occurs any time the output shape has been altered via a transform. This issue should probably be raised with zod itself as well.
Here's a reproduction without zod-form-data: Typescript playground link
@airjp73 thanks for having a look, I'll open an upstream issue with your repro
I've reverted to v1.3.1 which has fixed the problem for me instead of doing a type assertion on the resulting error. Looking forward to seeing this fixed 👍
In the upstream issue, Colin said that this doesn't seem like a solvable issue. So, unfortunately, I'm going to close this issue for now until they have a resolution. :(