fix: type serverValidate decoded values - #2332
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthrough
ChangesServer validation type correction
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to This localized change corrects the public types returned by the Next.js and Remix server-validation adapters while preserving existing runtime behavior; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes inaccurate type inference for createServerValidate in the Next.js and Remix adapters so the successful return value is typed as the decoded FormData output (instead of the inferred form/defaultValues type), matching runtime behavior described in #1438.
Changes:
- Stop casting decoded values to
TFormDataat the point of decoding; only cast where required for validation andServerFormState. - Add type regression tests in both adapters asserting
serverValidatereturns decoded-formdata-shaped values (Record<string, unknown>). - Add a changeset bumping both adapter packages with a patch release.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-form-nextjs/src/createServerValidate.ts | Returns decoded FormData values without forcing TFormData typing; keeps cast only for validator + ServerFormState error payload. |
| packages/react-form-remix/src/createServerValidate.ts | Same typing adjustment as Next.js adapter for decoded values vs validation-cast values. |
| packages/react-form-nextjs/tests/createServerValidate.test-d.ts | Adds type regression test asserting decoded-values return type for serverValidate. |
| packages/react-form-remix/tests/createServerValidate.test-d.ts | Adds equivalent type regression test for Remix adapter. |
| .changeset/quiet-lamps-warn.md | Declares patch releases for both adapters describing the return-type fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
View your CI Pipeline Execution ↗ for commit 7e8652e
☁️ Nx Cloud last updated this comment at |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2332 +/- ##
==========================================
- Coverage 90.35% 0.00% -90.36%
==========================================
Files 38 6 -32
Lines 1752 48 -1704
Branches 444 14 -430
==========================================
- Hits 1583 0 -1583
+ Misses 149 40 -109
+ Partials 20 8 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MILLERMARRU
left a comment
There was a problem hiding this comment.
I read through createServerValidate.ts in both react-form-nextjs and react-form-remix and the change is identical in each, which is good since they're meant to stay in sync. The split between values (untyped decoded data) and validationValues (cast for the validator call) is the right fix, the validator legitimately needs TFormData shape to type-check against the user's validation function, but claiming the same type for what callers get back from serverValidate() or catch in ServerValidateError.formState.values was misleading since decode() doesn't actually enforce that shape at runtime. The new .test-d.ts files cover exactly this distinction with expectTypeOf.
🎯 Changes
Fixes #1438.
createServerValidateexposed form-value types instead of decoded form data.Fix: Return decoded
decode-formdatavalue types from the public adapter API, and keep form-shaped casts only for validator andServerFormStateinternals.Test: Added Next.js and Remix adapter type regression coverage.
✅ Checklist
pnpm test:pr.🚀 Release Impact