Browse Source

types: add EsModuleComponent definition (#6477)

dev
JounQin 7 years ago
committed by Evan You
parent
commit
0b2929a3d6
  1. 7
      types/options.d.ts
  2. 5
      types/test/es-module.ts
  3. 8
      types/test/options-test.ts

7
types/options.d.ts

@ -6,10 +6,15 @@ type Constructor = {
} }
export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions; export type Component = typeof Vue | ComponentOptions<Vue> | FunctionalComponentOptions;
interface EsModuleComponent {
default: Component
}
export type AsyncComponent = ( export type AsyncComponent = (
resolve: (component: Component) => void, resolve: (component: Component) => void,
reject: (reason?: any) => void reject: (reason?: any) => void
) => Promise<Component> | Component | void; ) => Promise<Component | EsModuleComponent> | Component | void;
export interface ComponentOptions<V extends Vue> { export interface ComponentOptions<V extends Vue> {
data?: Object | ((this: V) => Object); data?: Object | ((this: V) => Object);

5
types/test/es-module.ts

@ -0,0 +1,5 @@
export default {
data() {
return {}
}
}

8
types/test/options-test.ts

@ -1,5 +1,5 @@
import Vue = require("../index"); import Vue = require("../index");
import { ComponentOptions, FunctionalComponentOptions } from "../index"; import { AsyncComponent, ComponentOptions, FunctionalComponentOptions } from "../index";
interface Component extends Vue { interface Component extends Vue {
a: number; a: number;
@ -206,11 +206,13 @@ Vue.component('functional-component', {
} }
} as FunctionalComponentOptions); } as FunctionalComponentOptions);
Vue.component("async-component", (resolve, reject) => { Vue.component("async-component", ((resolve, reject) => {
setTimeout(() => { setTimeout(() => {
resolve(Vue.component("component")); resolve(Vue.component("component"));
}, 0); }, 0);
return new Promise((resolve) => { return new Promise((resolve) => {
resolve({ functional: true } as FunctionalComponentOptions); resolve({ functional: true } as FunctionalComponentOptions);
}) })
}); }) as AsyncComponent);
Vue.component('async-es-module-component', (() => import('./es-module')) as AsyncComponent)

Loading…
Cancel
Save