Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb007377

Browse files
committed
refactor: strong type for getFormHelpers name
1 parent88e30be commitb007377

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎site/src/components/Form/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ interface FormHelpers {
1717
helperText?:string
1818
}
1919

20-
exportconstgetFormHelpers=<T>(form:FormikContextType<T>,name:string,error?:string):FormHelpers=>{
21-
// getIn is a util function from Formik that gets at any depth of nesting, and is necessary for the types to work
20+
exportconstgetFormHelpers=<T>(form:FormikContextType<T>,name:keyofT,error?:string):FormHelpers=>{
21+
if(typeofname!=="string"){
22+
thrownewError(`name must be type of string, instead received '${typeofname}'`)
23+
}
24+
25+
// getIn is a util function from Formik that gets at any depth of nesting
26+
// and is necessary for the types to work
2227
consttouched=getIn(form.touched,name)
2328
consterrors=error??getIn(form.errors,name)
2429
return{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp