Having trouble with the type of Object properties in Vue Single File Components using TypeScript (created with Vue CLI 3)? Check out the example below to see the issue.
The type of this.product
is currently showing as
(() => any) | ComputedOptions<any>
. Seeking a solution, does anyone have any suggestions?
<script lang="ts">
import Vue, { PropType } from 'vue';
interface ProductInterface {
units: number;
}
export default Vue.extend({
name: 'Product',
props: {
product: {
type: Object as PropType<ProductInterface>,
required: true,
},
},
computed: {
unitsString() {
return `${this.product.units} Units`;
},
},
});
</script>