How to narrow the type of a path param? #4743
Answered
by
schiller-manuel
rhuanbarreto
asked this question in
Q&A
-
In a route like this:
How can I assure that the type of I already do the validation in the beforeLoad handler in beforeLoad: async ({ params: { itemType } }) => {
if (!possibleTypes.find((n) => n === itemType))
redirect({ to: "/not-found", throw: true });
} |
Beta Was this translation helpful? Give feedback.
Answered by
schiller-manuel
Jul 22, 2025
Replies: 1 comment 2 replies
-
this should do it https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#paramsparse-method |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
rhuanbarreto
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this should do it https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#paramsparse-method