From 33ca5134a284e69fa29e083f73030abb7de545ff Mon Sep 17 00:00:00 2001 From: Kaleb Hornsby Date: Wed, 19 Jul 2017 11:40:05 -0400 Subject: [PATCH 1/2] Add AsyncComponent type to RouteOptions.component AsyncComponent is currently allowed, but typescript is giving me a bogus error. This type definition update fixes this. --- types/router.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/router.d.ts b/types/router.d.ts index 4d4c6a1d1..bed016ee0 100644 --- a/types/router.d.ts +++ b/types/router.d.ts @@ -1,7 +1,7 @@ import Vue = require("vue"); -import { ComponentOptions, PluginFunction } from "vue"; +import { ComponentOptions, PluginFunction, AsyncComponent } from "vue"; -type Component = ComponentOptions | typeof Vue; +type Component = ComponentOptions | typeof Vue | AsyncComponent; type Dictionary = { [key: string]: T }; export type RouterMode = "hash" | "history" | "abstract"; From f6796e120c7db5894b888cad7f4361d3bd2650f8 Mon Sep 17 00:00:00 2001 From: Kaleb Hornsby Date: Tue, 29 Aug 2017 11:09:01 -0400 Subject: [PATCH 2/2] Add async component typing test --- types/test/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/test/index.ts b/types/test/index.ts index 5fc8a51fc..9a0bc3612 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -9,6 +9,7 @@ Vue.use(VueRouter); const Home = { template: "
home
" }; const Foo = { template: "
foo
" }; const Bar = { template: "
bar
" }; +const AsyncComponent = () => Promise.resolve({ template: "
async
" }) const Hook: ComponentOptions = { template: "
hook
", @@ -66,7 +67,8 @@ const router = new VueRouter({ path: "child", components: { default: Foo, - bar: Bar + bar: Bar, + asyncComponent: AsyncComponent, }, meta: { auth: true }, beforeEnter (to, from, next) {