diff --git a/Libraries/Components/Picker/Picker.js b/Libraries/Components/Picker/Picker.js index 88a70a59f6d05f..c96f18baf6fbad 100644 --- a/Libraries/Components/Picker/Picker.js +++ b/Libraries/Components/Picker/Picker.js @@ -32,7 +32,7 @@ type PickerItemProps = $ReadOnly<{| * The value to be passed to picker's `onValueChange` callback when * this item is selected. Can be a string or an integer. */ - value?: any, + value?: ?(number | string), /** * Color of this item's text. @@ -63,14 +63,14 @@ type PickerProps = $ReadOnly<{| /** * Value matching value of one of the items. Can be a string or an integer. */ - selectedValue?: any, + selectedValue?: ?(number | string), /** * Callback for when an item is selected. This is called with the following parameters: * - `itemValue`: the `value` prop of the item that was selected - * - `itemPosition`: the index of the selected item in this picker + * - `itemIndex`: the index of the selected item in this picker */ - onValueChange?: ?(newValue: any, newIndex: number) => mixed, + onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed, /** * If set to false, the picker will be disabled, i.e. the user will not be able to make a diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index 2fb010506853e0..2c1ae760e27775 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local */ 'use strict'; @@ -34,18 +34,34 @@ type PickerAndroidChangeEvent = SyntheticEvent< type PickerAndroidProps = $ReadOnly<{| children?: React.Node, style?: ?TextStyleProp, - selectedValue?: any, + selectedValue?: ?(number | string), enabled?: ?boolean, mode?: ?('dialog' | 'dropdown'), - onValueChange?: ?(newValue: any, newIndex: number) => mixed, + onValueChange?: ?(itemValue: ?(string | number), itemIndex: number) => mixed, prompt?: ?string, testID?: string, |}>; +type Item = $ReadOnly<{| + label: string, + value: ?(number | string), + color?: ?number, +|}>; + +type PickerAndroidState = {| + initialSelectedIndex: number, + selectedIndex: number, + items: $ReadOnlyArray, +|}; + /** * Not exposed as a public API - use instead. */ -class PickerAndroid extends React.Component { + +class PickerAndroid extends React.Component< + PickerAndroidProps, + PickerAndroidState, +> { /* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found * when making Flow check .android.js files. */ constructor(props, context) { diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index fa2fabc09404e2..594f913599bff6 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -27,14 +27,14 @@ import type {TextStyleProp} from 'StyleSheet'; type PickerIOSChangeEvent = SyntheticEvent< $ReadOnly<{| - newValue: any, + newValue: number | string, newIndex: number, |}>, >; type RCTPickerIOSItemType = $ReadOnly<{| label: ?Label, - value: ?any, + value: ?(number | string), textColor: ?number, |}>; @@ -62,8 +62,8 @@ type Props = $ReadOnly<{| children: React.ChildrenArray>, itemStyle?: ?TextStyleProp, onChange?: ?(event: PickerIOSChangeEvent) => mixed, - onValueChange?: ?(newValue: any, newIndex: number) => mixed, - selectedValue: any, + onValueChange?: ?(itemValue: string | number, itemIndex: number) => mixed, + selectedValue: ?(number | string), |}>; type State = {| @@ -73,7 +73,7 @@ type State = {| type ItemProps = $ReadOnly<{| label: ?Label, - value?: ?any, + value?: ?(number | string), color?: ?ColorValue, |}>; diff --git a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js index 1ed6231c663603..f3f8c016026e32 100644 --- a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js +++ b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js @@ -134,7 +134,7 @@ describe('deepFreezeAndThrowOnMutationInDev', function() { expect(o.key1.key2).toBe('newValue'); }); - it('shouldn\'t recurse infinitely', () => { + it("shouldn't recurse infinitely", () => { __DEV__ = true; const o = {}; o.circular = o; diff --git a/RNTester/js/PermissionsExampleAndroid.android.js b/RNTester/js/PermissionsExampleAndroid.android.js index 285b2827f31fdd..e470d755f51b87 100644 --- a/RNTester/js/PermissionsExampleAndroid.android.js +++ b/RNTester/js/PermissionsExampleAndroid.android.js @@ -76,7 +76,7 @@ class PermissionsExample extends React.Component<{}, $FlowFixMeState> { ); } - _onSelectPermission = (permission: string) => { + _onSelectPermission = (permission: string | number) => { this.setState({ permission: permission, }); diff --git a/RNTester/js/PickerExample.js b/RNTester/js/PickerExample.js index ad234e5ebe8bad..4957916a4a8f26 100644 --- a/RNTester/js/PickerExample.js +++ b/RNTester/js/PickerExample.js @@ -116,7 +116,7 @@ class PickerExample extends React.Component<{}, $FlowFixMeState> { this.setState({mode: newMode}); }; - onValueChange = (key: string, value: string) => { + onValueChange = (key: string, value: string | number) => { const newState = {}; newState[key] = value; this.setState(newState);