14
14
15
15
const NativeMethodsMixin = require ( 'NativeMethodsMixin' ) ;
16
16
const React = require ( 'React' ) ;
17
+ const ReactNative = require ( 'ReactNative' ) ;
17
18
const PropTypes = require ( 'prop-types' ) ;
18
19
const StyleSheet = require ( 'StyleSheet' ) ;
19
20
const StyleSheetPropType = require ( 'StyleSheetPropType' ) ;
@@ -26,6 +27,17 @@ const createReactClass = require('create-react-class');
26
27
const itemStylePropType = StyleSheetPropType ( TextStylePropTypes ) ;
27
28
const requireNativeComponent = require ( 'requireNativeComponent' ) ;
28
29
30
+ import type { ColorValue } from 'StyleSheetTypes' ;
31
+ import type { ViewProps } from 'ViewPropTypes' ;
32
+
33
+ type Props = $ReadOnly < { |
34
+ ...ViewProps ,
35
+ color ?: ?ColorValue ,
36
+ label : string ,
37
+ testID ?: ?string ,
38
+ value ?: ?any ,
39
+ | } > ;
40
+
29
41
const PickerIOS = createReactClass ( {
30
42
displayName : 'PickerIOS' ,
31
43
mixins : [ NativeMethodsMixin ] ,
@@ -106,7 +118,13 @@ const PickerIOS = createReactClass({
106
118
} ,
107
119
} ) ;
108
120
109
- PickerIOS . Item = class extends React . Component {
121
+ PickerIOS . Item = class extends React . Component <
122
+ $ReadOnly < { |
123
+ label : string ,
124
+ value ?: ?any ,
125
+ color ?: ?ColorValue ,
126
+ | } > ,
127
+ > {
110
128
static propTypes = {
111
129
value : PropTypes . any , // string or integer basically
112
130
label : PropTypes . string ,
@@ -119,6 +137,10 @@ PickerIOS.Item = class extends React.Component {
119
137
}
120
138
} ;
121
139
140
+ class TypedPickerIOS extends ReactNative . NativeComponent < Props > {
141
+ static Item = PickerIOS . Item ;
142
+ }
143
+
122
144
const styles = StyleSheet . create ( {
123
145
pickerIOS : {
124
146
// The picker will conform to whatever width is given, but we do
@@ -144,4 +166,4 @@ const RCTPickerIOS = requireNativeComponent(
144
166
} ,
145
167
) ;
146
168
147
- module . exports = PickerIOS ;
169
+ module . exports = ( ( PickerIOS : any ) : Class < TypedPickerIOS > ) ;
0 commit comments