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:
|
🎯 Changes
Fixes #1438.
createServerValidatereturns the object produced bydecode-formdata, but the Next.js and Remix adapter return types were inferred from the form values. That made returned values look likedefaultValues/validator types even when the runtime value is still decoded form data.This keeps the decoded values typed from
decode-formdatafor the public return value, and only casts them to the form type where the existing validator andServerFormStatepaths require it. I added type regression tests for both adapters.Validation run locally:
corepack pnpm --filter @tanstack/form-core --filter @tanstack/react-form buildcorepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts54corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts55corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts56corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts57corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts58corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:types:ts59corepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:eslintcorepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix test:libcorepack pnpm --filter @tanstack/react-form-nextjs --filter @tanstack/react-form-remix buildcorepack pnpm exec prettier --check .changeset/quiet-lamps-warn.md packages/react-form-nextjs/src/createServerValidate.ts packages/react-form-nextjs/tests/createServerValidate.test-d.ts packages/react-form-remix/src/createServerValidate.ts packages/react-form-remix/tests/createServerValidate.test-d.tsPATH=/tmp/corepack-pnpm-bin:$PATH corepack pnpm test:prEnvironment notes: local Node is v22.16.0 while
.nvmrcasks for 24.8.0. I usedcorepack pnpmfor pnpm 11.21.0. The finaltest:prrun used a temporary PATH shim so nested package scripts also resolved pnpm 11.21.0 instead of this machine's system Rush wrapper.AI assistance was used for this change. I reviewed the final code, tests, and PR description.
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests