T
TanStack3w ago
ratty-blush

Route Path in `createFileRoute` Keeps Auto-Correcting to Remove Layout Folder

Hi all,
I’m running into an issue with TanStack Router’s file-based routing. My file structure is:
src/routes/
_authenticated.tsx
_authenticated.create-log.tsx
_authenticated.index.tsx
src/routes/
_authenticated.tsx
_authenticated.create-log.tsx
_authenticated.index.tsx
In _authenticated.create-log.tsx, I set up the route like this:
export const Route = createFileRoute('/_authenticated/create-log')({
// code here
})
export const Route = createFileRoute('/_authenticated/create-log')({
// code here
})
But whenever I save the file, the path in createFileRoute automatically changes to:
createFileRoute('/create-log')
createFileRoute('/create-log')
This causes a TypeScript error:
Argument of type '"/create-log"' is not assignable to parameter of type 'keyof FileRoutesByPath | undefined'.
Argument of type '"/create-log"' is not assignable to parameter of type 'keyof FileRoutesByPath | undefined'.
It seems like some tool or extension is auto-correcting the route path and removing the _authenticated part, even though I want to keep the file path for type safety. Has anyone else run into this? Is there a way to prevent this auto-correction or configure it to keep the full file path? Thanks!
3 Replies
conscious-sapphire
conscious-sapphire3w ago
minicheck@googlemail.com
StackBlitz
Router Quickstart File Based Example (duplicated) - StackBlitz
Run official live example code for Router Quickstart File Based, created by Tanstack on StackBlitz
conscious-sapphire
conscious-sapphire3w ago
our vite plugin automatically sets that path this cannot be turned off and is necessary can you please provide a complete minimal example that reproduces this error?
ratty-blush
ratty-blushOP3w ago
Hey this was fixed after I close the cursor and reopen it 😖

Did you find this page helpful?