T
TanStack5w ago
like-gold

Route.useParams() giving Unsafe assignment of an error typed value

export const Route = createFileRoute('/(app)/portfolio/create/$userId/story/select')({
component: UserStory,
});

function UserStory() {
const { userId } = Route.useParams();
export const Route = createFileRoute('/(app)/portfolio/create/$userId/story/select')({
component: UserStory,
});

function UserStory() {
const { userId } = Route.useParams();
I am trying to access the userId part of dynamic route and I am getting typescript error. Is it ideal to have this much of nested levels part of file based route strcuture? Unsafe assignment of an error typed value.eslint@typescript-eslint/no-unsafe-assignment ⌘+click to open in new tab (property) RouteExtensions<"/(app)/portfolio/create/$userId/story/select", "/portfolio/create/$userId/story/select">.useParams: <RouterCore<Route<any, "/", "/", string, "root", undefined, {}, MyRootContext, AnyContext, AnyContext, {}, undefined, RootRouteChildren, FileRouteTypes>, "never", false, RouterHistory, Record<...>>, unknown, boolean>(opts?: (UseParamsBaseOptions<...> & OptionalStructuralSharing<...>) | undefined) => {
4 Replies
flat-fuchsia
flat-fuchsia5w ago
that's not a typescript error this is a lint error not relevant here IMO
like-gold
like-goldOP5w ago
I am getting that only when I create a nested folder within $userId dynamic route. If I have direct child file as route with $userId the issue is not happening. Also could you please suggest is that ideal to have nested folders based routing within dynamic routes? Cause I could not find any examples
flat-fuchsia
flat-fuchsia5w ago
sounds strange please create a github issue and provide a complete minimal reproducer that should just work and not raise any strange linter errors so either the linter is misinterpreting something, or we need to fix something in the types
like-gold
like-goldOP5w ago
When I changed my ESLint config from ...tseslint.configs.strictTypeChecked, to ...tseslint.configs.recommended, That error was gone. Thanks for your reply But I am still curious to know whats the issue

Did you find this page helpful?