fix: type serverValidate decoded values #2332
main fromrefs/pull/2332/head·opened 🎯 Changes#
Fixes #1438. createServerValidate exposed form-value types instead of decoded form data.
Fix: Return decoded decode-formdata value types from the public adapter API, and keep form-shaped casts only for validator and ServerFormState internals.
Test: Added Next.js and Remix adapter type regression coverage.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
- 1
Pull request overview#
Fixes inaccurate type inference for
createServerValidatein the Next.js and Remix adapters so the successful return value is typed as the decodedFormDataoutput (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 FormDatavalues without forcingTFormDatatyping; keeps cast only for validator +ServerFormStateerror 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-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.- Stop casting decoded values to
View your CI Pipeline Execution ↗ for commit 7e8652e92fbe36e24091387a4d89bf01b9ab01e2
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 7m 27s View ↗ nx run-many --target=build --exclude=examples/**✅ Succeeded 6s View ↗
☁️ Nx Cloud last updated this comment at
2026-08-13 13:05:10UTCMore templates
- @tanstack/form-example-angular-array
- @tanstack/form-example-angular-large-form
- @tanstack/form-example-angular-multi-step-wizard
- @tanstack/form-example-angular-simple
- @tanstack/form-example-angular-standard-schema
- @tanstack/form-example-lit-array
- @tanstack/form-example-lit-large-form
- @tanstack/form-example-lit-multi-step-wizard
- @tanstack/form-example-lit-simple
- @tanstack/form-example-lit-standard-schema
- @tanstack/form-example-lit-ui-libraries
- @tanstack/form-example-preact-multi-step-wizard
- @tanstack/form-example-preact-simple
- @tanstack/form-example-react-array
- @tanstack/form-example-react-compiler
- @tanstack/form-example-react-composition
- @tanstack/form-example-react-devtools
- @tanstack/form-example-react-dynamic
- @tanstack/form-example-react-expo
- @tanstack/field-errors-from-form-validators
- @tanstack/form-example-react-large-form
- @tanstack/form-example-react-multi-step-wizard
- @tanstack/form-example-react-next-server-actions
- @tanstack/form-example-react-next-server-actions-zod
- @tanstack/form-example-react-query-integration
- @tanstack/form-example-remix
- @tanstack/form-example-react-simple
- @tanstack/form-example-react-standard-schema
- @tanstack/form-example-react-tanstack-start
- @tanstack/form-example-react-ui-libraries
- @tanstack/form-example-svelte-array
- @tanstack/form-example-svelte-large-form
- @tanstack/form-example-svelte-multi-step-wizard
- @tanstack/form-example-svelte-simple
- @tanstack/form-example-svelte-standard-schema
- @tanstack/form-example-solid-array
- @tanstack/form-example-solid-devtools
- @tanstack/form-example-solid-large-form
- @tanstack/form-example-solid-multi-step-wizard
- @tanstack/form-example-solid-simple
- @tanstack/form-example-solid-standard-schema
- @tanstack/form-example-vue-array
- @tanstack/form-example-vue-multi-step-wizard
- @tanstack/form-example-vue-simple
- @tanstack/form-example-vue-standard-schema
@tanstack/angular-form
npm i https://pkg.pr.new/@tanstack/angular-form@2332@tanstack/form-core
npm i https://pkg.pr.new/@tanstack/form-core@2332@tanstack/form-devtools
npm i https://pkg.pr.new/@tanstack/form-devtools@2332@tanstack/lit-form
npm i https://pkg.pr.new/@tanstack/lit-form@2332@tanstack/preact-form
npm i https://pkg.pr.new/@tanstack/preact-form@2332@tanstack/react-form
npm i https://pkg.pr.new/@tanstack/react-form@2332@tanstack/react-form-devtools
npm i https://pkg.pr.new/@tanstack/react-form-devtools@2332@tanstack/react-form-nextjs
npm i https://pkg.pr.new/@tanstack/react-form-nextjs@2332@tanstack/react-form-remix
npm i https://pkg.pr.new/@tanstack/react-form-remix@2332@tanstack/react-form-start
npm i https://pkg.pr.new/@tanstack/react-form-start@2332@tanstack/solid-form
npm i https://pkg.pr.new/@tanstack/solid-form@2332@tanstack/solid-form-devtools
npm i https://pkg.pr.new/@tanstack/solid-form-devtools@2332@tanstack/svelte-form
npm i https://pkg.pr.new/@tanstack/svelte-form@2332@tanstack/vue-form
npm i https://pkg.pr.new/@tanstack/vue-form@2332commit:
7e8652e:warning: Please install the
to ensure uploads and comments are reliably processed by Codecov.
Codecov Report#
:x: Patch coverage is
0%with4 linesin your changes missing coverage. Please review. :white_check_mark: Project coverage is 0.00%. Comparing base (6892ed0) to head (7e8652e). :warning: Report is 273 commits behind head on main.Files with missing lines Patch % Lines ...ages/react-form-nextjs/src/createServerValidate.ts 0.00% 1 Missing and 1 partial :warning: ...kages/react-form-remix/src/createServerValidate.ts 0.00% 1 Missing and 1 partial :warning: :exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality. 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:umbrella: View full report in Codecov by Harness. :loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
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) andvalidationValues(cast for the validator call) is the right fix, the validator legitimately needsTFormDatashape to type-check against the user's validation function, but claiming the same type for what callers get back fromserverValidate()or catch inServerValidateError.formState.valueswas misleading sincedecode()doesn't actually enforce that shape at runtime. The new.test-d.tsfiles cover exactly this distinction withexpectTypeOf.kkkhs(GitHub profile, opens in a new tab) linked this to fix #1438
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
e639946a-e6ab-4ff0-af79-709c1d737243📥 Commits
Reviewing files that changed from the base of the PR and between 7b8fc1d17fdfc3dbdb81077820f900bdc4bb28fd and 7e8652e92fbe36e24091387a4d89bf01b9ab01e2.
📒 Files selected for processing (5)
.changeset/quiet-lamps-warn.mdpackages/react-form-nextjs/src/createServerValidate.tspackages/react-form-nextjs/tests/createServerValidate.test-d.tspackages/react-form-remix/src/createServerValidate.tspackages/react-form-remix/tests/createServerValidate.test-d.ts📝 Walkthrough
Walkthrough#
createServerValidatenow separates decoded form data from cast validation values in the Next.js and Remix adapters. Type tests verify that returned fields are typed asunknown, and a patch Changeset documents the correction.Changes#
Server validation type correction
packages/react-form-nextjs/src/createServerValidate.ts,packages/react-form-remix/src/createServerValidate.ts,.changeset/quiet-lamps-warn.mdpackages/react-form-nextjs/tests/createServerValidate.test-d.ts,packages/react-form-remix/tests/createServerValidate.test-d.tsRecord<string, unknown>and that fields such asageare typed asunknown.Estimated code review effort: 2 (Simple) | ~10 minutes
Mergeability Score: ⚪ Minimal · up to
7e865This 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
createServerValidatedocumentation or behavior for the Next.js and Remix adapters.🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#1438by preserving decoded types in public returns and adding regression tests for both adapters.✨ 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.
❤️ Share