Skip to content

Commit 5da9b66

Browse files
committed
perf: propTypes
1 parent 1a1b70a commit 5da9b66

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/utils/propTypes.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { createTypes, VueTypesInterface, VueTypeValidableDef } from 'vue-types'
1+
import { VueTypeValidableDef, VueTypesInterface, createTypes, toValidableType } from 'vue-types'
22
import { CSSProperties } from 'vue'
33

4-
// 自定义扩展vue-types
54
type PropTypes = VueTypesInterface & {
65
readonly style: VueTypeValidableDef<CSSProperties>
76
}
8-
9-
const propTypes = createTypes({
7+
const newPropTypes = createTypes({
108
func: undefined,
119
bool: undefined,
1210
string: undefined,
@@ -15,14 +13,12 @@ const propTypes = createTypes({
1513
integer: undefined
1614
}) as PropTypes
1715

18-
// 需要自定义扩展的类型
19-
// see: https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method
20-
// propTypes.extend([
21-
// {
22-
// name: 'style',
23-
// getter: true,
24-
// type: [String, Object],
25-
// default: undefined
26-
// }
27-
// ])
16+
class propTypes extends newPropTypes {
17+
static get style() {
18+
return toValidableType('style', {
19+
type: [String, Object]
20+
})
21+
}
22+
}
23+
2824
export { propTypes }

0 commit comments

Comments
 (0)