From 8a59153bd7325055dcca33571ee0484f8f00fb30 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 10 Nov 2022 04:48:13 -0800 Subject: [PATCH] Remove $TEMPORARY$object types Summary: This was left over from an old codemod. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D41154548 fbshipit-source-id: 0b5fb3e78491b66ebaf13555f80e0265a25dc7d8 --- .../Components/Touchable/Touchable.flow.js | 34 ++++++++++++++++--- Libraries/Components/Touchable/Touchable.js | 9 +++-- Libraries/Core/ReactNativeVersionCheck.js | 10 +----- Libraries/Interaction/PanResponder.js | 4 +-- .../__tests__/VirtualizedSectionList-test.js | 6 ++-- Libraries/LogBox/UI/LogBoxInspector.js | 4 +-- .../LogBox/UI/LogBoxInspectorStackFrame.js | 4 +-- Libraries/LogBox/UI/LogBoxNotification.js | 12 +++---- .../getCachedComponentWithDebugName.js | 10 +++--- .../Utilities/__tests__/useRefEffect-test.js | 15 +++----- Libraries/Utilities/stringifySafe.js | 9 ++--- Libraries/Utilities/useWindowDimensions.js | 6 ++-- .../js/components/RNTesterExampleFilter.js | 10 +++--- .../rn-tester/js/components/RNTesterNavbar.js | 4 +-- 14 files changed, 72 insertions(+), 65 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.flow.js b/Libraries/Components/Touchable/Touchable.flow.js index 3a583c286df..b93087cbec5 100644 --- a/Libraries/Components/Touchable/Touchable.flow.js +++ b/Libraries/Components/Touchable/Touchable.flow.js @@ -99,7 +99,30 @@ import * as React from 'react'; * } */ -// Default amount "active" region protrudes beyond box +/** + * Touchable states. + */ + +const States = { + NOT_RESPONDER: 'NOT_RESPONDER', // Not the responder + RESPONDER_INACTIVE_PRESS_IN: 'RESPONDER_INACTIVE_PRESS_IN', // Responder, inactive, in the `PressRect` + RESPONDER_INACTIVE_PRESS_OUT: 'RESPONDER_INACTIVE_PRESS_OUT', // Responder, inactive, out of `PressRect` + RESPONDER_ACTIVE_PRESS_IN: 'RESPONDER_ACTIVE_PRESS_IN', // Responder, active, in the `PressRect` + RESPONDER_ACTIVE_PRESS_OUT: 'RESPONDER_ACTIVE_PRESS_OUT', // Responder, active, out of `PressRect` + RESPONDER_ACTIVE_LONG_PRESS_IN: 'RESPONDER_ACTIVE_LONG_PRESS_IN', // Responder, active, in the `PressRect`, after long press threshold + RESPONDER_ACTIVE_LONG_PRESS_OUT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT', // Responder, active, out of `PressRect`, after long press threshold + ERROR: 'ERROR', +}; + +type State = + | typeof States.NOT_RESPONDER + | typeof States.RESPONDER_INACTIVE_PRESS_IN + | typeof States.RESPONDER_INACTIVE_PRESS_OUT + | typeof States.RESPONDER_ACTIVE_PRESS_IN + | typeof States.RESPONDER_ACTIVE_PRESS_OUT + | typeof States.RESPONDER_ACTIVE_LONG_PRESS_IN + | typeof States.RESPONDER_ACTIVE_LONG_PRESS_OUT + | typeof States.ERROR; /** * By convention, methods prefixed with underscores are meant to be @private, @@ -200,9 +223,12 @@ interface TouchableMixinType { * @return {object} State object to be placed inside of * `this.state.touchable`. */ - touchableGetInitialState: () => $TEMPORARY$object<{| - touchable: $TEMPORARY$object<{|responderID: null, touchState: void|}>, - |}>; + touchableGetInitialState: () => { + touchable: { + touchState: ?State, + responderID: ?PressEvent['currentTarget'], + }, + }; // ==== Hooks to Gesture Responder system ==== /** diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 48e15bf1b6d..50c9b8f6a14 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -396,9 +396,12 @@ const TouchableMixin = { * @return {object} State object to be placed inside of * `this.state.touchable`. */ - touchableGetInitialState: function (): $TEMPORARY$object<{| - touchable: $TEMPORARY$object<{|responderID: null, touchState: void|}>, - |}> { + touchableGetInitialState: function (): { + touchable: { + touchState: ?State, + responderID: ?PressEvent['currentTarget'], + }, + } { return { touchable: {touchState: undefined, responderID: null}, }; diff --git a/Libraries/Core/ReactNativeVersionCheck.js b/Libraries/Core/ReactNativeVersionCheck.js index 19f639a1691..8b41988696d 100644 --- a/Libraries/Core/ReactNativeVersionCheck.js +++ b/Libraries/Core/ReactNativeVersionCheck.js @@ -40,15 +40,7 @@ exports.checkVersions = function checkVersions(): void { }; function _formatVersion( - version: - | {major: number, minor: number, patch: number, prerelease: ?number} - | {major: number, minor: number, patch: number, prerelease: ?string} - | $TEMPORARY$object<{ - major: number, - minor: number, - patch: number, - prerelease: null, - }>, + version: (typeof Platform)['constants']['reactNativeVersion'], ): string { return ( `${version.major}.${version.minor}.${version.patch}` + diff --git a/Libraries/Interaction/PanResponder.js b/Libraries/Interaction/PanResponder.js index 3f0e1e2128d..6d6df72e1f5 100644 --- a/Libraries/Interaction/PanResponder.js +++ b/Libraries/Interaction/PanResponder.js @@ -399,10 +399,10 @@ const PanResponder: PanResponderType = { * accordingly. (numberActiveTouches) may not be totally accurate unless you * are the responder. */ - create(config: PanResponderConfig): $TEMPORARY$object<{| + create(config: PanResponderConfig): { getInteractionHandle: () => ?number, panHandlers: PanHandlers, - |}> { + } { const interactionState = { handle: (null: ?number), }; diff --git a/Libraries/Lists/__tests__/VirtualizedSectionList-test.js b/Libraries/Lists/__tests__/VirtualizedSectionList-test.js index d103fa5c680..ca84e25f2e1 100644 --- a/Libraries/Lists/__tests__/VirtualizedSectionList-test.js +++ b/Libraries/Lists/__tests__/VirtualizedSectionList-test.js @@ -168,9 +168,9 @@ describe('VirtualizedSectionList', () => { describe('scrollToLocation', () => { const ITEM_HEIGHT = 100; - const createVirtualizedSectionList = ( - props: void | $TEMPORARY$object<{stickySectionHeadersEnabled: boolean}>, - ) => { + const createVirtualizedSectionList = (props?: { + stickySectionHeadersEnabled: boolean, + }) => { const component = ReactTestRenderer.create( void}>, -) { +function LogBoxInspectorBody(props: {log: LogBoxLog, onRetry: () => void}) { const [collapsed, setCollapsed] = React.useState(true); React.useEffect(() => { diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js b/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js index 78fb0bdb797..98326f9d0d7 100644 --- a/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +++ b/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js @@ -19,10 +19,10 @@ import LogBoxButton from './LogBoxButton'; import * as LogBoxStyle from './LogBoxStyle'; import * as React from 'react'; -type Props = $ReadOnly<{| +type Props = $ReadOnly<{ frame: StackFrame, onPress?: ?(event: PressEvent) => void, -|}>; +}>; function LogBoxInspectorStackFrame(props: Props): React.Node { const {frame, onPress} = props; diff --git a/Libraries/LogBox/UI/LogBoxNotification.js b/Libraries/LogBox/UI/LogBoxNotification.js index ae9163f342c..826108f3549 100644 --- a/Libraries/LogBox/UI/LogBoxNotification.js +++ b/Libraries/LogBox/UI/LogBoxNotification.js @@ -21,13 +21,13 @@ import LogBoxMessage from './LogBoxMessage'; import * as LogBoxStyle from './LogBoxStyle'; import * as React from 'react'; -type Props = $ReadOnly<{| +type Props = $ReadOnly<{ log: LogBoxLog, totalLogCount: number, level: 'warn' | 'error', onPressOpen: () => void, onPressDismiss: () => void, -|}>; +}>; function LogBoxLogNotification(props: Props): React.Node { const {totalLogCount, level, log} = props; @@ -56,9 +56,7 @@ function LogBoxLogNotification(props: Props): React.Node { ); } -function CountBadge( - props: $TEMPORARY$object<{count: number, level: 'error' | 'warn'}>, -) { +function CountBadge(props: {count: number, level: 'error' | 'warn'}) { return ( {/* $FlowFixMe[incompatible-type] (>=0.114.0) This suppression was added @@ -73,7 +71,7 @@ function CountBadge( ); } -function Message(props: $TEMPORARY$object<{message: MessageType}>) { +function Message(props: {message: MessageType}) { return ( @@ -89,7 +87,7 @@ function Message(props: $TEMPORARY$object<{message: MessageType}>) { ); } -function DismissButton(props: $TEMPORARY$object<{onPress: () => void}>) { +function DismissButton(props: {onPress: () => void}) { return ( ; +import * as React from 'react'; + +type NoopComponent = AbstractComponent<{children: React.Node}>; const cache: Map< string, // displayName @@ -23,9 +25,7 @@ export default function getCachedComponentWithDisplayName( let ComponentWithDisplayName = cache.get(displayName); if (!ComponentWithDisplayName) { - ComponentWithDisplayName = ({ - children, - }: $TEMPORARY$object<{children: Node}>) => children; + ComponentWithDisplayName = ({children}: {children: React.Node}) => children; // $FlowFixMe[prop-missing] ComponentWithDisplayName.displayName = displayName; cache.set(displayName, ComponentWithDisplayName); diff --git a/Libraries/Utilities/__tests__/useRefEffect-test.js b/Libraries/Utilities/__tests__/useRefEffect-test.js index ee163330d85..1cd759da4ec 100644 --- a/Libraries/Utilities/__tests__/useRefEffect-test.js +++ b/Libraries/Utilities/__tests__/useRefEffect-test.js @@ -20,17 +20,10 @@ import {act, create} from 'react-test-renderer'; function TestView({ childKey = null, effect, -}: - | $FlowFixMe - | $TEMPORARY$object<{ - childKey: $TEMPORARY$string<'bar'>, - effect: () => () => void, - }> - | $TEMPORARY$object<{childKey: $TEMPORARY$string<'foo'>, effect: () => void}> - | $TEMPORARY$object<{ - childKey: $TEMPORARY$string<'foo'>, - effect: () => () => void, - }>) { +}: { + childKey: ?string, + effect: () => (() => void) | void, +}) { const ref = useRefEffect(effect); return ; } diff --git a/Libraries/Utilities/stringifySafe.js b/Libraries/Utilities/stringifySafe.js index a61716ab49a..042fe0bfcda 100644 --- a/Libraries/Utilities/stringifySafe.js +++ b/Libraries/Utilities/stringifySafe.js @@ -26,9 +26,7 @@ export function createStringifySafeWithLimits(limits: {| maxArrayLimit = Number.POSITIVE_INFINITY, maxObjectKeysLimit = Number.POSITIVE_INFINITY, } = limits; - const stack: Array< - string | {+[string]: mixed} | {'...(truncated keys)...': number}, - > = []; + const stack: Array = []; /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by * Flow's LTI update could not be added via codemod */ function replacer(key: string, value: mixed): mixed { @@ -47,10 +45,7 @@ export function createStringifySafeWithLimits(limits: {| return value; } - let retval: - | string - | {+[string]: mixed} - | $TEMPORARY$object<{'...(truncated keys)...': number}> = value; + let retval: mixed = value; if (Array.isArray(value)) { if (stack.length >= maxDepth) { retval = `[ ... array with ${value.length} values ... ]`; diff --git a/Libraries/Utilities/useWindowDimensions.js b/Libraries/Utilities/useWindowDimensions.js index 94b68f9d675..95a145fa862 100644 --- a/Libraries/Utilities/useWindowDimensions.js +++ b/Libraries/Utilities/useWindowDimensions.js @@ -22,9 +22,9 @@ export default function useWindowDimensions(): useEffect(() => { function handleChange({ window, - }: - | $FlowFixMe - | $TEMPORARY$object<{window: DisplayMetrics | DisplayMetricsAndroid}>) { + }: { + window: DisplayMetrics | DisplayMetricsAndroid, + }) { if ( dimensions.width !== window.width || dimensions.height !== window.height || diff --git a/packages/rn-tester/js/components/RNTesterExampleFilter.js b/packages/rn-tester/js/components/RNTesterExampleFilter.js index 03daeb35e11..86f6860f9c1 100644 --- a/packages/rn-tester/js/components/RNTesterExampleFilter.js +++ b/packages/rn-tester/js/components/RNTesterExampleFilter.js @@ -80,10 +80,12 @@ class RNTesterExampleFilter extends React.Component, State> { } _renderFilteredSections( - filteredSections: Array< - $TEMPORARY$object<{data: Array, key: string, title: string}>, - >, - ): ?React.Element { + filteredSections: $ReadOnlyArray<{ + data: Array, + key: string, + title: string, + }>, + ): React.Node { if (this.props.page === 'examples_page') { return ( void, isBookmarkActive: boolean, theme: RNTesterTheme, -}>) => ( +}) => (