runtime.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. import { EpProp, EpPropConvert, EpPropFinalized, EpPropInput, EpPropMergeType, IfEpProp, IfNativePropType, NativePropType } from "./types.js";
  2. import { PropType } from "vue";
  3. //#region ../../packages/utils/vue/props/runtime.d.ts
  4. declare const epPropKey = "__epPropKey";
  5. declare const definePropType: <T>(val: any) => PropType<T>;
  6. declare const isEpProp: (val: unknown) => val is EpProp<any, any, any>;
  7. /**
  8. * @description Build prop. It can better optimize prop types
  9. * @description 生成 prop,能更好地优化类型
  10. * @example
  11. // limited options
  12. // the type will be PropType<'light' | 'dark'>
  13. buildProp({
  14. type: String,
  15. values: ['light', 'dark'],
  16. } as const)
  17. * @example
  18. // limited options and other types
  19. // the type will be PropType<'small' | 'large' | number>
  20. buildProp({
  21. type: [String, Number],
  22. values: ['small', 'large'],
  23. validator: (val: unknown): val is number => typeof val === 'number',
  24. } as const)
  25. @link see more: https://github.com/element-plus/element-plus/pull/3341
  26. */
  27. declare const buildProp: <Type = never, Value = never, Validator = never, Default extends EpPropMergeType<Type, Value, Validator> = never, Required extends boolean = false>(prop: EpPropInput<Type, Value, Validator, Default, Required>, key?: string) => EpPropFinalized<Type, Value, Validator, Default, Required>;
  28. declare const buildProps: <Props extends Record<string, {
  29. [epPropKey]: true;
  30. } | NativePropType | EpPropInput<any, any, any, any, any>>>(props: Props) => { [K in keyof Props]: IfEpProp<Props[K], Props[K], IfNativePropType<Props[K], Props[K], EpPropConvert<Props[K]>>> };
  31. //#endregion
  32. export { buildProp, buildProps, definePropType, epPropKey, isEpProp };