Subscribe on changes!

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

avatar
Sep 2nd 2020

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.

avatar
Apr 13th 2021

This issue no longer exists in the latest version