Permalink
Browse files

fix(types): support chain call for Vue.use and Vue.mixin (#8595)

  • Loading branch information...
lzxb authored and yyx990803 committed Dec 1, 2018
1 parent 613cb52 commit c711ec189aaf46399756e34d933ba5e0b6576c36
Showing with 24 additions and 5 deletions.
  1. +2 βˆ’2 flow/global-api.js
  2. +5 βˆ’0 test/unit/features/global-api/mixin.spec.js
  3. +5 βˆ’0 test/unit/features/global-api/use.spec.js
  4. +9 βˆ’0 types/test/vue-test.ts
  5. +3 βˆ’3 types/vue.d.ts
@@ -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;
@@ -162,4 +162,9 @@ describe('Global API: mixin', () => {
expect(base).toHaveBeenCalled()
expect(injected).toHaveBeenCalled()
})
// #8595
it('chain call', () => {
expect(Vue.mixin({})).toBe(Vue)
})
})
@@ -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)
})
})
@@ -97,6 +97,15 @@ class Test extends Vue {
this.use;
this.mixin(Test);
this.compile("<div>{{ message }}</div>");
this
.use(() => {
})
.use(() => {
})
.mixin({})
.mixin({});
}
}
@@ -111,9 +111,9 @@ export interface VueConstructor<V extends Vue = Vue> {
component<Props>(id: string, definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>): ExtendedVue<V, {}, {}, {}, 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)[];

0 comments on commit c711ec1

Please sign in to comment.