Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add EsModuleComponent definition #6477

Merged
merged 5 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/unit/features/component/component-slot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ describe('Component slot', () => {
</div><bar/>
</test-component>
</div>
`,
`,
components: {
TestComponent,
foo: {
Expand Down
7 changes: 6 additions & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions types/test/es-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
data() {
return {}
}
}
8 changes: 5 additions & 3 deletions types/test/options-test.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)