-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix typegen support for routes outside appDirectory #14410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Fix typegen support for routes outside appDirectory #14410
Conversation
🦋 Changeset detectedLatest commit: 5f0df45 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Hi @alex-pex, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected]. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
c8cfd3b
to
62637f5
Compare
Can someone allow CI to be run against my PR? |
I’ve created a PR related to this: #14439 My fix does not addresses the same issue you’re trying to solve, but I believe the same logic should be applied here as well. If, for some reason, the route type is not generated (for example, when it’s outside the root folder), we should provide a fallback for the module type. |
62637f5
to
72d0fee
Compare
72d0fee
to
5f0df45
Compare
Description :
Adds support for generating types for route files that are referenced outside of
appDirectory
, as long as they remain within the project root.Problem
Previously, type generation was strictly limited to files within
appDirectory
. TheisInAppDirectory
check ingenerate.ts
would filter out any route files that were not direct children ofappDirectory
, even if they were within the project root.This limitation was unnecessarily restrictive for projects that organize their code with route configuration in one directory and route modules in sibling directories. For example:
Typegen would skip generating types for route modules outside of
app/router/
path, breaking type safety. The generated types will be:Solution
I modified
generate.ts
to check if route files are within the project root instead of just within appDirectory:The generated types will be:
Tests
Test setup:
** A new test has been added ** in
typegen-test.ts
, named "routes outside app dir". All existing tests continue to pass, confirming no breaking changes.