mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 13:47:02 +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];
|
export type ValidateStatus = typeof ValidateStatuses[number];
|
||||||
|
|
||||||
type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
|
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;
|
type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
|
||||||
|
|
||||||
interface MemoInputProps {
|
interface MemoInputProps {
|
||||||
@ -43,7 +43,7 @@ const MemoInput = React.memo(
|
|||||||
export interface FormItemProps<Values = any>
|
export interface FormItemProps<Values = any>
|
||||||
extends FormItemLabelProps,
|
extends FormItemLabelProps,
|
||||||
FormItemInputProps,
|
FormItemInputProps,
|
||||||
RcFieldProps {
|
RcFieldProps<Values> {
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
noStyle?: boolean;
|
noStyle?: boolean;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
|
@ -73,8 +73,10 @@ describe('Form.typescript', () => {
|
|||||||
<Form<FormValues>>
|
<Form<FormValues>>
|
||||||
<Form.Item<FormValues>>
|
<Form.Item<FormValues>>
|
||||||
{({ getFieldsValue }) => {
|
{({ getFieldsValue }) => {
|
||||||
const values: FormValues = getFieldsValue();
|
const values = getFieldsValue();
|
||||||
expect(values).toBeTruthy();
|
expect(values).toBeTruthy();
|
||||||
|
expect(values.username).toBeTruthy();
|
||||||
|
expect(values.path1?.path2).toBeTruthy();
|
||||||
return null;
|
return null;
|
||||||
}}
|
}}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
Loading…
Reference in New Issue
Block a user