mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
types: add EsModuleComponent definition (#6477)
This commit is contained in:
parent
08a18dd7b8
commit
0b2929a3d6
7
types/options.d.ts
vendored
7
types/options.d.ts
vendored
@ -6,10 +6,15 @@ type Constructor = {
|
||||
}
|
||||
|
||||
export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions;
|
||||
|
||||
interface EsModuleComponent {
|
||||
default: Component
|
||||
}
|
||||
|
||||
export type AsyncComponent = (
|
||||
resolve: (component: Component) => void,
|
||||
reject: (reason?: any) => void
|
||||
) => Promise<Component> | Component | void;
|
||||
) => Promise<Component | EsModuleComponent> | Component | void;
|
||||
|
||||
export interface ComponentOptions<V extends Vue> {
|
||||
data?: Object | ((this: V) => Object);
|
||||
|
5
types/test/es-module.ts
Normal file
5
types/test/es-module.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
data() {
|
||||
return {}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user