From de7f69a58ed4e18887f4b9d4d853293fb136afb7 Mon Sep 17 00:00:00 2001 From: Mats Byrkjeland Date: Tue, 5 May 2020 12:42:16 -0700 Subject: [PATCH] Fix type of exported Touchables: ComponentType -> AbstractComponent (#28737) Summary: Fixes https://github.com/facebook/react-native/issues/28726 When importing TouchableOpacity, it is treated as any by Flow. Replacing ComponentType with AbstractComponent works. The [Flow documentation](https://flow.org/en/docs/react/types/#toc-react-componenttype) says the following about ComponentType: > Note: In 0.89.0+, React.ComponentType is an alias for React.AbstractComponent, which represents a component with config type Config and any instance type. So I'm thinking that since the instance type is treated as any with ComponentType, Flow treats TouchableOpacity as any as well. ## Changelog [General] [Fixed] - Fix Touchable{Opacity,Bounce,Highlight} being exported as `any` (Flow) Pull Request resolved: https://github.com/facebook/react-native/pull/28737 Test Plan: I have done the same changes to react-native in my project's node_modules and seen that the components TouchableOpacity went from any to AbstractComponent with some props. Now I have a bunch of errors because I'm sending in wrong props to some touchables, which is good! Reviewed By: cpojer Differential Revision: D21362601 Pulled By: TheSavior fbshipit-source-id: 5b98cc79eaef034eccdb7f47242f9f44be2ef2b8 --- Libraries/Components/Touchable/TouchableBounce.js | 2 +- Libraries/Components/Touchable/TouchableHighlight.js | 2 +- Libraries/Components/Touchable/TouchableOpacity.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index c47129dd392aa0..b03aaf1e364639 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -214,4 +214,4 @@ class TouchableBounce extends React.Component { module.exports = (React.forwardRef((props, hostRef) => ( -)): React.ComponentType<$ReadOnly<$Diff>>); +)): React.AbstractComponent<$ReadOnly<$Diff>>); diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index a29159e9f585f2..7eaa510c0327ca 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -380,4 +380,4 @@ class TouchableHighlight extends React.Component { module.exports = (React.forwardRef((props, hostRef) => ( -)): React.ComponentType<$ReadOnly<$Diff>>); +)): React.AbstractComponent<$ReadOnly<$Diff>>); diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index aa5239fddafe88..ae27775ba72fd9 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -299,4 +299,4 @@ class TouchableOpacity extends React.Component { module.exports = (React.forwardRef((props, hostRef) => ( -)): React.ComponentType<$ReadOnly<$Diff>>); +)): React.AbstractComponent<$ReadOnly<$Diff>>);