@@ -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