From ae69f99c42a20fb1f199c6f38682b7896cf65f35 Mon Sep 17 00:00:00 2001 From: Tomas Kudlac Date: Mon, 2 Aug 2021 21:25:36 +0200 Subject: [PATCH 1/5] fix(types): Support `undefined` in NavigationGuardNext --- src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/index.ts b/src/types/index.ts index 0ddd8866b..3dd467e5c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -369,7 +369,7 @@ export interface MatcherLocation export interface NavigationGuardNext { (): void (error: Error): void - (location: RouteLocationRaw): void + (location?: RouteLocationRaw): void (valid: boolean): void (cb: NavigationGuardNextCallback): void /** From 9a7e7b0bcf0f2aa0ddc8e864072eedcf315498a7 Mon Sep 17 00:00:00 2001 From: Tomas Kudlac Date: Mon, 2 Aug 2021 21:45:17 +0200 Subject: [PATCH 2/5] fix(types): Remove redundant line with no arguments in NavigationGuardNext --- src/types/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/index.ts b/src/types/index.ts index 3dd467e5c..cdd7f5011 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -367,7 +367,6 @@ export interface MatcherLocation > {} export interface NavigationGuardNext { - (): void (error: Error): void (location?: RouteLocationRaw): void (valid: boolean): void From da37c40dc767b63b77128ae5e64c1bc6d7de840c Mon Sep 17 00:00:00 2001 From: Tomas Kudlac Date: Mon, 2 Aug 2021 22:01:43 +0200 Subject: [PATCH 3/5] revert: fix(types): Remove redundant line with no arguments in NavigationGuardNext --- src/types/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/index.ts b/src/types/index.ts index cdd7f5011..3dd467e5c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -367,6 +367,7 @@ export interface MatcherLocation > {} export interface NavigationGuardNext { + (): void (error: Error): void (location?: RouteLocationRaw): void (valid: boolean): void From d22b684c5c7048e0c0f9dc00a507fd8a7d130a4c Mon Sep 17 00:00:00 2001 From: Tomas Kudlac Date: Mon, 2 Aug 2021 23:49:59 +0200 Subject: [PATCH 4/5] fix(types): Move undefined from location to valid argument --- src/types/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/index.ts b/src/types/index.ts index 3dd467e5c..9bfad6bc1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -369,8 +369,8 @@ export interface MatcherLocation export interface NavigationGuardNext { (): void (error: Error): void - (location?: RouteLocationRaw): void - (valid: boolean): void + (location: RouteLocationRaw): void + (valid: boolean | undefined): void (cb: NavigationGuardNextCallback): void /** * Allows to detect if `next` isn't called in a resolved guard. Used From 2a5a0abbe042cb5311cecfae62e16c2ac2588993 Mon Sep 17 00:00:00 2001 From: Tomas Kudlac Date: Mon, 2 Aug 2021 23:51:46 +0200 Subject: [PATCH 5/5] test(types): Add test with next undefined --- test-dts/navigationGuards.test-d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-dts/navigationGuards.test-d.ts b/test-dts/navigationGuards.test-d.ts index b2057fe82..71a244eb8 100644 --- a/test-dts/navigationGuards.test-d.ts +++ b/test-dts/navigationGuards.test-d.ts @@ -26,6 +26,10 @@ router.beforeEach((to, from) => { return false }) +router.beforeEach((to, from, next) => { + next(undefined) +}) + // @ts-expect-error router.beforeEach((to, from, next) => { return Symbol('not supported')