T
TanStack•2y ago
broad-brown

Return `fullPath` property from `new RouteApi({ id : "..." })`

The route fullPath property use required to for example use the navigate function with both from and search, but new RouteApi({ id : "..." }) only returns the route id, which generates type errors when trying to do something like this:
const navigate = useNavigate()

navigate({
from: api.id,
params: true,
search: search => ({ ...search, newParam }),
// 👆
// Type '(search: never) => any' is not assignable to type 'true | ((current: never) => never) | undefined'.
// Type '(search: never) => any' is not assignable to type '(current: never) => never'.
// Type 'any' is not assignable to type 'never'.ts(2322)
})
const navigate = useNavigate()

navigate({
from: api.id,
params: true,
search: search => ({ ...search, newParam }),
// 👆
// Type '(search: never) => any' is not assignable to type 'true | ((current: never) => never) | undefined'.
// Type '(search: never) => any' is not assignable to type '(current: never) => never'.
// Type 'any' is not assignable to type 'never'.ts(2322)
})
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?