From 5da9b660bdfebf1d6e59f651952b59ff7f28602c Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 16 Oct 2023 15:09:13 +0800 Subject: [PATCH] perf: propTypes --- src/utils/propTypes.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/utils/propTypes.ts b/src/utils/propTypes.ts index fb8f84e7..863f55cc 100644 --- a/src/utils/propTypes.ts +++ b/src/utils/propTypes.ts @@ -1,12 +1,10 @@ -import { createTypes, VueTypesInterface, VueTypeValidableDef } from 'vue-types' +import { VueTypeValidableDef, VueTypesInterface, createTypes, toValidableType } from 'vue-types' import { CSSProperties } from 'vue' -// 自定义扩展vue-types type PropTypes = VueTypesInterface & { readonly style: VueTypeValidableDef } - -const propTypes = createTypes({ +const newPropTypes = createTypes({ func: undefined, bool: undefined, string: undefined, @@ -15,14 +13,12 @@ const propTypes = createTypes({ integer: undefined }) as PropTypes -// 需要自定义扩展的类型 -// see: https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method -// propTypes.extend([ -// { -// name: 'style', -// getter: true, -// type: [String, Object], -// default: undefined -// } -// ]) +class propTypes extends newPropTypes { + static get style() { + return toValidableType('style', { + type: [String, Object] + }) + } +} + export { propTypes }