@@ -312,5 +312,44 @@ describe('warnings', () => {
312312 expect ( 'invalid param(s) "no", "foo" ' ) . toHaveBeenWarned ( )
313313 // from the previous location
314314 expect ( '"one"' ) . not . toHaveBeenWarned ( )
315+ // explicit params (not inherited) should not trigger the workaround hint
316+ expect ( 'catch-all route with a named redirect' ) . not . toHaveBeenWarned ( )
317+ } )
318+
319+ it ( 'hints at the `params: {}` workaround when discarded params are inherited' , ( ) => {
320+ const record = {
321+ path : '/a' ,
322+ name : 'a' ,
323+ components : { } ,
324+ }
325+ const matcher = createRouterMatcher ( [ record ] , { } )
326+ matcher . resolve (
327+ { name : 'a' , params : { pathMatch : 'unknown' } } ,
328+ {
329+ path : '/unknown' ,
330+ name : undefined ,
331+ params : { pathMatch : 'unknown' } ,
332+ matched : [ ] as any ,
333+ meta : { } ,
334+ }
335+ )
336+ expect ( 'Discarded invalid param(s)' ) . toHaveBeenWarned ( )
337+ expect ( 'catch-all route with a named redirect' ) . toHaveBeenWarned ( )
338+ } )
339+
340+ it ( 'does not warn for a catch-all redirect using the `params: {}` workaround' , async ( ) => {
341+ const history = createMemoryHistory ( )
342+ const router = createRouter ( {
343+ history,
344+ routes : [
345+ { path : '/' , name : 'HOME' , component } ,
346+ {
347+ path : '/:pathMatch(.*)*' ,
348+ redirect : { name : 'HOME' , params : { } } ,
349+ } ,
350+ ] ,
351+ } )
352+ await router . push ( '/anything' )
353+ expect ( 'Discarded invalid param(s)' ) . not . toHaveBeenWarned ( )
315354 } )
316355} )
0 commit comments