T
TanStack16mo ago
stormy-gold

Type error <Link to={"./"} />

Hello, idk how to solve this type error, the link is working fine as it should be, but this red line is so annoying
No description
12 Replies
stormy-gold
stormy-goldOP16mo ago
No description
stormy-gold
stormy-goldOP16mo ago
Type '"../../"' is not assignable to type '"../../../"'.ts(2322)
link.d.ts(43, 5): The expected type comes from property 'to' which is declared here on type 'IntrinsicAttributes & Omit<Omit<HTMLProps<"a">, "preload" | "children">, "ref"> & RefAttributes<HTMLAnchorElement> & ... 7 more ... & LinkPropsChildren'
Type '"../../"' is not assignable to type '"../../../"'.ts(2322)
link.d.ts(43, 5): The expected type comes from property 'to' which is declared here on type 'IntrinsicAttributes & Omit<Omit<HTMLProps<"a">, "preload" | "children">, "ref"> & RefAttributes<HTMLAnchorElement> & ... 7 more ... & LinkPropsChildren'
correct-apricot
correct-apricot16mo ago
if you want relative routes, you need to specify from
stormy-gold
stormy-goldOP16mo ago
ty. but now "search" type is missing, what it should be?
No description
correct-apricot
correct-apricot16mo ago
does your route have search params?
stormy-gold
stormy-goldOP16mo ago
yea /clube/qg88qo663stz97r/curso/ryu6o9q5g0w7k55 $clubId and $courseId I wanna go back from /clube/qg88qo663stz97r/curso/ryu6o9q5g0w7k55 to /clube/qg88qo663stz97r I think I have path params idk the correct nomenclature
correct-apricot
correct-apricot16mo ago
but do you have search params?
stormy-gold
stormy-goldOP16mo ago
no
correct-apricot
correct-apricot16mo ago
GitHub
Relative navigation always expects a search param? · Issue #1838 ...
Describe the bug When using navigation (e.g. navigate / redirect) with a from and relative to, it seems TypeScript always complains about the search param being required, even if none of the routes...
correct-apricot
correct-apricot16mo ago
so try linking to="../.." instead of to="../../" (notice the trailing slash)
stormy-gold
stormy-goldOP16mo ago
oh nice, you are insane, such a dumb thing all fine now
ratty-blush
ratty-blush16mo ago
Yeah. I guess I should fix this. It's to do with trailing slashes. We should have a better type error and not allow the trailing slash with never set

Did you find this page helpful?