TanStackT
TanStack2y ago
5 replies
dead-brown

Should .ts files be ignored by default with file based routing?

In my
routes
-folders I created a .ts-file (beneath the .tsx-files) . After creating the file, the generator plugin generates the typical createFileRoute in that file (and also includes the routes in
routeTree.gen.ts
). Obviously this does not work, as a .ts file does not support JSX syntax. When removing the generated code from the .ts-file the code is not generated again, but the "route" is not removed from
routeTree.gen.ts
(which is inconsistent imho).

I didn't found something in the docs nor the source code, so my question is: should .tsfiles be ignored or is it correct that the generator treats them as route files? Personally I'd like to see them ignored, because then I could easily co-locate non-UI files (data loading code, hooks, etc.) with my route files.
Was this page helpful?