TanStack / TanStack/router

Functional Search Setter causes type error when using ValidateLinkOptions

Open
#3,683 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

types
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Router

Describe the bug

I made a link component using ValidateLinkOptions as explained in the docs. The component works fine if I pass search to link options as an object, but if search is a setter function, I get:
Type '{ test: string; }' is not assignable to type 'never'.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-oeezf1an?file=src%2Froutes%2Fabout.tsx

Steps to Reproduce the Bug or Issue

Open the link and navigate to src/routes/about.tsx. Notice the two heading components, the one with the functional search setter has a type error.

Expected behavior

There should be no type error

Screenshots or Videos

No response

Platform
  • OS: macOS
  • Browser: Chrome
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction and inspect src/routes/about.tsx, especially the two heading components using ValidateLinkOptions. Trace the TypeScript types applied to object and functional search values, then verify that the functional setter produces no type error in the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.