Subscribe on changes!

Mixin types are not merged correctly for methods

avatar
Mar 23rd 2021

Version

3.0.7

Reproduction link

https://codesandbox.io/s/youthful-keldysh-r3e0h?file=/src/index.ts

Steps to reproduce

See the following code:

import { defineComponent } from "vue";

defineComponent({
  mixins: [
    defineComponent({ methods: { foo() {} } }),
    defineComponent({ methods: { bar() {} } })
  ],
  mounted () {
    console.log(this.foo, this.bar)
  }
})

defineComponent({
  mixins: [
    defineComponent({ methods: { foo() {} } }),
    defineComponent({})
  ],
  mounted () {
    console.log(this.foo) // Property 'foo' does not exist on type ...
  }
})

If two mixins both have defined some method, the result type is correctly merged. Otherwise all method types will be unavailable.

What is expected?

Method types are correctly merged.

What is actually happening?

If two mixins both have defined some method, the result type is correctly merged. Otherwise all method types will be unavailable.