Open henribru opened 3 years ago
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?
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 thetypes
object nested inserializers
. This seems to be becauseblock
is defined as a required key here: https://github.com/rdunk/sanity-blocks-vue-component/blob/master/src/types.ts#L77. Though theserializers
prop is aPartial<Serializers>
,Partial
doesn't extend to nested objects, so it doesn't stopblock
from being required.