import { VueTypeValidableDef, VueTypeDef } from 'vue-types'; const initDefaultProps = ( types: T, defaultProps: { [K in keyof T]?: T[K] extends VueTypeValidableDef ? U : T[K] extends VueTypeDef ? U : any; }, ): T => { const propTypes = { ...types }; Object.keys(defaultProps).forEach(k => { const prop = propTypes[k] as VueTypeValidableDef; if (prop) { prop.default = defaultProps[k]; } else { throw new Error(`not have ${k} prop`); } }); return propTypes; }; export default initDefaultProps;