TanStackT
TanStack10mo ago
4 replies
hidden-sapphire

TS error "unsafe assignment of type any" using `Route.useParams()`

export const Route = createFileRoute('/_user/learn/$lang/$id')({
    component: RouteComponent,
})

function RouteComponent() {
    const { lang, id } = Route.useParams()
    ...
}

In this case, it seems like my $lang and $id params should be typed automatically (I have registered the router, per these instructions), but I'm still getting this error: "Unsafe assignment of an
any
value." Any advice?

(Copilot says to change the useParams call to Route.useParams<{ lang: string; id: string }>() which actually does fix some of the downstream TS errors, but creates its own TS error and also just seems wrong.)
image.png
Was this page helpful?