]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: reverse extend order routerlocation
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 2 May 2022 15:17:05 +0000 (17:17 +0200)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 30 Jun 2022 07:59:00 +0000 (09:59 +0200)
src/types/index.ts

index b974d8f9203ffb1dde9c880ab2693343fd99336a..d4709cc117bee3433dedfc3023fc4836ec46ec90 100644 (file)
@@ -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<MatcherLocation, 'name' | 'path' | 'params' | 'meta'> {
   /**
    * 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