]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: update types
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 19 Jul 2022 10:36:11 +0000 (12:36 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 19 Jul 2022 10:36:11 +0000 (12:36 +0200)
packages/playground/src/router.ts
packages/router/__tests__/RouterView.spec.ts
packages/router/__tests__/utils.ts

index 4270b6a1cfcb6447ca4aab9b3101030b3fae4851..afca66cfc725c867531e267b5282a7fac298119e 100644 (file)
@@ -1,5 +1,4 @@
 import { createRouter, createWebHistory, RouterView } from 'vue-router'
-import type { RouterLinkTyped } from 'vue-router'
 import Home from './views/Home.vue'
 import Nested from './views/Nested.vue'
 import NestedWithId from './views/NestedWithId.vue'
@@ -16,13 +15,8 @@ import ComponentWithData from './views/ComponentWithData.vue'
 import { globalState } from './store'
 import { scrollWaiter } from './scrollWaiter'
 import RepeatedParams from './views/RepeatedParams.vue'
-import { h } from 'vue'
-import type { FunctionalComponent } from 'vue'
 let removeRoute: (() => void) | undefined
 
-const TransparentWrapper: FunctionalComponent = () => h(RouterView)
-TransparentWrapper.displayName = 'NestedView'
-
 export const routerHistory = createWebHistory()
 export const router = createRouter({
   history: routerHistory,
@@ -159,7 +153,6 @@ export const router = createRouter({
 
     {
       path: '/admin',
-      component: TransparentWrapper,
       children: [
         { path: '', component },
         { path: 'dashboard', component },
@@ -181,12 +174,6 @@ export const router = createRouter({
   },
 })
 
-declare module 'vue-router' {
-  export interface Config {
-    Router: typeof router
-  }
-}
-
 // router.push({ name: 'user', params: {} })
 
 const delay = (t: number) => new Promise(resolve => setTimeout(resolve, t))
index 2ba78331860ed0c789248f49025b00543bf5bddf..44c4558b19c1d41ebcbc4d8e907c0bbc8a1f9e90 100644 (file)
@@ -20,6 +20,10 @@ function createRoutes<T extends Record<string, RouteLocationNormalizedLoose>>(
 
   for (let key in routes) {
     nonReactiveRoutes[key] = markRaw(routes[key])
+    nonReactiveRoutes[key].matched.forEach(record => {
+      record.leaveGuards ??= new Set()
+      record.updateGuards ??= new Set()
+    })
   }
 
   return nonReactiveRoutes
@@ -238,7 +242,7 @@ describe('RouterView', () => {
     props: any = {}
   ) {
     const route = createMockedRoute(initialRoute)
-    const wrapper = mount(RouterView as any, {
+    const wrapper = mount(RouterView, {
       props,
       global: {
         provide: route.provides,
@@ -439,7 +443,7 @@ describe('RouterView', () => {
       props: any = {}
     ) {
       const route = createMockedRoute(initialRoute)
-      const wrapper = await mount(RouterView as any, {
+      const wrapper = await mount(RouterView, {
         props,
         global: {
           provide: route.provides,
@@ -470,7 +474,7 @@ describe('RouterView', () => {
       props: any = {}
     ) {
       const route = createMockedRoute(initialRoute)
-      const wrapper = await mount(RouterView as any, {
+      const wrapper = await mount(RouterView, {
         props,
         global: {
           provide: route.provides,
@@ -503,7 +507,7 @@ describe('RouterView', () => {
       props: any = {}
     ) {
       const route = createMockedRoute(initialRoute)
-      const wrapper = await mount(RouterView as any, {
+      const wrapper = await mount(RouterView, {
         props,
         global: {
           provide: route.provides,
index ee9dd582810e4ad840fce30ff290480bde60feba..000b838d3b6da68a812816491945ddf54b20079d 100644 (file)
@@ -55,6 +55,7 @@ export interface RouteRecordViewLoose
     'path' | 'name' | 'meta' | 'beforeEnter'
   > {
   leaveGuards?: any
+  updateGuards?: any
   instances: Record<string, any>
   enterCallbacks: Record<string, Function[]>
   props: Record<string, _RouteRecordProps>