TanStackT
TanStack16mo ago
9 replies
comprehensive-tomato

Route implicitely has type 'any' because of loader

I have the following code:
export const Route = createFileRoute(
  "/_layout/_adminPermission/admin/committees/$slug",
)({
  loader: ({ context: { queryClient, auth }, params: { slug } }) =>
    queryClient.ensureQueryData(
      committeesDetailQueryOptions(auth.getToken, slug),
    ),
  component: () => (
    <Suspense fallback={<></>}>
      <Page />
    </Suspense>
  ),
});


This results in Route being 'any'. Making loader async/await does not change this.
When I remove loader, the type of Route is inferred correctly and the error disappears. There are also routes that have a loader that do work correctly. I would likt to add more relevant information, but not sure what could be useful.

Anyone can point me in the right direction for what I might be doing wrong? Thanks!
Was this page helpful?