T
TanStack2y ago
optimistic-gold

Can you use TanStack Router without TypeScript?

I was assuming you could use this library without TypeScript, but after running the route generator I noticed TypeScript specific code in the output. If I'm not using TypeScript, should I be using this router?
7 Replies
eastern-cyan
eastern-cyan2y ago
The benefits ARE the typesafety..
optimistic-gold
optimistic-goldOP2y ago
So, no?
metropolitan-bronze
metropolitan-bronze2y ago
If you use the router-cli then it'll always spit out its output in typescript format. You could always strip out the type-annotations by hand, you look for a package that may already exist that de-typescriptifies a file. If you aren't using the cli, and writing the route definitions by hand, then it'll just work. Just DON'T add the type-definitions. With this approach you'd still get the robust search param functionality and stuff, just without the type-safety.
plain-purple
plain-purple2y ago
We should add a no types option to the CLI. Thoughts @Sean Cassiere @Manuel Schiller @Jason ?
metropolitan-bronze
metropolitan-bronze2y ago
Makes sense. At the moment, the router-cli path is certainly more challenging. --output-mode=js 🙌🏼
rare-sapphire
rare-sapphire2y ago
so this would then skip the output of declare module "@tanstack/react-router" { ... }
metropolitan-bronze
metropolitan-bronze2y ago
Most likely would since this would be targetting JS-only users. Unless there's some way of inserting the router types into JSDoc inference...

Did you find this page helpful?