]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(types): simplify props types
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 6 Jul 2022 13:24:56 +0000 (15:24 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 6 Jul 2022 13:26:27 +0000 (15:26 +0200)
packages/router/src/matcher/index.ts
packages/router/src/types/index.ts

index eda41a87ea10360a0bc66799a899056aaa3e5a46..fc39dec227556977d1ffc7110a6afdf7b75b4ca5 100644 (file)
@@ -5,7 +5,6 @@ import {
   isRouteName,
   RouteRecordName,
   _RouteRecordProps,
-  RouteRecordRedirect,
 } from '../types'
 import { createRouterError, ErrorTypes, MatcherError } from '../errors'
 import { createRouteRecordMatcher, RouteRecordMatcher } from './pathMatcher'
@@ -375,8 +374,7 @@ function normalizeRecordProps(
 ): Record<string, _RouteRecordProps> {
   const propsObject = {} as Record<string, _RouteRecordProps>
   // props does not exist on redirect records but we can set false directly
-  const props =
-    (record as Exclude<RouteRecordRaw, RouteRecordRedirect>).props || false
+  const props = record.props || false
   if ('component' in record) {
     propsObject.default = props
   } else {
index 865d510f0df27a0332af9388b56fe8c9501e18a6..4f5df48dfb7d1fff34fe32894180c5a13fe7dcef 100644 (file)
@@ -267,6 +267,11 @@ export interface _RouteRecordBase extends PathParserOptions {
    * Array of nested routes.
    */
   children?: RouteRecordRaw[]
+
+  /**
+   * Allow passing down params as props to the component rendered by `router-view`.
+   */
+  props?: _RouteRecordProps | Record<string, _RouteRecordProps>
 }
 
 /**
@@ -379,6 +384,7 @@ export interface RouteRecordRedirect extends _RouteRecordBase {
   redirect: RouteRecordRedirectOption
   component?: never
   components?: never
+  props?: never
 }
 
 export type RouteRecordRaw =