From 8a9a7b718dd0be486304564d57afa9b9e9273958 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 2 May 2022 17:17:05 +0200 Subject: [PATCH] refactor: reverse extend order routerlocation --- src/types/index.ts | 56 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/types/index.ts b/src/types/index.ts index b974d8f9..d4709cc1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -53,6 +53,9 @@ export interface LocationAsPath { path: string } +/** + * @internal + */ export interface LocationAsName { name: RouteRecordName params?: RouteParams @@ -105,11 +108,8 @@ export interface RouteLocationMatched extends RouteRecordNormalized { * * @internal */ -export interface _RouteLocationBase { - /** - * Percentage encoded pathname section of the URL. - */ - path: string +export interface _RouteLocationBase + extends Pick { /** * The whole location including the `search` and `hash`. This string is * percentage encoded. @@ -123,23 +123,11 @@ export interface _RouteLocationBase { * Hash of the current location. If present, starts with a `#`. */ hash: string - /** - * Name of the matched record - */ - name: RouteRecordName | null | undefined - /** - * Object of decoded params extracted from the `path`. - */ - params: RouteParams /** * Contains the location we were initially trying to access before ending up * on the current location. */ redirectedFrom: RouteLocation | undefined - /** - * Merged `meta` properties from all of the matched route records. - */ - meta: RouteMeta } // matched contains resolved components @@ -404,12 +392,34 @@ export type MatcherLocationRaw = | LocationAsName | LocationAsRelative -// TODO: should probably be the other way around: RouteLocationNormalized extending from MatcherLocation -export interface MatcherLocation - extends Pick< - RouteLocation, - 'name' | 'path' | 'params' | 'matched' | 'meta' - > {} +export interface MatcherLocation { + /** + * Name of the matched record + */ + name: RouteRecordName | null | undefined + + /** + * Percentage encoded pathname section of the URL. + */ + path: string + + /** + * Object of decoded params extracted from the `path`. + */ + params: RouteParams + + /** + * Merged `meta` properties from all of the matched route records. + */ + meta: RouteMeta + + /** + * 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 +} export interface NavigationGuardNext { (): void -- 2.47.3