未验证 提交 02d41197 编写于 作者: ufo025174's avatar ufo025174 提交者: GitHub

fix: propTypes.extend()方法已经废弃, 改为官方推荐的ES6+方法 (#2670)

Co-authored-by: N苗大 <caoshengmiao@hypergryph.com>
上级 84a5fc12
import { CSSProperties, VNodeChild } from 'vue'; import { CSSProperties, VNodeChild } from 'vue';
import { createTypes, VueTypeValidableDef, VueTypesInterface } from 'vue-types'; import { createTypes, VueTypeValidableDef, VueTypesInterface, toValidableType } from 'vue-types';
export type VueNode = VNodeChild | JSX.Element; export type VueNode = VNodeChild | JSX.Element;
...@@ -8,8 +8,7 @@ type PropTypes = VueTypesInterface & { ...@@ -8,8 +8,7 @@ type PropTypes = VueTypesInterface & {
readonly VNodeChild: VueTypeValidableDef<VueNode>; readonly VNodeChild: VueTypeValidableDef<VueNode>;
// readonly trueBool: VueTypeValidableDef<boolean>; // readonly trueBool: VueTypeValidableDef<boolean>;
}; };
const newPropTypes = createTypes({
const propTypes = createTypes({
func: undefined, func: undefined,
bool: undefined, bool: undefined,
string: undefined, string: undefined,
...@@ -18,17 +17,19 @@ const propTypes = createTypes({ ...@@ -18,17 +17,19 @@ const propTypes = createTypes({
integer: undefined, integer: undefined,
}) as PropTypes; }) as PropTypes;
propTypes.extend([ // 从 vue-types v5.0 开始,extend()方法已经废弃,当前已改为官方推荐的ES6+方法 https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method
{ class propTypes extends newPropTypes {
name: 'style', // a native-like validator that supports the `.validable` method
getter: true, static get style() {
type: [String, Object], return toValidableType('style', {
default: undefined, type: [String, Object],
}, });
{ }
name: 'VNodeChild',
getter: true, static get VNodeChild() {
type: undefined, return toValidableType('VNodeChild', {
}, type: undefined,
]); });
}
}
export { propTypes }; export { propTypes };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册