chore: update propTypes

This commit is contained in:
xiaoxian521 2023-03-01 20:03:47 +08:00
parent 1e30b31be2
commit 7678aa64e2

View File

@ -1,5 +1,10 @@
import { CSSProperties, VNodeChild } from "vue"; import type { CSSProperties, VNodeChild } from "vue";
import { createTypes, VueTypeValidableDef, VueTypesInterface } from "vue-types"; import {
createTypes,
toValidableType,
VueTypesInterface,
VueTypeValidableDef
} from "vue-types";
export type VueNode = VNodeChild | JSX.Element; export type VueNode = VNodeChild | JSX.Element;
@ -8,7 +13,7 @@ type PropTypes = VueTypesInterface & {
readonly VNodeChild: VueTypeValidableDef<VueNode>; readonly VNodeChild: VueTypeValidableDef<VueNode>;
}; };
const propTypes = createTypes({ const newPropTypes = createTypes({
func: undefined, func: undefined,
bool: undefined, bool: undefined,
string: undefined, string: undefined,
@ -17,18 +22,18 @@ 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
{ export default 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,
type: undefined
} }
]);
export { propTypes }; static get VNodeChild() {
return toValidableType("VNodeChild", {
type: undefined
});
}
}