File tree Expand file tree Collapse file tree 2 files changed +5
-17
lines changed
react-form-with-constraints-tools/src
react-form-with-constraints/src Expand file tree Collapse file tree 2 files changed +5
-17
lines changed Original file line number Diff line number Diff line change 9
9
FieldFeedbackType ,
10
10
FormWithConstraints ,
11
11
FormWithConstraintsChildContext ,
12
- HTMLInput ,
13
- isHTMLInput ,
14
- TextInput
12
+ isHTMLInput
15
13
} from 'react-form-with-constraints' ;
16
14
17
15
// Before:
@@ -74,9 +72,7 @@ function normalizeFieldElementProperty(fields: Field[]) {
74
72
const { element, ...otherProps } = field ;
75
73
return element
76
74
? {
77
- element : isHTMLInput ( element )
78
- ? ( element as HTMLInput ) . outerHTML
79
- : ( element as TextInput ) . props ,
75
+ element : isHTMLInput ( element ) ? element . outerHTML : element . props ,
80
76
...otherProps
81
77
}
82
78
: field ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export interface IHTMLInput {
56
56
readonly validationMessage : string ;
57
57
}
58
58
59
- export function isHTMLInput ( input : IHTMLInput | TextInput ) {
59
+ export function isHTMLInput ( input : IHTMLInput | TextInput ) : input is IHTMLInput {
60
60
return ( input as any ) . props === undefined ;
61
61
}
62
62
@@ -72,10 +72,6 @@ export class InputElement implements IHTMLInput {
72
72
73
73
constructor ( input : IHTMLInput | TextInput ) {
74
74
if ( isHTMLInput ( input ) ) {
75
- // FIXME
76
- // eslint-disable-next-line no-param-reassign
77
- input = input as IHTMLInput ;
78
-
79
75
this . name = input . name ;
80
76
this . type = input . type ;
81
77
this . value = input . value ;
@@ -91,13 +87,9 @@ export class InputElement implements IHTMLInput {
91
87
92
88
this . validationMessage = input . validationMessage ;
93
89
} else {
94
- // FIXME
95
- // eslint-disable-next-line no-param-reassign
96
- input = input as TextInput ;
97
-
98
- this . name = input . props ! . name ;
90
+ this . name = input . props . name ;
99
91
this . type = undefined as any ;
100
- this . value = input . props ! . value ! ; // Tested: TextInput props.value is always a string and never undefined (empty string instead)
92
+ this . value = input . props . value ! ; // Tested: TextInput props.value is always a string and never undefined (empty string instead)
101
93
this . validity = undefined as any ;
102
94
this . validationMessage = undefined as any ;
103
95
}
You can’t perform that action at this time.
0 commit comments