Skip to content
Source
Sign inSign up
TanStack/form

fix: type serverValidate decoded values #2332

Openkkkhs(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/2332/headopened

🎯 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. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      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.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.ts

      📝 Walkthrough

      Walkthrough

      createServerValidate now separates decoded form data from cast validation values in the Next.js and Remix adapters. Type tests verify that returned fields are typed as unknown, and a patch Changeset documents the correction.

      Changes

      Server validation type correction

      Layer / File(s)Summary
      Separate decoded and validation values
      packages/react-form-nextjs/src/createServerValidate.ts, packages/react-form-remix/src/createServerValidate.ts, .changeset/quiet-lamps-warn.md
      Both adapters pass cast values to server validation while preserving decoded values for successful returns. Server error state stores the cast validation values. The Changeset marks patch releases.
      Verify decoded return types
      packages/react-form-nextjs/tests/createServerValidate.test-d.ts, packages/react-form-remix/tests/createServerValidate.test-d.ts
      Type tests assert that awaited results use Record<string, unknown> and that fields such as age are typed as unknown.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Mergeability Score: ⚪ Minimal · up to 7e865

      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

      • TanStack/form#2308: Both PRs update createServerValidate documentation or behavior for the Next.js and Remix adapters.
      🚥 Pre-merge checks | ✅ 5
      ✅ Passed checks (5 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedThe changes address issue #1438 by preserving decoded types in public returns and adding regression tests for both adapters.
      Out of Scope Changes check✅ PassedAll changes are directly related to correcting createServerValidate type inference and documenting the published fix.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      Title check✅ PassedThe title clearly identifies the fix to decoded value types returned by server validation.
      Description check✅ PassedThe description explains the change, motivation, tests, checklist completion, and changeset release impact.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. 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 TFormData at the point of decoding; only cast where required for validation and ServerFormState.
      • Add type regression tests in both adapters asserting serverValidate returns 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
      FileDescription
      packages/react-form-nextjs/src/createServerValidate.tsReturns decoded FormData values without forcing TFormData typing; keeps cast only for validator + ServerFormState error payload.
      packages/react-form-remix/src/createServerValidate.tsSame typing adjustment as Next.js adapter for decoded values vs validation-cast values.
      packages/react-form-nextjs/tests/createServerValidate.test-d.tsAdds type regression test asserting decoded-values return type for serverValidate.
      packages/react-form-remix/tests/createServerValidate.test-d.tsAdds equivalent type regression test for Remix adapter.
      .changeset/quiet-lamps-warn.mdDeclares 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.

    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 7e8652e92fbe36e24091387a4d89bf01b9ab01e2

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded7m 27sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded6sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-08-13 13:05:10 UTC

    4. More templates

      @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@2332

      commit: 7e8652e

    5. :warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

      Codecov Report

      :x: Patch coverage is 0% with 4 lines in 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 linesPatch %Lines
      ...ages/react-form-nextjs/src/createServerValidate.ts0.00%1 Missing and 1 partial :warning:
      ...kages/react-form-remix/src/createServerValidate.ts0.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) 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.

  • kkkhs(GitHub profile, opens in a new tab) linked this to fix #1438

  • Sign in to join this conversation.