Skip to content

Commit 31776a2

Browse files
committed
fix: row ts type not work
1 parent 31ca070 commit 31776a2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

components/_util/type.ts

+8
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ export function eventType<T>() {
5050
export function objectType<T>(defaultVal?: any) {
5151
return { type: Object as PropType<T>, default: defaultVal as T };
5252
}
53+
54+
export function booleanType<T>(defaultVal?: any) {
55+
return { type: Boolean as PropType<T>, default: defaultVal as T };
56+
}
57+
58+
export function someType<T>(types: any[], defaultVal?: any) {
59+
return { type: types as PropType<T>, default: defaultVal as T };
60+
}

components/grid/Row.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExtractPropTypes, CSSProperties, PropType } from 'vue';
1+
import type { ExtractPropTypes, CSSProperties } from 'vue';
22
import { defineComponent, ref, onMounted, onBeforeUnmount, computed } from 'vue';
33
import classNames from '../_util/classNames';
44
import type { Breakpoint, ScreenMap } from '../_util/responsiveObserve';
@@ -7,6 +7,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
77
import useFlexGapSupport from '../_util/hooks/useFlexGapSupport';
88
import useProvideRow from './context';
99
import { useRowStyle } from './style';
10+
import { someType } from '../_util/type';
1011

1112
const RowAligns = ['top', 'middle', 'bottom', 'stretch'] as const;
1213
const RowJustify = [
@@ -34,13 +35,10 @@ export interface rowContextState {
3435
}
3536

3637
export const rowProps = () => ({
37-
align: [String, Object] as PropType<(typeof RowAligns)[number] | ResponsiveAligns>,
38-
justify: [String, Object] as PropType<(typeof RowJustify)[number] | ResponsiveJustify>,
38+
align: someType<(typeof RowAligns)[number] | ResponsiveAligns>([String, Object]),
39+
justify: someType<(typeof RowJustify)[number] | ResponsiveJustify>([String, Object]),
3940
prefixCls: String,
40-
gutter: {
41-
type: [Number, Array, Object] as PropType<Gutter | [Gutter, Gutter]>,
42-
default: 0 as Gutter | [Gutter, Gutter],
43-
},
41+
gutter: someType<Gutter | [Gutter, Gutter]>([Number, Array, Object], 0),
4442
wrap: { type: Boolean, default: undefined },
4543
});
4644

@@ -49,8 +47,8 @@ export type RowProps = Partial<ExtractPropTypes<ReturnType<typeof rowProps>>>;
4947
const ARow = defineComponent({
5048
compatConfig: { MODE: 3 },
5149
name: 'ARow',
52-
props: rowProps(),
5350
inheritAttrs: false,
51+
props: rowProps(),
5452
setup(props, { slots, attrs }) {
5553
const { prefixCls, direction } = useConfigInject('row', props);
5654
const [wrapSSR, hashId] = useRowStyle(prefixCls);

0 commit comments

Comments
 (0)