sanity-blocks-vue-component
sanity-blocks-vue-component copied to clipboard
Example in readme doesn't typecheck
Using e.g. vue-tsc to get typechecking in Vue templates the example in the readme doesn't actually typecheck. Specifically you'll get an error that the key block is missing from the types object nested in serializers. This seems to be because block is defined as a required key here: https://github.com/rdunk/sanity-blocks-vue-component/blob/master/src/types.ts#L77. Though the serializers prop is a Partial<Serializers>, Partial doesn't extend to nested objects, so it doesn't stop block from being required.
Perhaps I could use DeepPartial for the prop type? e.g.
type DeepPartial<T> = T extends Function
? T
: T extends object
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
export const SanityBlocks = defineComponent({
...
props: {
serializers: {
type: Object as PropType<DeepPartial<Serializers>>,
default: () => ({}),
},
},
...
});
What do you think?