Please see this minimum example
If I write my props directly inside the component, everything is fine
<script lang="ts">
import Vue, { PropType } from "vue";
export default Vue.extend({
props: {
colorType: {
default: "primary" as const,
type: String as PropType<"primary" | "secondary" | "other">,
validator: (value) => ["primary", "secondary", "other"].includes(value),
},
},
});
</script>
However, if I extract the props definition outside, it will break types
<script lang="ts">
import Vue, { PropType } from "vue";
const colorType = {
default: "primary" as const,
type: String as PropType<"primary" | "secondary" | "other">,
validator: (value) => ["primary", "secondary", "other"].includes(value),
};
export default Vue.extend({
props: {
colorType,
},
});
</script>
How can I share those prop type definition accross Vue components without breaking TypeScript?
