From: Eduardo San Martin Morote Date: Tue, 21 Jul 2020 13:03:09 +0000 (+0200) Subject: types(guards): allow to return values in guards X-Git-Tag: v4.0.0-beta.3~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=97a53a7c6ab12dee70b1f733d9d55c012536fc18;p=thirdparty%2Fvuejs%2Frouter.git types(guards): allow to return values in guards --- diff --git a/src/types/index.ts b/src/types/index.ts index 88e15635..cb8138f4 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -278,13 +278,20 @@ export interface NavigationGuardNext { export type NavigationGuardNextCallback = (vm: ComponentPublicInstance) => any +export type NavigationGuardReturn = + | void + | Error + | RouteLocationRaw + | boolean + | NavigationGuardNextCallback + export interface NavigationGuard { ( // TODO: we could maybe add extra information like replace: true/false to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext - ): any + ): NavigationGuardReturn | Promise } export interface NavigationGuardWithThis { @@ -293,7 +300,7 @@ export interface NavigationGuardWithThis { to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext - ): any + ): NavigationGuardReturn | Promise } export interface PostNavigationGuard {