@@ -64,19 +64,28 @@ function generateRouteFileInfoLines(
64
64
routeNames : string [ ]
65
65
childrenNamedViews : string [ ] | null
66
66
} > {
67
- const children = node . children . size > 0 ? node . getChildrenDeepSorted ( ) : null
67
+ const deepChildren =
68
+ node . children . size > 0 ? node . getChildrenDeepSorted ( ) : null
68
69
69
- const childrenNamedViews = children
70
+ const deepChildrenNamedViews = deepChildren
70
71
? Array . from (
71
72
new Set (
72
- children . flatMap ( ( child ) => Array . from ( child . value . components . keys ( ) ) )
73
+ deepChildren . flatMap ( ( child ) =>
74
+ Array . from ( child . value . components . keys ( ) )
75
+ )
73
76
)
74
77
)
75
78
: null
76
79
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
+ )
80
89
. map ( ( node ) => node . name )
81
90
82
91
// Most of the time we only have one view, but with named views we can have multiple.
@@ -86,7 +95,7 @@ function generateRouteFileInfoLines(
86
95
: Array . from ( node . value . components . values ( ) ) . map ( ( file ) => ( {
87
96
key : relative ( rootDir , file ) . replaceAll ( '\\' , '/' ) ,
88
97
routeNames,
89
- childrenNamedViews,
98
+ childrenNamedViews : deepChildrenNamedViews ,
90
99
} ) )
91
100
92
101
const childrenRouteInfo = node
0 commit comments