Skip to content

Commit d956eed

Browse files
authored
Fix form type prompt (#6375)
* fix(FormITem): Change from ValidationRule to Rule * fix(FormI): from props type
1 parent e5e20cc commit d956eed

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

components/form/Form.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
Callbacks,
2525
ValidateMessages,
2626
Rule,
27+
FormLabelAlign,
2728
} from './interface';
2829
import { useInjectSize } from '../_util/hooks/useSize';
2930
import useConfigInject from '../_util/hooks/useConfigInject';
@@ -35,15 +36,12 @@ import { useInjectGlobalForm } from '../config-provider/context';
3536
export type RequiredMark = boolean | 'optional';
3637
export type FormLayout = 'horizontal' | 'inline' | 'vertical';
3738

38-
/** @deprecated Will warning in future branch. Pls use `Rule` instead. */
39-
export type ValidationRule = Rule;
40-
4139
export const formProps = () => ({
42-
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical')),
40+
layout: PropTypes.oneOf(tuple('horizontal', 'inline', 'vertical') as FormLayout[]),
4341
labelCol: { type: Object as PropType<ColProps & HTMLAttributes> },
4442
wrapperCol: { type: Object as PropType<ColProps & HTMLAttributes> },
4543
colon: { type: Boolean, default: undefined },
46-
labelAlign: PropTypes.oneOf(tuple('left', 'right')),
44+
labelAlign: PropTypes.oneOf(tuple('left', 'right') as FormLabelAlign[]),
4745
labelWrap: { type: Boolean, default: undefined },
4846
prefixCls: String,
4947
requiredMark: { type: [String, Boolean] as PropType<RequiredMark | ''>, default: undefined },

components/form/FormItem.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ import useConfigInject from '../_util/hooks/useConfigInject';
3232
import { useInjectForm } from './context';
3333
import FormItemLabel from './FormItemLabel';
3434
import FormItemInput from './FormItemInput';
35-
import type { ValidationRule } from './Form';
3635
import { useProvideFormItemContext } from './FormItemContext';
3736
import useDebounce from './utils/useDebounce';
3837

3938
const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
40-
export type ValidateStatus = typeof ValidateStatuses[number];
39+
export type ValidateStatus = (typeof ValidateStatuses)[number];
4140

4241
export interface FieldExpose {
4342
fieldValue: Ref<any>;
@@ -46,7 +45,7 @@ export interface FieldExpose {
4645
resetField: () => void;
4746
clearValidate: () => void;
4847
namePath: ComputedRef<InternalNamePath>;
49-
rules?: ComputedRef<ValidationRule[]>;
48+
rules?: ComputedRef<Rule[]>;
5049
validateRules: (options: ValidateOptions) => Promise<void> | Promise<RuleError[]>;
5150
}
5251

@@ -169,7 +168,7 @@ export default defineComponent({
169168
validateTrigger = validateTrigger === undefined ? 'change' : validateTrigger;
170169
return toArray(validateTrigger);
171170
});
172-
const rulesRef = computed<ValidationRule[]>(() => {
171+
const rulesRef = computed<Rule[]>(() => {
173172
let formRules = formContext.rules.value;
174173
const selfRules = props.rules;
175174
const requiredRule =

0 commit comments

Comments
 (0)