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