Skip to content

Commit 5f0df45

Browse files
committed
Add typegen support for routes outside appDirectory
1 parent 3ea9c3b commit 5f0df45

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/yellow-carpets-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Fix typegen support for routes outside appDirectory

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- alberto
2121
- AlemTuzlak
2222
- Aleuck
23+
- alex-pex
2324
- alexandernanberg
2425
- alexanderson1993
2526
- alexlbr

packages/react-router-dev/typegen/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function generateRoutes(ctx: Context): Array<VirtualFile> {
119119

120120
// **/+types/*.ts
121121
const allAnnotations: Array<VirtualFile> = Array.from(fileToRoutes.entries())
122-
.filter(([file]) => isInAppDirectory(ctx, file))
122+
.filter(([file]) => isInRootDirectory(ctx, file))
123123
.map(([file, routeIds]) =>
124124
getRouteAnnotations({ ctx, file, routeIds, lineages }),
125125
);
@@ -219,9 +219,9 @@ function routeModulesType(ctx: Context) {
219219
);
220220
}
221221

222-
function isInAppDirectory(ctx: Context, routeFile: string): boolean {
222+
function isInRootDirectory(ctx: Context, routeFile: string): boolean {
223223
const path = Path.resolve(ctx.config.appDirectory, routeFile);
224-
return path.startsWith(ctx.config.appDirectory);
224+
return path.startsWith(ctx.rootDirectory);
225225
}
226226

227227
function getRouteAnnotations({

0 commit comments

Comments
 (0)