Skip to content

Commit e69bc47

Browse files
kalebposva
authored andcommitted
Add AsyncComponent type to RouteOptions.component (vuejs#1619)
* Add AsyncComponent type to RouteOptions.component AsyncComponent is currently allowed, but typescript is giving me a bogus error. This type definition update fixes this. * Add async component typing test
1 parent 6d4ac75 commit e69bc47

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

types/router.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue = require("vue");
2-
import { ComponentOptions, PluginFunction } from "vue";
2+
import { ComponentOptions, PluginFunction, AsyncComponent } from "vue";
33

4-
type Component = ComponentOptions<Vue> | typeof Vue;
4+
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
55
type Dictionary<T> = { [key: string]: T };
66

77
export type RouterMode = "hash" | "history" | "abstract";

types/test/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Vue.use(VueRouter);
99
const Home = { template: "<div>home</div>" };
1010
const Foo = { template: "<div>foo</div>" };
1111
const Bar = { template: "<div>bar</div>" };
12+
const AsyncComponent = () => Promise.resolve({ template: "<div>async</div>" })
1213

1314
const Hook: ComponentOptions<Vue> = {
1415
template: "<div>hook</div>",
@@ -66,7 +67,8 @@ const router = new VueRouter({
6667
path: "child",
6768
components: {
6869
default: Foo,
69-
bar: Bar
70+
bar: Bar,
71+
asyncComponent: AsyncComponent,
7072
},
7173
meta: { auth: true },
7274
beforeEnter (to, from, next) {

0 commit comments

Comments
 (0)