propTypes.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { CSSProperties, VNodeChild } from 'vue';
  2. import { createTypes, VueTypeValidableDef, VueTypesInterface, toValidableType } from 'vue-types';
  3. export type VueNode = VNodeChild | JSX.Element;
  4. type PropTypes = VueTypesInterface & {
  5. readonly style: VueTypeValidableDef<CSSProperties>;
  6. readonly VNodeChild: VueTypeValidableDef<VueNode>;
  7. // readonly trueBool: VueTypeValidableDef<boolean>;
  8. };
  9. const newPropTypes = createTypes({
  10. func: undefined,
  11. bool: undefined,
  12. string: undefined,
  13. number: undefined,
  14. object: undefined,
  15. integer: undefined,
  16. }) as PropTypes;
  17. // 从 vue-types v5.0 开始,extend()方法已经废弃,当前已改为官方推荐的ES6+方法 https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method
  18. class propTypes extends newPropTypes {
  19. // a native-like validator that supports the `.validable` method
  20. static get style() {
  21. return toValidableType('style', {
  22. type: [String, Object],
  23. });
  24. }
  25. static get VNodeChild() {
  26. return toValidableType('VNodeChild', {
  27. type: undefined,
  28. });
  29. }
  30. }
  31. export { propTypes };