-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Router
Describe the bug
I'm absorbing and learning all things TanStack Router and TanStack start these days. Very nice! Super human and readable code - reminds me of Laravel.
Now, the following code - which is more or less verbatim from one of the Router doc pages - works under the dev server, but does not compile with npm run build and gives an error Property 'summat' does not exist on type '{}'.
Have I missed something dopey here?
Your Example Website or App
https://stackblitz.com/edit/github-kbmszfr2?file=src%2Froutes%2Fposts.index.tsx
Steps to Reproduce the Bug or Issue
Try to build a TanStack Router project with the following route file:
`
import { createFileRoute } from "@tanstack/react-router";
type SummatOptions = "summat" | "owt" | "nowt";
type SummatSearch = {
summat: SummatOptions;
};
export const Route = createFileRoute("/posts/")({
component: PostsIndexComponent,
validateSearch: (search: Record<string, unknown>): SummatSearch => {
// validate and parse the search params into a typed state
return {
summat: (search.summat as SummatOptions) || "summat",
};
},
});
function PostsIndexComponent() {
const { summat } = Route.useSearch();
return
}
`
Expected behavior
I expect, in the component function , the type of summat to be inferred and available.
Rather, it is coming out as any or {}.
Screenshots or Videos
Platform
- Router / Start Version: [1.166.6]
- OS: [Linux]
- Browser: [Chromium]
- Browser Version: [145.0.7632.159]
- Bundler: [vite]
- Bundler Version: [e.g. 7.3.1]
Additional context
Running it in Linux but in a Docker container
(Have provided a Stackblitz but not familiar with this platform - I assume we can't npm run build in Stackblitz...)