-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
fix: use only in directory routes on +routes RouteModules #14439
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?
Conversation
🦋 Changeset detectedLatest commit: 58f0964 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 |
711bff3
to
4784e7a
Compare
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
This is especially important for routes that are shared through node_modules. I know that, for now, the framework does not officially support this use case, but it’s still possible to reference them using file system paths. I believe the RouteModule type should remain valid even when the route type file is not generated. In my opinion, adding unknown is the recommended approach — it allows us to later decide whether we want to support type definitions for routes outside the project. |
4784e7a
to
7370b3d
Compare
isInAppDirectory(ctx, route.file) | ||
? t.tsTypeQuery( | ||
t.tsImportType( | ||
t.stringLiteral( | ||
`./${Path.relative(ctx.rootDirectory, ctx.config.appDirectory)}/${route.file}`, | ||
), | ||
), | ||
) | ||
: t.tsUnknownKeyword(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might need to add a test to ensure this works properly, don't conflict with anything else and is not removed in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i did not had time to add it, but i will add it now :)
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration test added
7370b3d
to
838343f
Compare
838343f
to
58f0964
Compare
I believe PR (Full) / 👀 Integration Test / macos-latest / node@22 / webkit (pull_request) timeout. Can anyone retry this job? |
Description
Since React Router’s type generator skips any route located outside the
app
directory, adding such a route to the+routes.ts
RouteModule
type will cause a type error.Because it’s possible to include files from outside the
app
folder using file paths, I believe the type generator should at least fall back tounknown
for those routes.