Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Commit b2f66bd

Browse files
committed
fix readme and build warning
1 parent 30c5fcb commit b2f66bd

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.DS_Store
55
.AppleDouble
66
.LSOverride
7+
.idea
78

89
# Icon must end with two \r
910
Icon
@@ -192,4 +193,4 @@ dist
192193
.tern-port
193194

194195
# Stores VSCode versions used for testing VSCode extensions
195-
.vscode-test
196+
.vscode-test

README.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ import { useForm } from "react-hook-form";
3030
import { TextField, Checkbox } from "@material-ui/core";
3131

3232
type FormValues = {
33-
uncontrolled: string;
34-
controlled: string;
33+
flatType: string;
3534
nested: {
36-
uncontrolled: { test: string };
37-
controlled: { test: boolean }[];
35+
objectType: { test: string };
36+
arrayType: { test: boolean }[];
3837
};
39-
error: string;
4038
};
4139

4240
export default function App() {
@@ -47,51 +45,46 @@ export default function App() {
4745

4846
return (
4947
<form onSubmit={onSubmit}>
50-
{/* Uncontrolled Component */}
5148
<TypedController
52-
as="textarea"
53-
name={["nested", "uncontrolled", "test"]}
49+
name="flat"
5450
defaultValue=""
55-
rules={{ required: true }}
51+
render={(props) => <TextField {...props} />}
5652
/>
57-
58-
{/* Controlled Component */}
53+
5954
<TypedController
60-
name="controlled"
55+
as="textarea"
56+
name={["nested", "objectType", "test"]}
6157
defaultValue=""
62-
render={(props) => <TextField {...props} />}
58+
rules={{ required: true }}
6359
/>
64-
60+
6561
<TypedController
66-
name={["nested", "controlled", 0, "test"]}
62+
name={["nested", "arrayType", 0, "test"]}
6763
defaultValue={false}
68-
rules={{
69-
validate: (value) => value, // (parameter) value: boolean
70-
}}
7164
render={(props) => <Checkbox {...props} />}
7265
/>
73-
66+
7467
{/* ❌: Type '"notExists"' is not assignable to type 'DeepPath<FormValues, "notExists">'. */}
7568
<TypedController
7669
as="input"
77-
name="notExists"
70+
name="notExists"
7871
defaultValue=""
7972
/>
80-
81-
{/* ❌: Type '(string | number)[]' is not assignable to type 'DeepPath<FormValues, ["nested", "controlled", 0, "notExists"]>'. */}
73+
74+
{/* ❌: Type '(string | number)[]' is not assignable to type 'DeepPath<FormValues, ["nested", "objectType", 0, "notExists"]>'. */}
8275
<TypedController
8376
as="input"
84-
name={["nested", "controlled", 0, "notExists"]}
77+
name={["nested", "objectType", 0, "notExists"]}
8578
defaultValue=""
8679
/>
87-
80+
8881
{/* ❌: Type 'true' is not assignable to type 'string | undefined'. */}
8982
<TypedController
9083
as="input"
91-
name="error"
84+
name="flatType"
9285
defaultValue={true}
9386
/>
94-
87+
9588
<input type="submit" />
9689
</form>
9790
);

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@
9090
"npm run lint:fix"
9191
],
9292
"*.{md,json}": [
93-
"prettier --write",
94-
"git add"
93+
"prettier --write"
9594
]
9695
}
9796
}

0 commit comments

Comments
 (0)