T
TanStack10mo ago
correct-apricot

npx tsr doesn't generate `index.ts` route

I've followed the TanStack Start guide, and I'm about to create the second route in addition to __root.tsx, namely the index.ts route. When Vinxi is running, when I create the index.ts file, it is automatically populated with the following:
import * as React from 'react'
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
component: RouteComponent,
})

function RouteComponent() {
return 'Hello /!'
}
import * as React from 'react'
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/')({
component: RouteComponent,
})

function RouteComponent() {
return 'Hello /!'
}
Lovely!! However, I noticed inside routeTree.gen.ts that FileRoutesById is not populated with my index route.
export interface FileRoutesById {
__root__: typeof rootRoute
}
export interface FileRoutesById {
__root__: typeof rootRoute
}
I imagine this is why I get Argument of type 'string' is not assignable to parameter of type 'never'. on the createFileRoute invocation in index.ts. I tried installing @tanstack/router-cli and running npx tsr to try to generate the missing definition for index.ts, but had no luck.
8 Replies
correct-apricot
correct-apricotOP10mo ago
Alright so I deleted my route groups, and now the routes were generated. I'm gonna try to narrow it down to what specifically with the route groups it doesn't like
correct-apricot
correct-apricot10mo ago
what should npx tsr do? does this even exist? are you using start? since you mention vinxi?
correct-apricot
correct-apricotOP10mo ago
I remember using the router-cli way back, but maybe it's not needed anymore. I just figured I would try since I didn't see that the routes were properly generated. Yep, using vinxi, and I didn't tell the whole truth when I said that I'm adding my second route, I'm having an afternoon free where I'm exploring replacing Next.js with TanStack Start. So I got some route groups from beforehand
correct-apricot
correct-apricot10mo ago
the concepts from next are not the same as in router so please try reproducing this in a minimal complete example
correct-apricot
correct-apricotOP10mo ago
Nice, I managed to narrow it down. The reason is that I have two sibling folders like this:
_a/
error.tsx
_b/
error.tsx
_a/
error.tsx
_b/
error.tsx
And now that I see it, I ofcourse remember reading about how _a doesn't generate a subroute, so it's ambiguous whether error.tsx or error.tsx is the one to render I should have a separate directory for my pages and components, leaving routes with only the basic route definition stuff
correct-apricot
correct-apricot10mo ago
this should even produce an error in the generator output does it not?
correct-apricot
correct-apricotOP10mo ago
Ah, it ofcourse tells me explicitly what the error is :xd: Yeah, just me being sloppy Error: Conflicting configuration paths were found for the following routes:
correct-apricot
correct-apricot10mo ago
ok great that we have this covered

Did you find this page helpful?