@@ -44,6 +44,7 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
4444
4545 let currentRoute = transformLocationToRoute ( reactRouter . state . location , reactRouter . state . matches ) ;
4646
47+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4748 let listeners : ( ( ) => void ) [ ] = [ ] ;
4849
4950 reactRouter . getBlocker ( 'beforeGuard' , onBeforeRouteChange ) ;
@@ -99,7 +100,7 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
99100 return true ;
100101 }
101102 } else {
102- const finalRoute = to . matched [ to . matched . length - 1 ] ;
103+ const finalRoute = to . matched . at ( - 1 ) ;
103104
104105 const finalPath = getFullPath ( finalRoute ) ;
105106
@@ -212,13 +213,9 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
212213 async function initReady ( ) : Promise < boolean > {
213214 return new Promise ( ( resolved , reject ) => {
214215 init ( currentRoute . fullPath , blockerOrJump )
215- . then ( res => {
216- if ( ! res ) {
217- reactRouter . initialize ( ) ;
218- resolved ( true ) ;
219- } else {
220- reject ( new Error ( 'init failed' ) ) ;
221- }
216+ . then ( ( ) => {
217+ reactRouter . initialize ( ) ;
218+ resolved ( true ) ;
222219 } )
223220 . catch ( e => {
224221 reject ( e ) ;
@@ -291,9 +288,9 @@ export function createRouter({ beforeEach, initRoutes, mode, opt, getReactRoutes
291288 }
292289
293290 function subscribe ( listener : ( ) => void ) {
294- listeners = [ ... listeners , listener ] ;
291+ listeners = [ listener ] ;
295292 return ( ) => {
296- listeners = listeners . filter ( l => l !== listener ) ;
293+ listeners = [ ] ;
297294 } ;
298295 }
299296
0 commit comments