-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: react-router-dom doesn't expose RemixRouter type so return types fail #10787
Comments
This type is exported from |
@timdorr https://www.npmjs.com/package/@remix-run/router |
Why is this issue closed, it still happens with the latest Maybe this is a temporary solution: const router: ReturnType<typeof createMemoryRouter> = createMemoryRouter(routes, {
initialEntries: ["/all"]
}); |
Still seeing this issue on vscode. |
Is there an update to this? It is still closed but not resolved |
import { createBrowserRouter, Link } from 'react-router-dom'
export const router: ReturnType<typeof createBrowserRouter> =
createBrowserRouter([
{
path: '/',
element: (
<div>
<h1>Hello World</h1>
<Link to="about"> About Us </Link>
</div>
),
},
{
path: 'about',
element: <div>About </div>,
},
]) As of today, do we still need to write this to resolve Error Msg? |
Wow... If we need to manually install @remix-run/router still, don't make a v6. Why not create a separate package called Personally I use a git patch |
This is fixed upstream in Typescript 5.5: microsoft/TypeScript#42873 (comment) |
This issue is estimated to be an issue for variables that are extracted from inside the router.tsx file. Therefore, the answer cited below is the most convenient and practical solution.
Thank you @rogepi 👍 |
What version of React Router are you using?
6.15
Steps to Reproduce
Node v18.12.1
Pnpm v8.4.0
Turbo v1.9.3
Installed packages:
Create router:
Expected Behavior
This is the result when we add:
To:
react-router-dom@6.15.0_react-dom@18.2.0_react@18.2.0/node_modules/react-router-dom/dist/index.d.ts
Actual Behavior
The inferred type of 'router' cannot be named without a reference to '.pnpm/@remix-run+router@1.8.0/node_modules/@remix-run/router'. This is likely not portable. A type annotation is necessary.ts(2742)
The text was updated successfully, but these errors were encountered: