diff --git a/packages/react-native/Libraries/Animated/Animated.js b/packages/react-native/Libraries/Animated/Animated.js index a9df993ad298..509e33880db5 100644 --- a/packages/react-native/Libraries/Animated/Animated.js +++ b/packages/react-native/Libraries/Animated/Animated.js @@ -21,9 +21,9 @@ import Platform from '../Utilities/Platform'; import AnimatedImplementation from './AnimatedImplementation'; import AnimatedMock from './AnimatedMock'; -const Animated = ((Platform.isDisableAnimations +const Animated: typeof AnimatedImplementation = Platform.isDisableAnimations ? AnimatedMock - : AnimatedImplementation): typeof AnimatedImplementation); + : AnimatedImplementation; export default { get FlatList(): AnimatedFlatList { diff --git a/packages/react-native/Libraries/Components/Touchable/PooledClass.js b/packages/react-native/Libraries/Components/Touchable/PooledClass.js index 67847c1ba0c0..e10b470fef77 100644 --- a/packages/react-native/Libraries/Components/Touchable/PooledClass.js +++ b/packages/react-native/Libraries/Components/Touchable/PooledClass.js @@ -112,7 +112,7 @@ const addPoolingTo = function ( } { // Casting as any so that flow ignores the actual implementation and trusts // it to match the type we declared - const NewKlass = (CopyConstructor: any); + const NewKlass: any = CopyConstructor; NewKlass.instancePool = []; NewKlass.getPooled = pooler || DEFAULT_POOLER; if (!NewKlass.poolSize) { diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js index f2f9c4e7829a..9cdc5f76cb2e 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js @@ -379,12 +379,12 @@ class TouchableHighlight extends React.Component { } } -const Touchable = (React.forwardRef((props, hostRef) => ( - -)): React.AbstractComponent< +const Touchable: React.AbstractComponent< $ReadOnly<$Diff|}>>, React.ElementRef, ->); +> = React.forwardRef((props, hostRef) => ( + +)); Touchable.displayName = 'TouchableHighlight'; diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js index 789f0394343b..8e6db9415397 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js @@ -323,9 +323,12 @@ class TouchableOpacity extends React.Component { } } -const Touchable = (React.forwardRef((props, ref) => ( +const Touchable: React.AbstractComponent< + Props, + React.ElementRef, +> = React.forwardRef((props, ref) => ( -)): React.AbstractComponent>); +)); Touchable.displayName = 'TouchableOpacity'; diff --git a/packages/react-native/Libraries/MutationObserver/MutationRecord.js b/packages/react-native/Libraries/MutationObserver/MutationRecord.js index e5627b2e7b69..0616ee97f3c0 100644 --- a/packages/react-native/Libraries/MutationObserver/MutationRecord.js +++ b/packages/react-native/Libraries/MutationObserver/MutationRecord.js @@ -32,15 +32,15 @@ export default class MutationRecord { _removedNodes: NodeList; constructor(nativeRecord: NativeMutationRecord) { - // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type. - const target = (nativeRecord.target: ReactNativeElement); + // $FlowExpectedError[incompatible-type] the codegen doesn't support the actual type. + const target: ReactNativeElement = nativeRecord.target; this._target = target; - // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type. - const addedNodes = (nativeRecord.addedNodes: $ReadOnlyArray); + // $FlowExpectedError[incompatible-type] the codegen doesn't support the actual type. + const addedNodes: $ReadOnlyArray = nativeRecord.addedNodes; this._addedNodes = createNodeList(addedNodes); - const removedNodes = - // $FlowExpectedError[incompatible-cast] the codegen doesn't support the actual type. - (nativeRecord.removedNodes: $ReadOnlyArray); + const removedNodes: $ReadOnlyArray = + // $FlowFixMe[incompatible-type] + nativeRecord.removedNodes; this._removedNodes = createNodeList(removedNodes); } diff --git a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js index ee428d47e33f..41e0e2bb57bd 100644 --- a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js +++ b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js @@ -359,8 +359,8 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = { return; } - let nativeViewTag = (instanceHandle.stateNode.canonical - .nativeTag: number); + let nativeViewTag: number = + instanceHandle.stateNode.canonical.nativeTag; FabricUIManager.measure( node, diff --git a/packages/react-native/Libraries/Text/TextAncestor.js b/packages/react-native/Libraries/Text/TextAncestor.js index f61c90e8209b..2b04983de917 100644 --- a/packages/react-native/Libraries/Text/TextAncestor.js +++ b/packages/react-native/Libraries/Text/TextAncestor.js @@ -15,9 +15,8 @@ const React = require('react'); /** * Whether the current element is the descendant of a element. */ -const TextAncestorContext = (React.createContext( - false, -): React$Context<$FlowFixMe>); +const TextAncestorContext: React$Context<$FlowFixMe> = + React.createContext(false); if (__DEV__) { TextAncestorContext.displayName = 'TextAncestorContext'; } diff --git a/packages/react-native/Libraries/Utilities/binaryToBase64.js b/packages/react-native/Libraries/Utilities/binaryToBase64.js index ad136a23eabe..898a5cf74408 100644 --- a/packages/react-native/Libraries/Utilities/binaryToBase64.js +++ b/packages/react-native/Libraries/Utilities/binaryToBase64.js @@ -24,7 +24,7 @@ function binaryToBase64(data: ArrayBuffer | $ArrayBufferView): string { throw new Error('data must be ArrayBuffer or typed array'); } // Already checked that `data` is `DataView` in `ArrayBuffer.isView(data)` - const {buffer, byteOffset, byteLength} = ((data: $FlowFixMe): DataView); + const {buffer, byteOffset, byteLength}: DataView = (data: $FlowFixMe); return base64.fromByteArray(new Uint8Array(buffer, byteOffset, byteLength)); } diff --git a/packages/rn-tester/js/examples/Animated/EasingExample.js b/packages/rn-tester/js/examples/Animated/EasingExample.js index d36e603d2ed5..3a7995ca33f8 100644 --- a/packages/rn-tester/js/examples/Animated/EasingExample.js +++ b/packages/rn-tester/js/examples/Animated/EasingExample.js @@ -136,7 +136,7 @@ function EasingExample(props: Props): React.Node { { - const item = (info.item: EasingListItem); + const item: EasingListItem = info.item; return ( = [ ModalPresentation, ModalOnShow, -]: Array); +]; diff --git a/packages/rn-tester/js/examples/MutationObserver/VisualCompletionExample/VisualCompletionExample.js b/packages/rn-tester/js/examples/MutationObserver/VisualCompletionExample/VisualCompletionExample.js index 20a3eb895e8e..5a7303070f67 100644 --- a/packages/rn-tester/js/examples/MutationObserver/VisualCompletionExample/VisualCompletionExample.js +++ b/packages/rn-tester/js/examples/MutationObserver/VisualCompletionExample/VisualCompletionExample.js @@ -64,8 +64,8 @@ function VisualCompletionExampleScreen(props: { style={styles.root} ref={node => { if (node != null) { - // $FlowExpectedError[incompatible-cast] - const element = (node: ReactNativeElement); + // $FlowExpectedError[incompatible-type] + const element: ReactNativeElement = node; props.vcTracker.addMutationRoot(element); } }}> diff --git a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js index df4c54ba87ac..ab89d4b429ea 100644 --- a/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js +++ b/packages/rn-tester/js/examples/ScrollView/ScrollViewExample.js @@ -252,7 +252,7 @@ exports.documentationURL = 'https://reactnative.dev/docs/scrollview'; exports.category = 'Basic'; exports.description = 'Component that enables scrolling through child components'; -const examples = ([ +const examples: Array = [ { name: 'scrollTo', title: '\n', @@ -425,7 +425,7 @@ const examples = ([ return ; }, }, -]: Array); +]; if (Platform.OS === 'ios') { examples.push({