refactor: Form support namePath type check (#43904)

* chore: up form

* chore: test
This commit is contained in:
叶枫 2023-07-31 11:18:02 +08:00 committed by GitHub
parent b1394ec1a1
commit 8a165947d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -9,6 +9,12 @@ const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
type FieldType = {
username?: string;
password?: string;
remember?: string;
};
const App: React.FC = () => (
<Form
name="basic"
@ -20,7 +26,7 @@ const App: React.FC = () => (
onFinishFailed={onFinishFailed}
autoComplete="off"
>
<Form.Item
<Form.Item<FieldType>
label="Username"
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
@ -28,7 +34,7 @@ const App: React.FC = () => (
<Input />
</Form.Item>
<Form.Item
<Form.Item<FieldType>
label="Password"
name="password"
rules={[{ required: true, message: 'Please input your password!' }]}
@ -36,7 +42,11 @@ const App: React.FC = () => (
<Input.Password />
</Form.Item>
<Form.Item name="remember" valuePropName="checked" wrapperCol={{ offset: 8, span: 16 }}>
<Form.Item<FieldType>
name="remember"
valuePropName="checked"
wrapperCol={{ offset: 8, span: 16 }}
>
<Checkbox>Remember me</Checkbox>
</Form.Item>

View File

@ -128,7 +128,7 @@
"rc-dialog": "~9.1.0",
"rc-drawer": "~6.2.0",
"rc-dropdown": "~4.1.0",
"rc-field-form": "~1.35.0",
"rc-field-form": "~1.36.0",
"rc-image": "~7.1.0",
"rc-input": "~1.1.0",
"rc-input-number": "~8.0.2",