Skip to content

Commit 0b2929a

Browse files
JounQinyyx990803
authored andcommitted
types: add EsModuleComponent definition (#6477)
1 parent 08a18dd commit 0b2929a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

types/options.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ type Constructor = {
66
}
77

88
export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions;
9+
10+
interface EsModuleComponent {
11+
default: Component
12+
}
13+
914
export type AsyncComponent = (
1015
resolve: (component: Component) => void,
1116
reject: (reason?: any) => void
12-
) => Promise<Component> | Component | void;
17+
) => Promise<Component | EsModuleComponent> | Component | void;
1318

1419
export interface ComponentOptions<V extends Vue> {
1520
data?: Object | ((this: V) => Object);

types/test/es-module.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
data() {
3+
return {}
4+
}
5+
}

types/test/options-test.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue = require("../index");
2-
import { ComponentOptions, FunctionalComponentOptions } from "../index";
2+
import { AsyncComponent, ComponentOptions, FunctionalComponentOptions } from "../index";
33

44
interface Component extends Vue {
55
a: number;
@@ -206,11 +206,13 @@ Vue.component('functional-component', {
206206
}
207207
} as FunctionalComponentOptions);
208208

209-
Vue.component("async-component", (resolve, reject) => {
209+
Vue.component("async-component", ((resolve, reject) => {
210210
setTimeout(() => {
211211
resolve(Vue.component("component"));
212212
}, 0);
213213
return new Promise((resolve) => {
214214
resolve({ functional: true } as FunctionalComponentOptions);
215215
})
216-
});
216+
}) as AsyncComponent);
217+
218+
Vue.component('async-es-module-component', (() => import('./es-module')) as AsyncComponent)

0 commit comments

Comments
 (0)