From: Eduardo San Martin Morote Date: Tue, 11 Jun 2024 09:30:24 +0000 (+0200) Subject: refactor: fix todos X-Git-Tag: v4.4.0-alpha.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=839e45bf8a78313769bb3fc775f0dc64746aa595;p=thirdparty%2Fvuejs%2Frouter.git refactor: fix todos --- diff --git a/packages/router/src/location.ts b/packages/router/src/location.ts index 5d5386eb..08c2b744 100644 --- a/packages/router/src/location.ts +++ b/packages/router/src/location.ts @@ -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: '', diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index f05de580..c5a32372 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -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 { const targetLocation: RouteLocation = (pendingLocation = resolve(to))