]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: fix todos
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 11 Jun 2024 09:30:24 +0000 (11:30 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 11 Jun 2024 09:30:24 +0000 (11:30 +0200)
packages/router/src/location.ts
packages/router/src/router.ts

index 5d5386eb7c1acfe8210d4a0cc19bb1107c70d049..08c2b744b4a1582b523afdffab188f7c2bc321a3 100644 (file)
@@ -262,8 +262,8 @@ export function resolveRelativePath(to: string, from: string): string {
  */
 export const START_LOCATION_NORMALIZED: RouteLocationNormalizedLoaded = {
   path: '/',
-  name: undefined,
   // TODO: could we use a symbol in the future?
+  name: undefined,
   params: {},
   query: {},
   hash: '',
index f05de580520937be7d30874f506f4f43984afd54..c5a323727935dd8366fff03412defbeda7eaa5f7 100644 (file)
@@ -448,7 +448,6 @@ export function createRouter(options: RouterOptions): Router {
   }
 
   function resolve(
-    // NOTE: it's easier to by pass the type generics which are just for type inference in the resolved route
     rawLocation: RouteLocationRaw,
     currentLocation?: RouteLocationNormalizedLoaded
   ): RouteLocationResolved {
@@ -484,7 +483,7 @@ export function createRouter(options: RouterOptions): Router {
         hash: decode(locationNormalized.hash),
         redirectedFrom: undefined,
         href,
-      }) as any // FIXME:
+      })
     }
 
     if (__DEV__ && !isRouteLocation(rawLocation)) {
@@ -582,8 +581,7 @@ export function createRouter(options: RouterOptions): Router {
             ? normalizeQuery(rawLocation.query)
             : ((rawLocation.query || {}) as LocationQuery),
       },
-      // make it typed
-      matchedRoute as RouteLocation,
+      matchedRoute,
       {
         redirectedFrom: undefined,
         href,
@@ -642,7 +640,7 @@ export function createRouter(options: RouterOptions): Router {
 
       if (
         __DEV__ &&
-        (!('path' in newTargetLocation) || newTargetLocation.path == null) &&
+        newTargetLocation.path == null &&
         !('name' in newTargetLocation)
       ) {
         warn(
@@ -670,7 +668,7 @@ export function createRouter(options: RouterOptions): Router {
   }
 
   function pushWithRedirect(
-    to: RouteLocationRaw,
+    to: RouteLocationRaw | RouteLocation,
     redirectedFrom?: RouteLocation
   ): Promise<NavigationFailure | void | undefined> {
     const targetLocation: RouteLocation = (pendingLocation = resolve(to))