Allow to specify the location to generate Route Module types #12450
Replies: 1 comment
-
Thanks for bringing this up @khabubuphathu ! This is also what my team needs in a slightly different context. Our Remix v2 app serves as multiple web apps by leveraging the following directory structure and an environment variable that is consumed in vite.config.ts:
This works perfectly fines with Remix v2. But since React Router v7 generates route types in the fixed location, that is ./react-router directory in the root, we realized that we can't generate route types for all our apps as generating types for one app wipes out ./react-router. Ideally, just like @khabubuphathu said above, we can specify where we want to generate route types by command line option, or a config option (in react-router.config.ts or vite.config.ts) so that we can support multiple app scenarios. |
Beta Was this translation helpful? Give feedback.
-
Problem
Currently, the Type Safety CLI in React Router does not provide an option to specify the location where the Route Module types should be generated. This limitation can lead to inconvenience for developers who may be using a monorepo and have specific package for types that they would like to share with other packages. Limiting developers to rely of the no typesafe option of
ActionFunctionArgs
andLoaderFunctionArgs
Solution
Introduce a new option in the Type Safety CLI that allows developers to specify the directory where the Route Module types should be generated. This option can be added as a command-line argument or a configuration setting in Vite plugin
Implementation
--types-dir
, to specify the directory for generated types.vite.config.ts
, under a new property liketypesDir
.Example Usage
# Using command-line argument react-router typegen --types-dir ../../packages/types
Beta Was this translation helpful? Give feedback.
All reactions