diff --git a/types/router.d.ts b/types/router.d.ts index dc4516bbd..07850bace 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -1,6 +1,6 @@ -import Vue, { ComponentOptions, PluginFunction, AsyncComponent } from "vue"; +import Vue, { Component as VueComponent, PluginFunction, AsyncComponent } from "vue"; -type Component = ComponentOptions | typeof Vue | AsyncComponent; +export type Component = VueComponent | AsyncComponent; type Dictionary = { [key: string]: T }; type ErrorHandler = (err: Error) => void; diff --git a/types/test/index.ts b/types/test/index.ts index abb5395b3..a42ba9733 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -1,7 +1,6 @@ -import Vue, { ComponentOptions, AsyncComponent } from "vue"; - -import VueRouter from "../index"; -import { Route, RouteRecord, RedirectOption } from "../index"; +import Vue, { ComponentOptions } from "vue"; +import { Component } from "../router"; +import VueRouter, { Route, RouteRecord, RedirectOption } from "../index"; Vue.use(VueRouter); @@ -9,6 +8,7 @@ const Home = { template: "
home
" }; const Foo = { template: "
foo
" }; const Bar = { template: "
bar
" }; const Async = () => Promise.resolve({ template: "
async
" }) +const Functional = { functional: true, template: "
functional
" }; const Hook: ComponentOptions = { template: "
hook
", @@ -73,6 +73,7 @@ const router = new VueRouter({ default: Foo, bar: Bar, asyncComponent: Async, + functionalComponent: Functional, }, meta: { auth: true }, beforeEnter (to, from, next) { @@ -115,7 +116,7 @@ const matched: RouteRecord[] = route.matched; matched.forEach(m => { const path: string = m.path; const components: { - [key: string]: ComponentOptions | typeof Vue | AsyncComponent + [key: string]: Component } = m.components; const instances: { [key: string]: Vue } = m.instances; const name: string | undefined = m.name; @@ -171,7 +172,7 @@ router.go(-1); router.back(); router.forward(); -const Components: (ComponentOptions | typeof Vue | AsyncComponent)[] = router.getMatchedComponents(); +const Components: Component[] = router.getMatchedComponents(); const vm = new Vue({ router,