fix: row ts type not work

pull/6222/head
tangjinzhou 2023-01-31 22:37:36 +08:00
parent 31ca070a18
commit 31776a2cf8
2 changed files with 14 additions and 8 deletions

View File

@ -50,3 +50,11 @@ export function eventType<T>() {
export function objectType<T>(defaultVal?: any) {
return { type: Object as PropType<T>, default: defaultVal as T };
}
export function booleanType<T>(defaultVal?: any) {
return { type: Boolean as PropType<T>, default: defaultVal as T };
}
export function someType<T>(types: any[], defaultVal?: any) {
return { type: types as PropType<T>, default: defaultVal as T };
}

View File

@ -1,4 +1,4 @@
import type { ExtractPropTypes, CSSProperties, PropType } from 'vue';
import type { ExtractPropTypes, CSSProperties } from 'vue';
import { defineComponent, ref, onMounted, onBeforeUnmount, computed } from 'vue';
import classNames from '../_util/classNames';
import type { Breakpoint, ScreenMap } from '../_util/responsiveObserve';
@ -7,6 +7,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
import useFlexGapSupport from '../_util/hooks/useFlexGapSupport';
import useProvideRow from './context';
import { useRowStyle } from './style';
import { someType } from '../_util/type';
const RowAligns = ['top', 'middle', 'bottom', 'stretch'] as const;
const RowJustify = [
@ -34,13 +35,10 @@ export interface rowContextState {
}
export const rowProps = () => ({
align: [String, Object] as PropType<(typeof RowAligns)[number] | ResponsiveAligns>,
justify: [String, Object] as PropType<(typeof RowJustify)[number] | ResponsiveJustify>,
align: someType<(typeof RowAligns)[number] | ResponsiveAligns>([String, Object]),
justify: someType<(typeof RowJustify)[number] | ResponsiveJustify>([String, Object]),
prefixCls: String,
gutter: {
type: [Number, Array, Object] as PropType<Gutter | [Gutter, Gutter]>,
default: 0 as Gutter | [Gutter, Gutter],
},
gutter: someType<Gutter | [Gutter, Gutter]>([Number, Array, Object], 0),
wrap: { type: Boolean, default: undefined },
});
@ -49,8 +47,8 @@ export type RowProps = Partial<ExtractPropTypes<ReturnType<typeof rowProps>>>;
const ARow = defineComponent({
compatConfig: { MODE: 3 },
name: 'ARow',
props: rowProps(),
inheritAttrs: false,
props: rowProps(),
setup(props, { slots, attrs }) {
const { prefixCls, direction } = useConfigInject('row', props);
const [wrapSSR, hashId] = useRowStyle(prefixCls);