-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
Description
When importing TouchableOpacity, it is treated as any
by Flow. Same goes for TouchableHighlight. I think this is because of the use of React.forwardRef
in their respective files. Flow understands TouchableWithoutFeedback, which does not use forwardRef.
This blog post might be relevant for typing forwardRef in Flow: https://medium.com/flow-type/supporting-react-forwardref-and-beyond-f8dd88f35544
I was hoping to use React.ElementConfig<typeof TouchableOpacity>
to type the Props of my own Button component, but that does not work because of this. I am using React.ElementConfig<typeof TouchableWithoutFeedback>
now as a workaround.
React Native version:
0.62.2
Flow version 0.113.0
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Import TouchableOpacity in a component file
- Use your Flow tools in your editor to inspect that TouchableOpacity is treated as
any
or use it "illegally" and run flow to see that it passes. Like for instance
cons x: number = TouchableOpacity
Expected Results
I expect Flow to understand that TouchableOpacity is not "any", but a React component with a set of valid Props.