]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor(types): rename NavigationGuardCallback to NavigationGuardNext
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 11 May 2020 07:08:56 +0000 (09:08 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 11 May 2020 07:08:56 +0000 (09:08 +0200)
src/index.ts
src/navigationGuards.ts
src/types/index.ts
test-dts/createRouter.test-d.ts

index 54473dee253f647547155fd65cf994c1088ffb46..9c452e3d1883a0231430ead1d0a091e4ddd7a83f 100644 (file)
@@ -31,7 +31,7 @@ export {
   RouteLocationOptions,
   RouteRecordRaw,
   NavigationGuard,
-  NavigationGuardCallback,
+  NavigationGuardNext,
   PostNavigationGuard,
 } from './types'
 export {
index 9695dd718ad897ccf07ae0fa71415761c8c58926..f1c96a7633d42c0b22af67d46cc6d4ec1797696b 100644 (file)
@@ -1,7 +1,7 @@
 import {
   NavigationGuard,
   RouteLocationNormalized,
-  NavigationGuardCallback,
+  NavigationGuardNext,
   RouteLocationRaw,
   RouteLocationNormalizedLoaded,
   NavigationGuardNextCallback,
@@ -95,7 +95,7 @@ export function guardToPromiseFn(
 ): () => Promise<void> {
   return () =>
     new Promise((resolve, reject) => {
-      const next: NavigationGuardCallback = (
+      const next: NavigationGuardNext = (
         valid?: boolean | RouteLocationRaw | NavigationGuardNextCallback | Error
       ) => {
         if (valid === false)
@@ -140,10 +140,10 @@ export function guardToPromiseFn(
 }
 
 function canOnlyBeCalledOnce(
-  next: NavigationGuardCallback,
+  next: NavigationGuardNext,
   to: RouteLocationNormalized,
   from: RouteLocationNormalized
-): NavigationGuardCallback {
+): NavigationGuardNext {
   let called = 0
   return function () {
     if (called++ === 1)
index 04fb2f7d47d2496b92847be38be5de2d3eca00f9..ca62b34dd851ddc28c8cba26d62532904d59faaa 100644 (file)
@@ -237,7 +237,7 @@ export interface MatcherLocation
     'name' | 'path' | 'params' | 'matched' | 'meta'
   > {}
 
-export interface NavigationGuardCallback {
+export interface NavigationGuardNext {
   (): void
   (error: Error): void
   (location: RouteLocationRaw): void
@@ -252,7 +252,7 @@ export interface NavigationGuard {
     // TODO: we could maybe add extra information like replace: true/false
     to: RouteLocationNormalized,
     from: RouteLocationNormalized,
-    next: NavigationGuardCallback
+    next: NavigationGuardNext
   ): any
 }
 
@@ -261,7 +261,7 @@ export interface NavigationGuardWithThis<T> {
     this: T,
     to: RouteLocationNormalized,
     from: RouteLocationNormalized,
-    next: NavigationGuardCallback
+    next: NavigationGuardNext
   ): any
 }
 
index 1af67c2f1d02966603d3e603fb9cb8463e1f2d83..ca647b3e39b8f89132149e1e4d3c5aff834dbf46 100644 (file)
@@ -2,7 +2,7 @@ import {
   createRouter,
   createWebHistory,
   NavigationGuard,
-  NavigationGuardCallback,
+  NavigationGuardNext,
   RouteLocationNormalized,
 } from './index'
 import { createApp, defineComponent } from 'vue'
@@ -24,7 +24,7 @@ export const loggedInGuard: NavigationGuard = (to, from, next) => next('/')
 function beforeGuardFn(
   to: RouteLocationNormalized,
   from: RouteLocationNormalized,
-  next: NavigationGuardCallback
+  next: NavigationGuardNext
 ) {}
 
 router.beforeEach(loggedInGuard)