Route types not being passed across libraries in a monorepo
I was about to post a question about this but ended up solving it. Posting it anyways in case someone else (or me in the future) run into this issue:
I'm exporting the Link component from a router library in a monorepo and importing it in a component lib and now the "to" prop is typed as any. Is there some sort of typescript config or something I need to modify for this to work?
The attached photo shows the Link being exported and and example of it working on the left where on the right you can see that the link component isn't type checking.
I noticed this also affects useRouteContext, useRouter, RouterProvider, getRouteApi... pretty much everything exported from the router lib.
Well it turns out it was a simple fix, somewhere along the line compilerOptions.strict was set to false on tsconfig.json for the consuming library
The solution:
Make sure your consuming library tsconfig is set with: compilerOptions.strict: true

1 Reply
correct-apricot•11mo ago
just FYI the
strict: true
option is not only relevant for monorepos but is required for router to correctly function in general