Skip to content

fix(forms): fix Zod v4 compatibility in zodResolver type declaration#220

Open
YevheniiKotyrlo wants to merge 1 commit into
primefaces:mainfrom
YevheniiKotyrlo:fix/zod-resolver-v4-compat
Open

fix(forms): fix Zod v4 compatibility in zodResolver type declaration#220
YevheniiKotyrlo wants to merge 1 commit into
primefaces:mainfrom
YevheniiKotyrlo:fix/zod-resolver-v4-compat

Conversation

@YevheniiKotyrlo
Copy link
Copy Markdown

Defect Fixes

Fixes #219

The zodResolver type declaration imports ParseParams from zod, which was removed in Zod v4. This causes TS2305: Module '"zod"' has no exported member 'ParseParams' for projects using Zod v4 with skipLibCheck: false.

Change

Replace ParseParams with Parameters<T['parse']>[1], which uses TypeScript's built-in Parameters utility to infer the second argument type of the schema's parse() method. This automatically resolves to:

  • Zod v3: InexactPartial<ParseParams> (= { path?, errorMap?, async? })
  • Zod v4: ParseContext<$ZodIssue> (= { error?, reportInput?, jitless? })

The approach is forward-compatible with any future Zod version — no maintenance burden.

Impact

  • Runtime: Zero — types only, the .mjs bundle is unchanged
  • Zod v3 users: No breaking change — same inferred type as before
  • Zod v4 users: Fixes the broken import, provides correct ParseContext autocomplete

Related: #33, #187

@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/zod-resolver-v4-compat branch from e795395 to 4b2ad78 Compare March 3, 2026 18:41
@YevheniiKotyrlo YevheniiKotyrlo force-pushed the fix/zod-resolver-v4-compat branch from 4b2ad78 to 82a1bf7 Compare March 4, 2026 18:23
@YevheniiKotyrlo
Copy link
Copy Markdown
Author

Hi — just checking in on this PR. Is there anything else needed from my side?

This is a one-line type fix — the current zod devDep resolves to Zod v4 (3.25.76), which removed the ParseParams export, so the zodResolver type declaration is broken on main right now. The fix uses Parameters<T['parse']>[1] which works with both Zod v3 and v4.

Rebased on latest main. Happy to adjust if needed.

@aboudard
Copy link
Copy Markdown

@YevheniiKotyrlo did you manage to have some answers ?
I'd like to propose some PR on primeuix, but I can't find the people involved.

@YevheniiKotyrlo
Copy link
Copy Markdown
Author

@aboudard No luck so far — it's been over a month with no response. The repo seems quiet recently. Based on git history, @tugcekucukoglu and @mertsincan are the main contributors but neither has been active lately. Happy to coordinate if you find a way through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zodResolver type declaration incompatible with Zod v4 (TS2305: ParseParams)

2 participants