Skip to content

test(start-client-core): type regression tests for createServerFn GET validator inference (fixes #7671)#7721

Open
tsushanth wants to merge 1 commit into
TanStack:mainfrom
tsushanth:test/server-fn-validator-type-regression-7671
Open

test(start-client-core): type regression tests for createServerFn GET validator inference (fixes #7671)#7721
tsushanth wants to merge 1 commit into
TanStack:mainfrom
tsushanth:test/server-fn-validator-type-regression-7671

Conversation

@tsushanth

@tsushanth tsushanth commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds three type-level regression tests covering the ctx.data type inference regression reported in #7671, where createServerFn({ method: 'GET' }).validator(schema) caused ctx.data to resolve as unknown instead of the schema's output type.

Cases covered:

  1. Bare StandardSchemaV1 object validator — minimal { '~standard': { types, validate } } shape
  2. Parse-method validator (zod v3 shape){ parse(input: unknown): T } (the AnyValidatorObj path)
  3. Combined StandardSchema + parse validator (zod 3.25+ shape) — has both ~standard and .parse

All three pass on the current HEAD (1.170.12) with TS 5.9, confirming either: (a) the regression was fixed between 1.168.24 and now, or (b) it's environment/TS-version specific. These tests guard against future regressions.

Closes #7671

Summary by CodeRabbit

  • Tests
    • Added coverage for validator type inference with object inputs.
    • Verified server function handlers preserve typed data instead of falling back to unknown.
    • Included regression checks for validators using standard, parse-based, and combined validation patterns.

… GET validator inference

Guards against ctx.data resolving to `unknown` when a StandardSchema or
parse-method validator is used with `createServerFn({ method: 'GET' })`.

Three cases covered:
- bare StandardSchemaV1 object validator → ctx.data inferred correctly
- parse-method validator (zod v3 shape) → ctx.data inferred correctly
- combined StandardSchema + parse validator (zod 3.25+ shape) → ctx.data inferred correctly

Closes TanStack#7671
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

Run ID: d89ed8cc-ef9c-4db4-8128-b8451949072e

📥 Commits

Reviewing files that changed from the base of the PR and between 9809a06 and c1af6ac.

📒 Files selected for processing (1)
  • packages/start-client-core/src/tests/createServerFn.test-d.ts

📝 Walkthrough

Walkthrough

Three new type-level tests were added to createServerFn.test-d.ts to verify TypeScript correctly infers ctx.data as {id: string} for validators using ~standard metadata, parse methods, or both, addressing a prior regression to unknown type inference.

Changes

Validator inference regression tests

Layer / File(s) Summary
Standard, parse, and combined validator type tests
packages/start-client-core/src/tests/createServerFn.test-d.ts
Adds three type-level tests verifying that createServerFn's handler correctly infers ctx.data as {id: string} for ~standard validators, parse-method validators (Zod v3-like), and validators combining both ~standard and parse (Zod v3.25+-like), instead of regressing to unknown.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the new GET validator inference regression tests and references the linked issue.
Linked Issues check ✅ Passed The added tests cover the GET validator inference regression and the validator shapes described in #7671.
Out of Scope Changes check ✅ Passed The diff is limited to regression tests for the linked GET validator inference issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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.

data type not inferred from validator when method: 'GET' in createServerFn (regression in @tanstack/react-start 1.168.24)

1 participant