Use Statically Type Links type as a return type #66287
Unanswered
dawnchan030920
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Statically typed links are cool, but I ran into issues when trying to use
Router<T>
as the return type of a function. Only static route strings are acceptable, dynamic route strings will cause type error.I checked the
link.d.ts
and found that corresponding dynamic route string types are generated.link.d.ts
function I am trying to build
If I change
/category/${item.value}
into something like/
or/projects
which are valid static route strings, the compiler won't complain.Beta Was this translation helpful? Give feedback.
All reactions