@@ -678,6 +678,18 @@ export type Props = $ReadOnly<{|
678678 contextMenuHidden ?: ?boolean ,
679679| } > ;
680680
681+ type DefaultProps = $ReadOnly < { |
682+ allowFontScaling : boolean ,
683+ rejectResponderTermination : boolean ,
684+ underlineColorAndroid : 'transparent' ,
685+ | } > ;
686+
687+ type State = { |
688+ currentlyFocusedField : typeof TextInputState . currentlyFocusedField ,
689+ focusTextInput : typeof TextInputState . focusTextInput ,
690+ blurTextInput : typeof TextInputState . blurTextInput ,
691+ | } ;
692+
681693const emptyFunctionThatReturnsTrue = ( ) => true ;
682694
683695/**
@@ -791,16 +803,16 @@ const emptyFunctionThatReturnsTrue = () => true;
791803 * or control this param programmatically with native code.
792804 *
793805 */
794- class TextInput extends React . Component < Props > {
795- static defaultProps = {
806+ class TextInput extends React . Component < Props , State > {
807+ static defaultProps : DefaultProps = {
796808 allowFontScaling : true ,
797809 rejectResponderTermination : true ,
798810 underlineColorAndroid : 'transparent' ,
799811 } ;
800812
801813 static propTypes = DeprecatedTextInputPropTypes ;
802814
803- static State = {
815+ static State : State = {
804816 currentlyFocusedField : TextInputState . currentlyFocusedField ,
805817 focusTextInput : TextInputState . focusTextInput ,
806818 blurTextInput : TextInputState . blurTextInput ,
@@ -876,52 +888,54 @@ class TextInput extends React.Component<Props> {
876888 /**
877889 * Removes all text from the `TextInput`.
878890 */
879- clear = ( ) = > {
891+ clear : ( ) => void = ( ) => {
880892 this . setNativeProps ( { text : '' } ) ;
881893 } ;
882894
883895 /**
884896 * Returns `true` if the input is currently focused; `false` otherwise.
885897 */
886- isFocused = ( ) : boolean => {
898+ isFocused : ( ) => boolean = ( ) => {
887899 return (
888900 TextInputState . currentlyFocusedField ( ) ===
889901 ReactNative . findNodeHandle ( this . _inputRef )
890902 ) ;
891903 } ;
892904
893- getNativeRef = ( ) : ?React . ElementRef < HostComponent < mixed >> => {
905+ getNativeRef : ( ) => ?React . ElementRef < HostComponent < mixed >> = ( ) => {
894906 return this . _inputRef ;
895907 } ;
896908
897909 // From NativeMethodsMixin
898910 // We need these instead of using forwardRef because we also have the other
899911 // methods we expose
900- blur = ( ) => {
912+ blur : ( ) => void = ( ) => {
901913 this . _inputRef && this . _inputRef . blur ( ) ;
902914 } ;
903- focus = ( ) => {
915+ focus : ( ) => void = ( ) => {
904916 this . _inputRef && this . _inputRef . focus ( ) ;
905917 } ;
906- measure = ( callback : MeasureOnSuccessCallback ) => {
918+ measure : ( callback : MeasureOnSuccessCallback ) => void = callback => {
907919 this . _inputRef && this . _inputRef . measure ( callback ) ;
908920 } ;
909- measureInWindow = ( callback : MeasureInWindowOnSuccessCallback ) => {
921+ measureInWindow : (
922+ callback : MeasureInWindowOnSuccessCallback ,
923+ ) => void = callback => {
910924 this . _inputRef && this . _inputRef . measureInWindow ( callback ) ;
911925 } ;
912- measureLayout = (
926+ measureLayout : (
913927 relativeToNativeNode : number | React . ElementRef < HostComponent < mixed >> ,
914928 onSuccess : MeasureLayoutOnSuccessCallback ,
915929 onFail ?: ( ) => void ,
916- ) => {
930+ ) => void = ( relativeToNativeNode , onSuccess , onFail ) => {
917931 this . _inputRef &&
918932 this . _inputRef . measureLayout ( relativeToNativeNode , onSuccess , onFail ) ;
919933 } ;
920- setNativeProps = ( nativeProps : Object ) => {
934+ setNativeProps : ( nativeProps : Object ) => void = nativeProps => {
921935 this . _inputRef && this . _inputRef . setNativeProps ( nativeProps ) ;
922936 } ;
923937
924- render ( ) {
938+ render ( ) : React . Node {
925939 let textInput = null ;
926940 let additionalTouchableProps : { |
927941 rejectResponderTermination ?: $PropertyType <
0 commit comments