-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Router
Describe the bug
I file this as bug because this was my expectation when I got into this project, it has been my initial understand about its type safety, I do not think this should be a new feature but the baseline, so please feel free to close this issue if I miss something.
I find the current way and the need to type the route myself in addition to the file naming and location with file-based routing tedious and not DRY:
export const Route = createFileRoute("/")({
component: Home,
...
});routeTree.gen.ts gets autogenerated all the time anyway and it could also read the file and folder structure and generate typing right from that structure with file-based routing.
I mean, the reason file-based routing got again so popular is that it is dead-simple, it isn't always the best but it is easy, intuitive and gets out of the way. And, it is less work, because you need to name files and folders anyway.
Now we have to do both, naming and decide on the location of a file + declare its route, this is more work while we could just infer the type safety from the file and folder structure.
Also fire-and-forget refactoring is not straight-forward because of the non-DRY nature, you have to manually sync route declaration and file naming and location.
Your Example Website or App
not applicable
Steps to Reproduce the Bug or Issue
not applicable
Expected behavior
Routes type safety should be automatically inferred from the real file and folder structure with file-based routing with the option to manually override typing.
Screenshots or Videos
No response
Platform
not applicable
Additional context
No response