Repository navigation
Type-only useSearchParams typed from a route's search schema (no runtime witness) #705
lovrozagar
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Version:
@solidjs/router2.0.0-next.42useSearchParams<In, Out>(path: TypedSearchPath<In, Out>)(dist/routing.d.ts:160) needs a value to be typed. At runtime the argument is only a switch (dist/routing.js:195,const query = path ? ... : ...): the schemas that run are the matched routes', andpath's value is never read.So a component that wants the typed search of its route has to either import
toand build a path node (e.g.useSearchParams(to.lab(1))), which pulls a value and the route tree's types into its chunk, or cast a phantomTypedSearchPath.Question / idea: could there be a type-only form, typed from a route's
searchschema the wayRouteProps<typeof route>types params? For example:We ship a small helper,
useRouteSearch<typeof route>(), that does this today by readingR["search"]["~standard"]["types"]and passing a phantom witness. A supported overload would make it unnecessary.All reactions