Skip to content

Commit f14598d

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

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/codegen/generateRouteFileInfoMap.ts

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

69-
const childrenNamedViews = children
71+
const deepChildrenNamedViews = deepChildren
7072
? Array.from(
7173
new Set(
72-
children.flatMap((child) => Array.from(child.value.components.keys()))
74+
deepChildren.flatMap((child) => Array.from(child.value.components.keys()))
7375
)
7476
)
7577
: null
7678

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)
79+
const routeNames: Array<Extract<TreeNode['name'], string>> = [node, ...(deepChildren ?? [])]
80+
// unnamed routes and routes that don't correspond to certain components cannot be accessed in types
81+
.filter((node): node is TreeNode & { name: string } => node.value.components.size > 0 && !!node.name)
8082
.map((node) => node.name)
8183

8284
// Most of the time we only have one view, but with named views we can have multiple.
@@ -86,7 +88,7 @@ function generateRouteFileInfoLines(
8688
: Array.from(node.value.components.values()).map((file) => ({
8789
key: relative(rootDir, file).replaceAll('\\', '/'),
8890
routeNames,
89-
childrenNamedViews,
91+
childrenNamedViews: deepChildrenNamedViews,
9092
}))
9193

9294
const childrenRouteInfo = node

0 commit comments

Comments
 (0)