#Types not correctly generated.

1 messages · Page 1 of 1 (latest)

plucky flicker
#

"typecheck": "react-router typegen && tsc" add this as script in package.json

plucky flicker
#

did u try deleting .react-router/ folder ?

silk niche
#

You should import like this : import type { Route } from './+types'

#

And have a file .react-router/types/app/routes/campaigns/+types/index.ts

#

Include ".react-router/types/**/*" in your tsconfig, and "rootDirs": [".", "./.react-router/types"],

patent knoll
silk niche
#

Your route is an index, that's why './+types/campaigns' isn't working

#

Yep

silk niche
#

I'm not sure to understand your question (i'm not a native english speaker) but solid (or svelte, don't remember) inspired react-router team for this. The rootDirsconfig allows multiple root directories to be treated as one merged directory. TypeScript will look for files in all specified directories as if they were one combined directory.

Current :

..prefix("/campaigns", [
  index("./routes/campaigns/index.tsx"), // import type { Route } from './+types'
  route(":campaignId", "./routes/campaigns/campaign/index.tsx"), // import type { Route } from './+types' because filename is still index.tsx
])

Maybe what you want is :

..prefix("/campaigns", [
  index("./routes/campaigns/index.tsx"), // import type { Route } from './+types'
  route(":campaignId", "./routes/campaigns/campaign.tsx"), // import type { Route } from './+types/campaign' because filename is campaign
])

Or (if you don't need the campaigns directory) :

..prefix("/campaigns", [
  index("./routes/campaigns.tsx"), // import type { Route } from './+types/campaigns' because filename is campaigns
  route(":campaignId", "./routes/campaigns.$id.tsx"), // import type { Route } from './+types/campaigns.$id' because filename is campaigns.$id
])