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

fix(types): support chain call #8595

Merged
merged 15 commits into from
Dec 1, 2018
4 changes: 2 additions & 2 deletions flow/global-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ declare interface GlobalAPI {
set: <T>(target: Object | Array<T>, key: string | number, value: T) => T;
delete: <T>(target: Object| Array<T>, key: string | number) => void;
nextTick: (fn: Function, context?: Object) => void | Promise<*>;
use: (plugin: Function | Object) => void;
mixin: (mixin: Object) => void;
use: (plugin: Function | Object) => GlobalAPI;
mixin: (mixin: Object) => GlobalAPI;
compile: (template: string) => { render: Function, staticRenderFns: Array<Function> };

directive: (id: string, def?: Function | Object) => Function | Object | void;
Expand Down
5 changes: 5 additions & 0 deletions test/unit/features/global-api/mixin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,9 @@ describe('Global API: mixin', () => {
expect(base).toHaveBeenCalled()
expect(injected).toHaveBeenCalled()
})

// #8595
it('chain call', () => {
expect(Vue.mixin({})).toBe(Vue)
})
})
5 changes: 5 additions & 0 deletions test/unit/features/global-api/use.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ describe('Global API: use', () => {
expect(Vue.options.directives['plugin-test']).toBeUndefined()
expect(Ctor2.options.directives['plugin-test']).toBe(def)
})

// #8595
it('chain call', () => {
expect(Vue.use(() => {})).toBe(Vue)
})
})
9 changes: 9 additions & 0 deletions types/test/vue-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ class Test extends Vue {
this.use;
this.mixin(Test);
this.compile("<div>{{ message }}</div>");
this
.use(() => {

})
.use(() => {

})
.mixin({})
.mixin({});
}
}

Expand Down
6 changes: 3 additions & 3 deletions types/vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export interface VueConstructor<V extends Vue = Vue> {
component<Data, Methods, Computed, Props>(id: string, definition?: ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>;
component(id: string, definition?: ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>;

use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): void;
use(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): void;
mixin(mixin: VueConstructor | ComponentOptions<Vue>): void;
use<T>(plugin: PluginObject<T> | PluginFunction<T>, options?: T): this;
use(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): this;
mixin(mixin: VueConstructor | ComponentOptions<Vue>): this;
compile(template: string): {
render(createElement: typeof Vue.prototype.$createElement): VNode;
staticRenderFns: (() => VNode)[];
Expand Down