Skip to content

Commit a53ecf9

Browse files
committed
fix: remove componentless routes from routes in _RouteFileInfoMap
1 parent 2d20014 commit a53ecf9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/codegen/generateRouteFileInfoMap.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,28 @@ function generateRouteFileInfoLines(
6464
routeNames: string[]
6565
childrenNamedViews: string[] | null
6666
}> {
67-
const children = node.children.size > 0 ? node.getChildrenDeepSorted() : null
67+
const deepChildren =
68+
node.children.size > 0 ? node.getChildrenDeepSorted() : null
6869

69-
const childrenNamedViews = children
70+
const deepChildrenNamedViews = deepChildren
7071
? Array.from(
7172
new Set(
72-
children.flatMap((child) => Array.from(child.value.components.keys()))
73+
deepChildren.flatMap((child) =>
74+
Array.from(child.value.components.keys())
75+
)
7376
)
7477
)
7578
: null
7679

77-
const routeNames = [node, ...node.getChildrenDeepSorted()]
78-
// an unnamed route cannot be accessed in types
79-
.filter((node): node is TreeNode & { name: string } => !!node.name)
80+
const routeNames: Array<Extract<TreeNode['name'], string>> = [
81+
node,
82+
...(deepChildren ?? []),
83+
]
84+
// unnamed routes and routes that don't correspond to certain components cannot be accessed in types
85+
.filter(
86+
(node): node is TreeNode & { name: string } =>
87+
node.value.components.size > 0 && !!node.name
88+
)
8089
.map((node) => node.name)
8190

8291
// Most of the time we only have one view, but with named views we can have multiple.
@@ -86,7 +95,7 @@ function generateRouteFileInfoLines(
8695
: Array.from(node.value.components.values()).map((file) => ({
8796
key: relative(rootDir, file).replaceAll('\\', '/'),
8897
routeNames,
89-
childrenNamedViews,
98+
childrenNamedViews: deepChildrenNamedViews,
9099
}))
91100

92101
const childrenRouteInfo = node

0 commit comments

Comments
 (0)