import appRouter from "./appRouter" ; import homeRouter from "./homeRouter" ; interface Router { [ key ] : JSX . Element | null ; "*" : JSX . Element | null ; } const routerSwitch = ( router ) => { return ( pathname ) => { for ( const key of Object . keys ( router ) ) { if ( key === pathname ) { return router [ key ] ; } } return router [ "*" ] ; } ; } ; export const appRouterSwitch = routerSwitch ( appRouter ) ; export const homeRouterSwitch = routerSwitch ( homeRouter ) ;