T
TanStack13mo ago
sunny-green

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
sunny-green
sunny-greenOP13mo ago
No description
sunny-green
sunny-greenOP13mo 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'
harsh-harlequin
harsh-harlequin13mo ago
if you want relative routes, you need to specify from
sunny-green
sunny-greenOP13mo ago
ty. but now "search" type is missing, what it should be?
No description
harsh-harlequin
harsh-harlequin13mo ago
does your route have search params?
sunny-green
sunny-greenOP13mo 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
harsh-harlequin
harsh-harlequin13mo ago
but do you have search params?
sunny-green
sunny-greenOP13mo ago
no
harsh-harlequin
harsh-harlequin13mo 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...
harsh-harlequin
harsh-harlequin13mo ago
so try linking to="../.." instead of to="../../" (notice the trailing slash)
sunny-green
sunny-greenOP13mo ago
oh nice, you are insane, such a dumb thing all fine now
sensitive-blue
sensitive-blue13mo 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?