From: Cédric Exbrayat Date: Mon, 11 May 2020 07:05:54 +0000 (+0200) Subject: feat(types): export NavigationGuardNext (#229) X-Git-Tag: v4.0.0-alpha.11~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=888bf4df33d718d74e5835e99d0f1ac4ce3a0ccf;p=thirdparty%2Fvuejs%2Frouter.git feat(types): export NavigationGuardNext (#229) --- diff --git a/src/index.ts b/src/index.ts index 00f5554f..54473dee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,7 @@ export { RouteLocationOptions, RouteRecordRaw, NavigationGuard, + NavigationGuardCallback, PostNavigationGuard, } from './types' export { diff --git a/test-dts/createRouter.test-d.ts b/test-dts/createRouter.test-d.ts index 44a97244..1af67c2f 100644 --- a/test-dts/createRouter.test-d.ts +++ b/test-dts/createRouter.test-d.ts @@ -1,4 +1,10 @@ -import { createRouter, createWebHistory } from './index' +import { + createRouter, + createWebHistory, + NavigationGuard, + NavigationGuardCallback, + RouteLocationNormalized, +} from './index' import { createApp, defineComponent } from 'vue' const component = defineComponent({}) @@ -14,5 +20,15 @@ const router = createRouter({ scrollBehavior(to, from, savedPosition) {}, }) +export const loggedInGuard: NavigationGuard = (to, from, next) => next('/') +function beforeGuardFn( + to: RouteLocationNormalized, + from: RouteLocationNormalized, + next: NavigationGuardCallback +) {} + +router.beforeEach(loggedInGuard) +router.beforeEach(beforeGuardFn) + const app = createApp({}) app.use(router)