diff --git a/types/options.d.ts b/types/options.d.ts index b1ab125665..0de8e8f7de 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -6,10 +6,15 @@ type Constructor = { } export type Component = typeof Vue | ComponentOptions | FunctionalComponentOptions; + +interface EsModuleComponent { + default: Component +} + export type AsyncComponent = ( resolve: (component: Component) => void, reject: (reason?: any) => void -) => Promise | Component | void; +) => Promise | Component | void; export interface ComponentOptions { data?: Object | ((this: V) => Object); diff --git a/types/test/es-module.ts b/types/test/es-module.ts new file mode 100644 index 0000000000..f124374df4 --- /dev/null +++ b/types/test/es-module.ts @@ -0,0 +1,5 @@ +export default { + data() { + return {} + } +} diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 28ce077e98..3f17b071a3 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -1,5 +1,5 @@ import Vue = require("../index"); -import { ComponentOptions, FunctionalComponentOptions } from "../index"; +import { AsyncComponent, ComponentOptions, FunctionalComponentOptions } from "../index"; interface Component extends Vue { a: number; @@ -206,11 +206,13 @@ Vue.component('functional-component', { } } as FunctionalComponentOptions); -Vue.component("async-component", (resolve, reject) => { +Vue.component("async-component", ((resolve, reject) => { setTimeout(() => { resolve(Vue.component("component")); }, 0); return new Promise((resolve) => { resolve({ functional: true } as FunctionalComponentOptions); }) -}); +}) as AsyncComponent); + +Vue.component('async-es-module-component', (() => import('./es-module')) as AsyncComponent)