From d18c4976e9cfd7decd5627503643351cf2ce391c Mon Sep 17 00:00:00 2001 From: beary Date: Mon, 11 May 2020 16:58:59 +0800 Subject: [PATCH] feat(types): NavigationGuardNext (#2497) --- types/index.d.ts | 5 +++-- types/router.d.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index a66f5ba15..b38685bd3 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -12,5 +12,6 @@ export { RouteRecord, Location, Route, - NavigationGuard -} from './router' + NavigationGuard, + NavigationGuardNext +} from "./router"; diff --git a/types/router.d.ts b/types/router.d.ts index 77c69bde8..af0f04c64 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -4,13 +4,15 @@ type Component = ComponentOptions | typeof Vue | AsyncComponent type Dictionary = { [key: string]: T } type ErrorHandler = (err: Error) => void -export type RouterMode = 'hash' | 'history' | 'abstract' -export type RawLocation = string | Location -export type RedirectOption = RawLocation | ((to: Route) => RawLocation) +export type RouterMode = "hash" | "history" | "abstract"; +export type RawLocation = string | Location; +export type RedirectOption = RawLocation | ((to: Route) => RawLocation); +export type NavigationGuardNext = (to?: RawLocation | false | ((vm: V) => any) | void) => void; + export type NavigationGuard = ( to: Route, from: Route, - next: (to?: RawLocation | false | ((vm: V) => any) | void) => void + next: NavigationGuardNext ) => any export declare class VueRouter {