Repository: vuejs/vue
Pull request: fix(types): support chain call

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [x] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [ ] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**

![image](https://user-images.githubusercontent.com/8424643/43619839-4a4e15ce-9702-11e8-9d6d-e81e8bf8b8d8.png)


Changed files:
filename: flow/global-api.js
patch: @@ -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;

filename: test/unit/features/global-api/mixin.spec.js
patch: @@ -162,4 +162,9 @@ describe('Global API: mixin', () => {
     expect(base).toHaveBeenCalled()
     expect(injected).toHaveBeenCalled()
   })
+
+  // #8595
+  it('chain call', () => {
+    expect(Vue.mixin({})).toBe(Vue)
+  })
 })

filename: test/unit/features/global-api/use.spec.js
patch: @@ -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)
+  })
 })

filename: types/test/vue-test.ts
patch: @@ -97,6 +97,15 @@ class Test extends Vue {
     this.use;
     this.mixin(Test);
     this.compile("<div>{{ message }}</div>");
+    this
+      .use(() => {
+        
+      })
+      .use(() => {
+        
+      })
+      .mixin({})
+      .mixin({});
   }
 }
 

filename: types/vue.d.ts
patch: @@ -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)[];