Hey all, quick preface: I don't necessarily think this belongs in the help-forum, I would have preferred to put this in #discussions, but I don't have write permissions at the moment.
Here's my question/discussion:
In Next.js, we have dynamic routes, the basic example would be:
// /users/[userId]/page.tsx
export default function UserPage({
params,
}: {
params: { userId: string };
}) {}
But, let's say a userId is/should be a number, and not a string. Then I would go ahead and change the params type to:
params: { userId: number }
But, there is an odd caveat, which is that all params come in as strings (unless I'm mistaken), no matter what.
If I type params.userId to be a number, it's actually a string.
This makes sense, as routes are inherently strings, and I don't expect Next to handle the conversion for me, or even worse, make assumptions about the type and perform an automatic conversion.
But, how does this have implications on best practices? If I put number as the type, the code all works, and I get no linting errors.
Am I mistaken in assuming that this is problematic? Should a type exist that allows you to define what the params are but not their types to avoid confusion for users?