mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 19:50:05 +08:00
fix: form.item is not type safe due to not forwarding their type para… (#29397)
* fix: form.item is not type safe due to not forwarding their type parameters to the rcForm components * test: add test cases
This commit is contained in:
parent
52bbca4047
commit
4ad6a55474
@ -26,7 +26,7 @@ const ValidateStatuses = tuple('success', 'warning', 'error', 'validating', '');
|
||||
export type ValidateStatus = typeof ValidateStatuses[number];
|
||||
|
||||
type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
|
||||
type RcFieldProps = Omit<FieldProps, 'children'>;
|
||||
type RcFieldProps<Values = any> = Omit<FieldProps<Values>, 'children'>;
|
||||
type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
|
||||
|
||||
interface MemoInputProps {
|
||||
@ -43,7 +43,7 @@ const MemoInput = React.memo(
|
||||
export interface FormItemProps<Values = any>
|
||||
extends FormItemLabelProps,
|
||||
FormItemInputProps,
|
||||
RcFieldProps {
|
||||
RcFieldProps<Values> {
|
||||
prefixCls?: string;
|
||||
noStyle?: boolean;
|
||||
style?: React.CSSProperties;
|
||||
|
@ -73,8 +73,10 @@ describe('Form.typescript', () => {
|
||||
<Form<FormValues>>
|
||||
<Form.Item<FormValues>>
|
||||
{({ getFieldsValue }) => {
|
||||
const values: FormValues = getFieldsValue();
|
||||
const values = getFieldsValue();
|
||||
expect(values).toBeTruthy();
|
||||
expect(values.username).toBeTruthy();
|
||||
expect(values.path1?.path2).toBeTruthy();
|
||||
return null;
|
||||
}}
|
||||
</Form.Item>
|
||||
|
Loading…
Reference in New Issue
Block a user