diff --git a/types/router.d.ts b/types/router.d.ts index 424a48430..09bca5032 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -89,21 +89,30 @@ export interface PathToRegexpOptions { end?: boolean } -export interface RouteConfig { +interface _RouteConfigBase { path: string name?: string - component?: Component - components?: Dictionary redirect?: RedirectOption alias?: string | string[] - children?: RouteConfig[] meta?: any beforeEnter?: NavigationGuard - props?: boolean | Object | RoutePropsFunction caseSensitive?: boolean pathToRegexpOptions?: PathToRegexpOptions } +interface RouteConfigSingleView extends _RouteConfigBase { + component?: Component + props?: boolean | Object | RoutePropsFunction +} + +interface RouteConfigMultipleViews extends _RouteConfigBase { + components?: Dictionary + children?: RouteConfig[] + props?: Dictionary +} + +export type RouteConfig = RouteConfigSingleView | RouteConfigMultipleViews + export interface RouteRecord { path: string regex: RegExp diff --git a/types/test/index.ts b/types/test/index.ts index 4afa858b0..328e8c980 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -8,6 +8,7 @@ Vue.use(VueRouter) const Home = { template: '
home
' } const Foo = { template: '
foo
' } const Bar = { template: '
bar
' } +const Abc = { template: '
abc
' } const Async = () => Promise.resolve({ template: '
async
' }) const Hook: ComponentOptions = { @@ -76,6 +77,7 @@ const router = new VueRouter({ components: { default: Foo, bar: Bar, + abc: Abc, asyncComponent: Async }, meta: { auth: true }, @@ -88,6 +90,7 @@ const router = new VueRouter({ props: { default: true, bar: { id: 123 }, + abc: route => route.params, asyncComponent: (route: Route) => route.params } },