ValidateLinkOptions throwing type error when trying to add search params through function.
Which project does this relate to?
Router
Describe the bug
The search option is throwing a type error when trying to setup linkOptions props. While the code navigates properly, the type is
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-4gmm6ikn?file=src%2Froutes%2Fabout.tsx
Steps to Reproduce the Bug or Issue
Go to About page in code, Hover type error on
<HeadingLink
title="Three"
linkOptions={{
to: '/posts',
search: (prev) => ({ ...prev, tag: 'three' }),
}}
/>
```
### Expected behavior
I expect the search options to work with typesafety as 'to' 'from' etc do
### Screenshots or Videos
_No response_
### Platform
- Router / Start Version: 1.132.47
- OS: MacOS
- Browser: Chrome
- Bundler: vite
- Bundler Version: 7.1.7
### Additional context
_No response_
Solved by adding TFrom into the generic, allowing the type to properly infer when using from in the linkOptions
function FilterButton<
TRouter extends RegisteredRouter = RegisteredRouter,
TOptions = unknown,
TFrom extends string = string,
>({
label,
isActive,
disabled,
linkOptions,
}: {
label: string;
disabled?: boolean;
linkOptions: ValidateLinkOptions<TRouter, TOptions, TFrom>;
}) {
return (
<Button
disabled={disabled}
asChild
>
<Link {...linkOptions}>
{label}
</Link>
</Button>
);
}
Should this be added to the docs or is it a bug?
Had this issue today as well. Either using TFrom or LinkOptions (and adding TTo and TFrom) instead of ValidateLinkOptions fixes the issue, but it would be better if a search callback was more loose rather than failing to function at all if it cannot be narrowed