Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional Search Setter causes type error when using ValidateLinkOptions #3683

Open
seththoburn-cc opened this issue Mar 6, 2025 · 1 comment
Labels
types Changes to the typescript types

Comments

@seththoburn-cc
Copy link

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

@schiller-manuel schiller-manuel added the types Changes to the typescript types label Mar 6, 2025
@seththoburn-cc
Copy link
Author

seththoburn-cc commented Mar 7, 2025

Still haven't found the cause exactly, but if anyone is looking for a workaround, explicitly annotating the prev type is typesafe and fixes the issue.

<Button
  linkProps={{
    from: '/items',
    search: (prev: ItemSearch) => ({
      ...prev,
      editItem: 'new', 
    }),
  }}
  text="New Item"
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Changes to the typescript types
Projects
None yet
Development

No branches or pull requests

2 participants