From 5719c0e1ac985549d888ea42716f7bf3819ac460 Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Tue, 28 Nov 2023 10:46:01 +0900 Subject: [PATCH] fix: update flow version (#533) --- .flowconfig | 5 +-- js/AndroidDropdownPickerNativeComponent.js | 1 + js/Picker.js | 2 +- js/Picker.web.js | 4 +-- js/PickerIOS.ios.js | 42 +++++++++++++--------- js/PickerMacOS.macos.js | 9 +++-- js/RNCPickerNativeComponent.js | 1 + package.json | 2 +- yarn.lock | 8 ++--- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/.flowconfig b/.flowconfig index f93a51f18f..70a7f4e439 100644 --- a/.flowconfig +++ b/.flowconfig @@ -60,8 +60,6 @@ suppress_type=$FlowFixMeState server.max_workers=2 -experimental.abstract_locations=true - [lints] sketchy-null-number=warn sketchy-null-mixed=warn @@ -71,7 +69,6 @@ nonstrict-import=warn deprecated-type=warn unsafe-getters-setters=warn unnecessary-invariant=warn -signature-verification-failure=warn [strict] deprecated-type @@ -83,4 +80,4 @@ untyped-import untyped-type-import [version] -^0.170.0 +^0.222.0 diff --git a/js/AndroidDropdownPickerNativeComponent.js b/js/AndroidDropdownPickerNativeComponent.js index dd69944752..6666e539a5 100644 --- a/js/AndroidDropdownPickerNativeComponent.js +++ b/js/AndroidDropdownPickerNativeComponent.js @@ -16,6 +16,7 @@ import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTyp import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; import type { BubblingEventHandler, + Double, Int32, } from 'react-native/Libraries/Types/CodegenTypes'; diff --git a/js/Picker.js b/js/Picker.js index 003171d170..48c65a9962 100644 --- a/js/Picker.js +++ b/js/Picker.js @@ -53,7 +53,7 @@ type PickerItemProps = $ReadOnly<{| * Individual selectable item in a Picker. */ class PickerItem extends React.Component { - render() { + render(): React.Node { // The items are not rendered directly throw null; } diff --git a/js/Picker.web.js b/js/Picker.web.js index 54b3774685..38df4fc505 100644 --- a/js/Picker.web.js +++ b/js/Picker.web.js @@ -30,7 +30,7 @@ type PickerProps = { prompt?: string, }; -const Select = forwardRef((props: any, forwardedRef) => +const Select = forwardRef((props: $FlowFixMe, forwardedRef: $FlowFixMe) => unstable_createElement('select', { ...props, ref: forwardedRef, @@ -39,7 +39,7 @@ const Select = forwardRef((props: any, forwardedRef) => const Picker: React$AbstractComponent = forwardRef< PickerProps, - *, + $FlowFixMe, >((props, forwardedRef) => { const { enabled, diff --git a/js/PickerIOS.ios.js b/js/PickerIOS.ios.js index 85daba3cb3..817f0beca2 100644 --- a/js/PickerIOS.ios.js +++ b/js/PickerIOS.ios.js @@ -44,6 +44,7 @@ type Label = Stringish | number; type Props = $ReadOnly<{| ...ViewProps, + // $FlowFixMe children: ChildrenArray>, itemStyle?: ?TextStyleProp, numberOfLines: ?number, @@ -92,6 +93,7 @@ function useMergeRefs(...refs: $ReadOnlyArray>): CallbackRef { ); } +// $FlowFixMe const PickerIOSItem: RNCPickerIOSItemType = (props: ItemProps): null => { return null; }; @@ -117,6 +119,7 @@ const PickerIOSWithForwardedRef: React.AbstractComponent< typeof RNCPickerNativeComponent, > | null>(null); + // $FlowFixMe const ref = useMergeRefs(nativePickerRef, forwardedRef); const [nativeSelectedIndex, setNativeSelectedIndex] = React.useState({ @@ -127,20 +130,22 @@ const PickerIOSWithForwardedRef: React.AbstractComponent< // eslint-disable-next-line no-shadow let selectedIndex = 0; // eslint-disable-next-line no-shadow - const items = React.Children.toArray(children).map((child, index) => { - if (child === null) { - return null; - } - if (String(child.props.value) === String(selectedValue)) { - selectedIndex = index; - } - return { - value: String(child.props.value), - label: String(child.props.label), - textColor: processColor(child.props.color), - testID: child.props.testID, - }; - }); + const items = React.Children.toArray<$FlowFixMe>(children).map( + (child, index) => { + if (child === null) { + return null; + } + if (String(child.props.value) === String(selectedValue)) { + selectedIndex = index; + } + return { + value: String(child.props.value), + label: String(child.props.label), + textColor: processColor(child.props.color), + testID: child.props.testID, + }; + }, + ); return [items, selectedIndex]; }, [children, selectedValue]); @@ -151,7 +156,10 @@ const PickerIOSWithForwardedRef: React.AbstractComponent< React.useLayoutEffect(() => { let jsValue = 0; - React.Children.toArray(children).forEach(function (child, index) { + React.Children.toArray<$FlowFixMe>(children).forEach(function ( + child: $FlowFixMe, + index: number, + ) { if (String(child.props.value) === String(selectedValue)) { jsValue = index; } @@ -177,7 +185,7 @@ const PickerIOSWithForwardedRef: React.AbstractComponent< }, [selectedValue, nativeSelectedIndex, children]); const _onChange = React.useCallback( - (event) => { + (event: $FlowFixMe) => { onChange?.(event); onValueChange?.(event.nativeEvent.newValue, event.nativeEvent.newIndex); setNativeSelectedIndex({value: event.nativeEvent.newIndex}); @@ -192,6 +200,7 @@ const PickerIOSWithForwardedRef: React.AbstractComponent< themeVariant={themeVariant} testID={testID} style={[styles.pickerIOS, itemStyle]} + // $FlowFixMe items={items} onChange={_onChange} numberOfLines={parsedNumberOfLines} @@ -211,6 +220,7 @@ const styles = StyleSheet.create({ }, }); +// $FlowFixMe PickerIOSWithForwardedRef.Item = PickerIOSItem; export default PickerIOSWithForwardedRef; diff --git a/js/PickerMacOS.macos.js b/js/PickerMacOS.macos.js index fa3ad39289..dd5e257241 100644 --- a/js/PickerMacOS.macos.js +++ b/js/PickerMacOS.macos.js @@ -53,6 +53,7 @@ type Label = Stringish | number; type Props = $ReadOnly<{| ...ViewProps, + // $FlowFixMe children: ChildrenArray>, itemStyle?: ?TextStyleProp, onChange?: ?(event: PickerMacOSChangeEvent) => mixed, @@ -89,7 +90,10 @@ class PickerMacOS extends React.Component { static getDerivedStateFromProps(props: Props): State { let selectedIndex = 0; const items = []; - React.Children.toArray(props.children).forEach(function (child, index) { + React.Children.toArray<$FlowFixMe>(props.children).forEach(function ( + child: $FlowFixMe, + index: number, + ) { if (child.props.value === props.selectedValue) { selectedIndex = index; } @@ -112,6 +116,7 @@ class PickerMacOS extends React.Component { }} testID={this.props.testID} style={[styles.pickerMacOS, this.props.itemStyle]} + // $FlowFixMe items={this.state.items} selectedIndex={this.state.selectedIndex} onChange={this._onChange} @@ -120,7 +125,7 @@ class PickerMacOS extends React.Component { ); } - _onChange = (event) => { + _onChange = (event: $FlowFixMe) => { if (this.props.onChange) { this.props.onChange(event); } diff --git a/js/RNCPickerNativeComponent.js b/js/RNCPickerNativeComponent.js index ab9b2990f9..e8960b9d79 100644 --- a/js/RNCPickerNativeComponent.js +++ b/js/RNCPickerNativeComponent.js @@ -17,6 +17,7 @@ import type { BubblingEventHandler, Int32, } from 'react-native/Libraries/Types/CodegenTypes'; +import type {ProcessedColorValue} from 'react-native/Libraries/StyleSheet/processColor'; import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; diff --git a/package.json b/package.json index 286cf92ef4..726c05dde9 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint": "^7.32.0", "eslint-plugin-prettier": "^3.0.1", "expo": "^41.0.1", - "flow-bin": "0.170.0", + "flow-bin": "0.222.0", "husky": "^2.2.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.67.0", diff --git a/yarn.lock b/yarn.lock index 5546668df6..c8ad972029 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8287,10 +8287,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== -flow-bin@0.170.0: - version "0.170.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.170.0.tgz#1da264de9868cc20a338f801bedc370e3e06f5cc" - integrity sha512-h4qy4f5loKdeLhj7TRM6XQWhmPpnfjDcOg6GPDuJnLAQuB60LJIHZ8QL3hxMf0oA++NkiYx62Vr8oHu+UZ2bGQ== +flow-bin@0.222.0: + version "0.222.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.222.0.tgz#b4ca588c77fbd79db1edf38615cd04d114c1e933" + integrity sha512-U2047+pOX1EutHGykcjtamAlP8UIHrxbkexB5zPVQ8PH+WcVmD4PtRE6J8Jc3S6odyo0AqVnQsI4rE/2x2fGmQ== flow-parser@0.*: version "0.154.0"