T
TanStack2y ago
optimistic-gold

How to get type infer?

I build a electron project use forge.And build route by docs's quick start.But cannot get type infer. The code is same as docs show. It may be tsconfig.json? here is tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"useDefineForClassFields": true,
"allowJs": true,
"jsx": "react-jsx",
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src"
]
}
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"useDefineForClassFields": true,
"allowJs": true,
"jsx": "react-jsx",
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src"
]
}
No description
No description
6 Replies
xenial-black
xenial-black2y ago
Have you registered the router using the declare module? This is what powers the type completion. https://tanstack.com/router/latest/docs/framework/react/quick-start#srcapptsx
Quick Start | TanStack Router Docs
If you're feeling impatient and prefer to skip all of our wonderful documentation, here is the bare minimum to get going with TanStack Router using both file-based route generation and code-based route configuration: Using File-Based Route Generation + Vite
optimistic-gold
optimistic-goldOP2y ago
of course,I flow quick star step by step.and also generate gen.ts successfully
xenial-black
xenial-black2y ago
If you've declared the router on the module, then its either your tsconfig/typescript set up or the way your editor is picking up the ts-types.
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}
declare module '@tanstack/react-router' {
interface Register {
router: typeof router
}
}
optimistic-gold
optimistic-goldOP2y ago
yep of course,all of code is same as quickly start
No description
optimistic-gold
optimistic-goldOP2y ago
i think it maybe tsconfig lead to it
xenial-black
xenial-black2y ago
Probably. A couple days back someone was using it in a monorepo with Webstorm, and for whatever reason the IDE's implementation of the typescript language server only recognized the root tsconfig and not the app-level one.

Did you find this page helpful?