When using Object properties in Vue Single File Components in TypeScript (generated with Vue CLI 3), the type of the prop is not correct, as shown by the minimal example below.
The type of this.product is (() => any) | ComputedOptions<any>. Does anyone know of a solution to this?
<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>