@@ -739,6 +739,66 @@ describe('generateRouteNamedMap', () => {
739739 )
740740 } )
741741
742+ it ( 'excludes _parent routes from route map' , ( ) => {
743+ const tree = new PrefixTree ( DEFAULT_OPTIONS )
744+ tree . insert ( 'nested/_parent' , 'nested/_parent.vue' )
745+ tree . insert ( 'nested/index' , 'nested/index.vue' )
746+ tree . insert ( 'nested/other' , 'nested/other.vue' )
747+
748+ // _parent route creates a parent component but is non-matchable (name: false)
749+ // so it should NOT appear in the RouteNamedMap
750+ expect (
751+ formatExports ( generateRouteNamedMap ( tree , DEFAULT_OPTIONS , new Map ( ) ) )
752+ ) . toMatchInlineSnapshot ( `
753+ "export interface RouteNamedMap {
754+ '/nested/': RouteRecordInfo<
755+ '/nested/',
756+ '/nested',
757+ Record<never, never>,
758+ Record<never, never>,
759+ | never
760+ >,
761+ '/nested/other': RouteRecordInfo<
762+ '/nested/other',
763+ '/nested/other',
764+ Record<never, never>,
765+ Record<never, never>,
766+ | never
767+ >,
768+ }"
769+ ` )
770+ } )
771+
772+ it ( 'excludes _parent routes without index from children union' , ( ) => {
773+ const tree = new PrefixTree ( DEFAULT_OPTIONS )
774+ tree . insert ( 'nested/_parent' , 'nested/_parent.vue' )
775+ tree . insert ( 'nested/child' , 'nested/child.vue' )
776+ tree . insert ( 'nested/other' , 'nested/other.vue' )
777+
778+ // _parent is non-matchable so it doesn't appear in the map
779+ // and its children (child, other) should not list _parent in their unions
780+ expect (
781+ formatExports ( generateRouteNamedMap ( tree , DEFAULT_OPTIONS , new Map ( ) ) )
782+ ) . toMatchInlineSnapshot ( `
783+ "export interface RouteNamedMap {
784+ '/nested/child': RouteRecordInfo<
785+ '/nested/child',
786+ '/nested/child',
787+ Record<never, never>,
788+ Record<never, never>,
789+ | never
790+ >,
791+ '/nested/other': RouteRecordInfo<
792+ '/nested/other',
793+ '/nested/other',
794+ Record<never, never>,
795+ Record<never, never>,
796+ | never
797+ >,
798+ }"
799+ ` )
800+ } )
801+
742802 it ( 'excludes routes with empty names from route map' , ( ) => {
743803 const tree = new PrefixTree ( DEFAULT_OPTIONS )
744804 tree . insert ( 'parent' , 'parent.vue' )
0 commit comments