You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed the zx.parseFormSafe type inference does not handle well ZodEffects schemas resulting from the use of refine, superRefine or transform. I will create a PR with a failing test and go from there. Do you have any idea how to fix this?
The text was updated successfully, but these errors were encountered:
The type of result.data seems correctly inferred, however, the type of result.error is not.
As a consequence, when I try to access fieldErrors.password or fieldErrors.confirmPassword in my template TypeScript is angry:
Property 'password' does not exist on type 'SerializeObject<UndefinedToOptional<{ _output?: string[] | undefined; _input?: string[] | undefined; refinement?: string[] | undefined; innerType?: string[] | undefined; _parse?: string[] | undefined; _type?: string[] | undefined; ... 27 more ...; isNullable?: string[] | undefined; }>>'. ts(2339)
I tried parsing directly with safeParse and safeParseAsync from zod and it gets it right.
It seems to be coming from the definition of SafeParsedData:
The ZodEffects case is not handled, and SafeParseReturnType<Input, Output> gets the right Output which explain the correct inference of result.data, but the Input is visibly not appropriate.
I noticed the
zx.parseFormSafe
type inference does not handle wellZodEffects
schemas resulting from the use ofrefine
,superRefine
ortransform
. I will create a PR with a failing test and go from there. Do you have any idea how to fix this?The text was updated successfully, but these errors were encountered: