From: Eduardo San Martin Morote Date: Wed, 6 Jul 2022 13:24:56 +0000 (+0200) Subject: feat(types): simplify props types X-Git-Tag: v4.1.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2df87efda150027b5e455958f284db8f755caa1a;p=thirdparty%2Fvuejs%2Frouter.git feat(types): simplify props types --- 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 =