diff --git a/flow/global-api.js b/flow/global-api.js index 0b2efb23ac3..eab244c22bb 100644 --- a/flow/global-api.js +++ b/flow/global-api.js @@ -8,8 +8,8 @@ declare interface GlobalAPI { set: (target: Object | Array, key: string | number, value: T) => T; delete: (target: Object| Array, 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 }; directive: (id: string, def?: Function | Object) => Function | Object | void; diff --git a/test/unit/features/global-api/mixin.spec.js b/test/unit/features/global-api/mixin.spec.js index bcf962402c2..0b83773a5d4 100644 --- a/test/unit/features/global-api/mixin.spec.js +++ b/test/unit/features/global-api/mixin.spec.js @@ -162,4 +162,9 @@ describe('Global API: mixin', () => { expect(base).toHaveBeenCalled() expect(injected).toHaveBeenCalled() }) + + // #8595 + it('chain call', () => { + expect(Vue.mixin({})).toBe(Vue) + }) }) diff --git a/test/unit/features/global-api/use.spec.js b/test/unit/features/global-api/use.spec.js index 00053f808a7..d54ff0750f3 100644 --- a/test/unit/features/global-api/use.spec.js +++ b/test/unit/features/global-api/use.spec.js @@ -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) + }) }) diff --git a/types/test/vue-test.ts b/types/test/vue-test.ts index 326969c1637..6fe0e56182c 100644 --- a/types/test/vue-test.ts +++ b/types/test/vue-test.ts @@ -97,6 +97,15 @@ class Test extends Vue { this.use; this.mixin(Test); this.compile("
{{ message }}
"); + this + .use(() => { + + }) + .use(() => { + + }) + .mixin({}) + .mixin({}); } } diff --git a/types/vue.d.ts b/types/vue.d.ts index 179fb5fe38e..29667ead1f6 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -111,9 +111,9 @@ export interface VueConstructor { component(id: string, definition: FunctionalComponentOptions>): ExtendedVue; component(id: string, definition?: ComponentOptions): ExtendedVue; - use(plugin: PluginObject | PluginFunction, options?: T): void; - use(plugin: PluginObject | PluginFunction, ...options: any[]): void; - mixin(mixin: VueConstructor | ComponentOptions): void; + use(plugin: PluginObject | PluginFunction, options?: T): this; + use(plugin: PluginObject | PluginFunction, ...options: any[]): this; + mixin(mixin: VueConstructor | ComponentOptions): this; compile(template: string): { render(createElement: typeof Vue.prototype.$createElement): VNode; staticRenderFns: (() => VNode)[];