diff --git a/types/router.d.ts b/types/router.d.ts index 424a484304..44928042b1 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -89,7 +89,7 @@ export interface PathToRegexpOptions { end?: boolean } -export interface RouteConfig { +interface _RouteConfigBase { path: string name?: string component?: Component @@ -104,6 +104,18 @@ export interface RouteConfig { pathToRegexpOptions?: PathToRegexpOptions } +type RouteConfigSingleView = _RouteConfigBase | { + component?: Component + props?: boolean | Object | RoutePropsFunction +} + +type RouteConfigMultipleViews = _RouteConfigBase | { + components?: Dictionary + 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 4afa858b00..328e8c9809 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 } },