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 99 FieldFeedbackType ,
1010 FormWithConstraints ,
1111 FormWithConstraintsChildContext ,
12- HTMLInput ,
13- isHTMLInput ,
14- TextInput
12+ isHTMLInput
1513} from 'react-form-with-constraints' ;
1614
1715// Before:
@@ -74,9 +72,7 @@ function normalizeFieldElementProperty(fields: Field[]) {
7472 const { element, ...otherProps } = field ;
7573 return element
7674 ? {
77- element : isHTMLInput ( element )
78- ? ( element as HTMLInput ) . outerHTML
79- : ( element as TextInput ) . props ,
75+ element : isHTMLInput ( element ) ? element . outerHTML : element . props ,
8076 ...otherProps
8177 }
8278 : field ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export interface IHTMLInput {
5656 readonly validationMessage : string ;
5757}
5858
59- export function isHTMLInput ( input : IHTMLInput | TextInput ) {
59+ export function isHTMLInput ( input : IHTMLInput | TextInput ) : input is IHTMLInput {
6060 return ( input as any ) . props === undefined ;
6161}
6262
@@ -72,10 +72,6 @@ export class InputElement implements IHTMLInput {
7272
7373 constructor ( input : IHTMLInput | TextInput ) {
7474 if ( isHTMLInput ( input ) ) {
75- // FIXME
76- // eslint-disable-next-line no-param-reassign
77- input = input as IHTMLInput ;
78-
7975 this . name = input . name ;
8076 this . type = input . type ;
8177 this . value = input . value ;
@@ -91,13 +87,9 @@ export class InputElement implements IHTMLInput {
9187
9288 this . validationMessage = input . validationMessage ;
9389 } 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 ;
9991 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)
10193 this . validity = undefined as any ;
10294 this . validationMessage = undefined as any ;
10395 }
You can’t perform that action at this time.
0 commit comments