Skip to content

Commit 2df87ef

Browse files
committed
feat(types): simplify props types
1 parent ef27a2d commit 2df87ef

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/router/src/matcher/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
isRouteName,
66
RouteRecordName,
77
_RouteRecordProps,
8-
RouteRecordRedirect,
98
} from '../types'
109
import { createRouterError, ErrorTypes, MatcherError } from '../errors'
1110
import { createRouteRecordMatcher, RouteRecordMatcher } from './pathMatcher'
@@ -375,8 +374,7 @@ function normalizeRecordProps(
375374
): Record<string, _RouteRecordProps> {
376375
const propsObject = {} as Record<string, _RouteRecordProps>
377376
// props does not exist on redirect records but we can set false directly
378-
const props =
379-
(record as Exclude<RouteRecordRaw, RouteRecordRedirect>).props || false
377+
const props = record.props || false
380378
if ('component' in record) {
381379
propsObject.default = props
382380
} else {

packages/router/src/types/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ export interface _RouteRecordBase extends PathParserOptions {
267267
* Array of nested routes.
268268
*/
269269
children?: RouteRecordRaw[]
270+
271+
/**
272+
* Allow passing down params as props to the component rendered by `router-view`.
273+
*/
274+
props?: _RouteRecordProps | Record<string, _RouteRecordProps>
270275
}
271276

272277
/**
@@ -379,6 +384,7 @@ export interface RouteRecordRedirect extends _RouteRecordBase {
379384
redirect: RouteRecordRedirectOption
380385
component?: never
381386
components?: never
387+
props?: never
382388
}
383389

384390
export type RouteRecordRaw =

0 commit comments

Comments
 (0)