From 2df87efda150027b5e455958f284db8f755caa1a Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 6 Jul 2022 15:24:56 +0200 Subject: [PATCH] feat(types): simplify props types --- packages/router/src/matcher/index.ts | 4 +--- packages/router/src/types/index.ts | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/router/src/matcher/index.ts b/packages/router/src/matcher/index.ts index eda41a87..fc39dec2 100644 --- a/packages/router/src/matcher/index.ts +++ b/packages/router/src/matcher/index.ts @@ -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 { const propsObject = {} as Record // props does not exist on redirect records but we can set false directly - const props = - (record as Exclude).props || false + const props = record.props || false if ('component' in record) { propsObject.default = props } else { diff --git a/packages/router/src/types/index.ts b/packages/router/src/types/index.ts index 865d510f..4f5df48d 100644 --- a/packages/router/src/types/index.ts +++ b/packages/router/src/types/index.ts @@ -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 } /** @@ -379,6 +384,7 @@ export interface RouteRecordRedirect extends _RouteRecordBase { redirect: RouteRecordRedirectOption component?: never components?: never + props?: never } export type RouteRecordRaw = -- 2.47.2