title: Typescript: onPress type
body: <p>I just ported my react-native project to typescript and have a question about functions as props</p>
  
  <p>im passing:</p>
  
  <pre><code>&lt;DisplayCardsWithLikes
  data={testData}
  likes={500}
  onPress={() =&gt; this.props.navigation.navigate("CardDetailScreen")}
  /&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>type Props = {
    onPress: Function
  }
  
  
  const FloatingActionButtonSimple = (props:Props) =&gt; {
    const {onPress} = props
    return (
      &lt;View style={styles.containerFab}&gt;
        &lt;TouchableOpacity style={styles.fab} onPress={onPress}&gt;
          &lt;Icon name="plus" size={16} color={"white"} /&gt;
        &lt;/TouchableOpacity&gt;
      &lt;/View&gt;
    );
  };
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Error, caused by child onPress:
  o overload matches this call.
    Overload 1 of 2, '(props: Readonly&lt;TouchableOpacityProps&gt;): TouchableOpacity', gave the following error.
      Type 'Function' is not assignable to type '(event: GestureResponderEvent) =&gt; void'.
        Type 'Function' provides no match for the signature '(event: GestureResponderEvent): void'.
    Overload 2 of 2, '(props: TouchableOpacityProps, context?: any): TouchableOpacity', gave the following error.
      Type 'Function' is not assignable to type '(event: GestureResponderEvent) =&gt; void'.ts(2769)
  index.d.ts(5125, 5): The expected type comes from property 'onPress' which is declared here on type 'IntrinsicAttributes &amp; IntrinsicClassAttributes&lt;TouchableOpacity&gt; &amp; Readonly&lt;TouchableOpacityProps&gt; &amp; Readonly&lt;...&gt;'
  index.d.ts(5125, 5): The expected type comes from property 'onPress' which is declared here on type 'IntrinsicAttributes &amp; IntrinsicClassAttributes&lt;TouchableOpacity&gt; &amp; Readonly&lt;TouchableOpacityProps&gt; &amp; Readonly&lt;...&gt;'
  </code></pre>
  
  <p>Summary:
  onPress passed as prop (is a function). On child type onPress:Function displays an error(the one above), onPress:any works though. I basically don't know which kind of type the onPress prop is</p>
  
  <p>So nothing crazy, but if I define onPress as a function it displays an error, so apparently that's not the correct type. Do you know which type this onPress functions are?</p>
  
  <p>Thanks a lot!</p>