Replies: 4 comments 11 replies
-
typescript unfortunately does not know in which file you are currently in, so we need to tell it. |
Beta Was this translation helpful? Give feedback.
-
Two questions:
Looking forward to your reply. |
Beta Was this translation helpful? Give feedback.
-
we got the question "why do we need to have an identifier in the route file" repeatedly, so you got the canned response for that :D
|
Beta Was this translation helpful? Give feedback.
-
Thanks for taking the time. Now, let us go back and look at the meta first: We enter a time where full-stack TS will be the fastest way to build client-server apps. Not sure if you realized it but you spearhead this with Even worse, REST shouldn't be derived from the file-system or some manual declaration but its source of truth should be the data model, SQL or its ORM, e.g., Drizzle, because changes in the REST endpoints ALWAYS start in the data model. So, your odd urge to have REST type safety declared on file-level just ignores reality and how rest endpoints are designed. This doesn't make sense and you develop a solution to a problem that doesn't exist, nobody needs this. Worst, again, file-based routing was invented as a way to declare routes implicitly, your solutions fully ignores this and again, isn't DRY, and people couldn't care less about your reasoning, it just doesn't click, and will be the major bummer for general adoption, sry for the harsh words and people won't tell you this in your face, instead they just silently opt for another solution. So, now the tl;dr:
=> Just forget REST, it is not your domain You do not want to know how many times I entered a rabbit-hole and came out months later realizing it was the wrong one. |
Beta Was this translation helpful? Give feedback.
-
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:
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
Beta Was this translation helpful? Give feedback.
All reactions