wonderful-panda/vue-tsx-support

Mixins props is marked as required by typescript even tho I defined it as optional

Closed this issue · 7 comments

import PropTypes from 'vue-strict-prop';

export const textXsCenterMixin = {
  props: {
    textXsCenter: PropTypes(Boolean).optional,
  },
};
const Flex = componentFactory.mixin(textXsCenterMixin).create({ //...

image

Typescript complain Property 'textXsCenter' is missing in type

import * as tsx from "vue-tsx-support"; import p from "vue-strict-prop"; const Flex = tsx.mixin(textXsCenterMixin).create({ props: { textXsCenter: p(Boolean).optional, }, });

@eshimischi If i do that, i'm just duplicating the mixin.

@chanlito

const textXsCenterMixin should only consist of methods in that case, not props as you did above

Why not?

@chanlito If you want to use props in mixin, you must use tsx.component with mixin declaration.

import * as tsx from "vue-tsx-support";

export const textXsCenterMixin = tsx.component({
  props: {
    textXsCenter: PropTypes(Boolean).optional,
  },
});

const Flex = componentFactory.mixin(textXsCenterMixin).create({ //...

@wonderful-panda That works! Cheers.