Skip to content

[TSX] Optional props(with default) from mixins or extends are treated as required  #2039

Closed
@wonderful-panda

Description

@wonderful-panda

Version

3.0.0-rc.9

Reproduction link

https://github.com/wonderful-panda/vue-next/blob/tsx-typeerror/test-dts/defineComponent.test-d.tsx#L667-L669

Steps to reproduce

  1. checkout tsx-typeerror branch of wonderful-panda/vue-next
  2. Run build and test-dts

Below code is a simplified example.
mP1 should be optional, but treated as required in TSX.

const Mixin = defineComponent({
  props: {
      mP1: { type: String, default: "a" }
  }
})

const MyComponent = defineComponent({
  mixins: [Mixin]
}

const elm = <MyComponent /> // TS2322 Property 'mP1' is missing


/* extends also has same problem */

const MyComponent2 = defineComponent({
  extends: Mixin
}

const elm = <MyComponent2 /> // TS2322 Property 'mP1' is missing

What is expected?

no error (mP1 is treated as optional)

What is actually happening?

mP1 is treated as required and compilation error TS2322 occurred.

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