From: Eduardo San Martin Morote Date: Mon, 10 Jun 2024 20:02:23 +0000 (+0200) Subject: refactor: remove old RouteLocation X-Git-Tag: v4.4.0-alpha.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8173b0bf760a1f4400da0467454e084c3822f15;p=thirdparty%2Fvuejs%2Frouter.git refactor: remove old RouteLocation --- diff --git a/packages/router/src/location.ts b/packages/router/src/location.ts index 29fcb41e..98693970 100644 --- a/packages/router/src/location.ts +++ b/packages/router/src/location.ts @@ -1,14 +1,10 @@ import { LocationQuery, LocationQueryRaw } from './query' -import { - RouteLocation, - RouteLocationNormalized, - RouteParamValue, -} from './types' +import { RouteLocationNormalized, RouteParamValue } from './types' import { RouteRecord } from './matcher/types' import { warn } from './warning' import { isArray } from './utils' import { decode } from './encoding' -import { RouteLocationNormalizedLoaded } from './typed-routes' +import { RouteLocation, RouteLocationNormalizedLoaded } from './typed-routes' /** * Location object returned by {@link `parseURL`}. diff --git a/packages/router/src/typed-routes/index.ts b/packages/router/src/typed-routes/index.ts index b88c0d4d..08b32445 100644 --- a/packages/router/src/typed-routes/index.ts +++ b/packages/router/src/typed-routes/index.ts @@ -10,7 +10,7 @@ export type { RouteRecordInfo } from './route-map' export type { _RouteRecordName as RouteRecordName, _RouteLocationRaw as RouteLocationRaw, - _RouteLocation as RouteLocation, + RouteLocation, _RouteLocationNormalized as RouteLocationNormalized, _RouteLocationNormalizedLoaded as RouteLocationNormalizedLoaded, _RouteLocationResolved as RouteLocationResolved, diff --git a/packages/router/src/typed-routes/route-location.ts b/packages/router/src/typed-routes/route-location.ts index 2221db5d..c405388a 100644 --- a/packages/router/src/typed-routes/route-location.ts +++ b/packages/router/src/typed-routes/route-location.ts @@ -1,16 +1,17 @@ import type { - RouteLocation, RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteLocationOptions, RouteQueryAndHash, RouteRecordName, RouteLocationRaw, + _RouteLocationBase, } from '../types' import type { _LiteralUnion } from '../types/utils' // inlining the type as it avoids code splitting issues import type { RouteMap, _RouteMapGeneric } from './route-map' import type { Router } from '../router' +import type { RouteRecord } from '../matcher/types' /** * Type safe version if it exists of the routes' names. @@ -24,9 +25,16 @@ export type _RouteRecordName = keyof RouteMap export interface RouteLocationTyped< RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap -> extends RouteLocation { +> extends _RouteLocationBase { name: Extract params: RouteMap[Name]['params'] + + /** + * Array of {@link RouteRecord} containing components as they were + * passed when adding records. It can also contain redirect records. This + * can't be used directly + */ + matched: RouteRecord[] // non-enumerable } /** @@ -193,10 +201,10 @@ export type _RouteLocationResolved< > = RouteLocationResolvedTypedList[Name] /** - * Type safe version of `RouteLocation` . Allows passing the name of the route to be passed as a generic. + * {@link RouteLocationRaw} resolved using the matcher * @see {@link RouteLocation} */ -export type _RouteLocation = +export type RouteLocation = RouteLocationTypedList[Name] /** diff --git a/packages/router/src/typed-routes/route-records.ts b/packages/router/src/typed-routes/route-records.ts index 1395f274..3a6247e5 100644 --- a/packages/router/src/typed-routes/route-records.ts +++ b/packages/router/src/typed-routes/route-records.ts @@ -1,8 +1,8 @@ -import { _RouteLocation, _RouteLocationRaw } from './route-location' +import { RouteLocation, _RouteLocationRaw } from './route-location' /** * @internal */ export type RouteRecordRedirectOption = | _RouteLocationRaw - | ((to: _RouteLocation) => _RouteLocationRaw) + | ((to: RouteLocation) => _RouteLocationRaw) diff --git a/packages/router/src/types/index.ts b/packages/router/src/types/index.ts index 9bcc131d..c9337dcb 100644 --- a/packages/router/src/types/index.ts +++ b/packages/router/src/types/index.ts @@ -6,6 +6,7 @@ import { HistoryState } from '../history/common' import { NavigationFailure } from '../errors' import { NavigationGuardWithThis, + RouteLocation, RouteRecordRedirectOption, } from '../typed-routes' import { _Awaitable } from './utils' @@ -193,18 +194,6 @@ export interface RouteLocationNormalizedLoaded extends _RouteLocationBase { matched: RouteLocationMatched[] // non-enumerable } -/** - * {@link RouteLocationRaw} resolved using the matcher - */ -export interface RouteLocation extends _RouteLocationBase { - /** - * Array of {@link RouteRecord} containing components as they were - * passed when adding records. It can also contain redirect records. This - * can't be used directly - */ - matched: RouteRecord[] // non-enumerable -} - /** * Similar to {@link RouteLocation} but its * {@link RouteLocationNormalized.matched} cannot contain redirect records