Skip to content

Commit 5593207

Browse files
committed
update types for route props feature
1 parent 776e8be commit 5593207

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

flow/declarations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ declare type RouteConfig = {
3737
children?: Array<RouteConfig>;
3838
beforeEnter?: NavigationGuard;
3939
meta?: any;
40+
props?: boolean | Object | Function;
4041
}
4142

4243
declare type RouteRecord = {
@@ -49,6 +50,7 @@ declare type RouteRecord = {
4950
matchAs: ?string;
5051
beforeEnter: ?NavigationGuard;
5152
meta: any;
53+
props: boolean | Object | Function | Dictionary<boolean | Object | Function>;
5254
}
5355

5456
declare type Location = {

src/create-route-map.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ function addRouteRecord (
4444
name,
4545
parent,
4646
matchAs,
47-
props: typeof route.props === 'undefined' ? {} : (route.components ? route.props : { default: route.props }),
4847
redirect: route.redirect,
4948
beforeEnter: route.beforeEnter,
50-
meta: route.meta || {}
49+
meta: route.meta || {},
50+
props: route.props == null
51+
? {}
52+
: route.components
53+
? route.props
54+
: { default: route.props }
5155
}
5256

5357
if (route.children) {

types/router.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface RouteConfig {
5959
children?: RouteConfig[];
6060
meta?: any;
6161
beforeEnter?: NavigationGuard;
62+
props?: boolean | Object | Function;
6263
}
6364

6465
export interface RouteRecord {
@@ -75,6 +76,7 @@ export interface RouteRecord {
7576
redirect: (location: RawLocation) => void,
7677
next: () => void
7778
) => any;
79+
props: boolean | Object | Function | Dictionary<boolean | Object | Function>;
7880
}
7981

8082
export interface Location {

0 commit comments

Comments
 (0)