You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ParsedHistoryState doesn't work with useLocation #3193
You have to extend the HistoryState interface in the @tanstack/react-router module instead of in the @tanstack/history one. Good catch on the docs though, I will work on them now. Also, by chance, are you using pnpm, maybe the way it structures the node_modules folder is the reason why you cannot extend it in the @tanstack/history package.
src/App.tsx:11:10 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'Navigate'.
11 import { Navigate, RouterProvider, createRouter } from '@tanstack/react-router'
Anyway, I found this (#284 (comment)) and will try to check my local setup (I use npm and Vite BTW).
Can you provide a full minimal reproduction? I created a completely new project and added the code above with the fix I mentioned and it works perfectly, I cannot reproduce your issue.
> tsc -b && vite build
src/main.tsx:3:10 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'RouterProvider'.
3 import { RouterProvider, createRouter } from '@tanstack/react-router'~~~~~~~~~~~~~~
src/main.tsx:3:26 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'createRouter'.
3 import { RouterProvider, createRouter } from '@tanstack/react-router'~~~~~~~~~~~~
src/routes/__root.tsx:1:10 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'createRootRoute'.
1 import { createRootRoute, Link, Outlet } from '@tanstack/react-router'~~~~~~~~~~~~~~~
src/routes/__root.tsx:1:27 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'Link'.
1 import { createRootRoute, Link, Outlet } from '@tanstack/react-router'~~~~
src/routes/__root.tsx:1:33 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'Outlet'.
1 import { createRootRoute, Link, Outlet } from '@tanstack/react-router'~~~~~~
src/routes/about.lazy.tsx:1:10 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'createLazyFileRoute'.
1 import { createLazyFileRoute } from '@tanstack/react-router'~~~~~~~~~~~~~~~~~~~
src/routes/index.lazy.tsx:1:10 - error TS2305: Module '"@tanstack/react-router"' has no exported member 'createLazyFileRoute'.
1 import { createLazyFileRoute } from '@tanstack/react-router'~~~~~~~~~~~~~~~~~~~
That declare module is supposed to be in main.tsx.
Edit: Also, npm create @tanstack/router --legacy-peer-deps works, it's due to the way npm handles peer dependencies, if it does not like something it just errors. Hence why I use pnpm.
Activity
ferretwithaberet commentedon Jan 19, 2025
You have to extend the
HistoryStateinterface in the@tanstack/react-routermodule instead of in the@tanstack/historyone. Good catch on the docs though, I will work on them now. Also, by chance, are you usingpnpm, maybe the way it structures thenode_modulesfolder is the reason why you cannot extend it in the@tanstack/historypackage.guy-ecton commentedon Jan 19, 2025
When I try
it breaks everything.
Like
Anyway, I found this (#284 (comment)) and will try to check my local setup (I use npm and Vite BTW).
ferretwithaberet commentedon Jan 19, 2025
Can you provide a full minimal reproduction? I created a completely new project and added the code above with the fix I mentioned and it works perfectly, I cannot reproduce your issue.
guy-ecton commentedon Jan 19, 2025
npm create @tanstack/router@latestcrashes for me (tried inside an empty folder, tried after creating vite project with react + ts...)Log
src/vite-env.d.ts:npm run dev- worksnpm run build- breaks.Logs
(sorry, I'm unable to open a repro right now).
package.json
{ "name": "test-proj", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", "preview": "vite preview" }, "dependencies": { "@tanstack/react-router": "^1.97.3", "react": "^18.3.1", "react-dom": "^18.3.1" }, "devDependencies": { "@eslint/js": "^9.17.0", "@tanstack/router-devtools": "^1.97.3", "@tanstack/router-plugin": "^1.97.3", "@types/react": "^18.3.18", "@types/react-dom": "^18.3.5", "@vitejs/plugin-react": "^4.3.4", "eslint": "^9.17.0", "eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-refresh": "^0.4.16", "globals": "^15.14.0", "typescript": "~5.6.2", "typescript-eslint": "^8.18.2", "vite": "^6.0.5" } }ferretwithaberet commentedon Jan 19, 2025
That
declare moduleis supposed to be inmain.tsx.Edit: Also,
npm create @tanstack/router --legacy-peer-depsworks, it's due to the waynpmhandles peer dependencies, if it does not like something it just errors. Hence why I usepnpm.guy-ecton commentedon Jan 19, 2025
That makes sense 😬 as it already contains override for
interface Register...Thanks and sorry (at least we'll get the documentation fixed.)