Skip to content

Mixin types are not merged correctly for methods #3468

Closed
@Justineo

Description

@Justineo

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions