#Route branch based typing: is it possible?

4 messages · Page 1 of 1 (latest)

hidden zenith
#

I've got an app with two main routes, each with nested routes.

const routeTree = rootRoute.addChildren([
  homeRoute,
  branchA.addChildren([child1, child2, child3]),
  branchB.addChildren([child4, child5, child6]),
])

Is there any way to tell TS to ignore certain branches of the routing heirarchy? If I know I am in branchB, but I just don't know which child, I'd like to not have to contend with all the search types for all of branchA as well. In my case, the types are incompatible, such that search={x => x} actually fails if I cannot provide both to and from. What I'd like to do, conceptually, is something like this:

<Navigate
  within={branchA.id} // This line is the idea
  search={x => ({...x, page: x.page + 1})}
/>
#

Typescript: branch-based typing when strict: false?

hidden zenith
#

Route branch based typing: is it possible?

quaint hazel
#

where are the search types defined? on branchA route or on child1 etc?