title: Typescript onPress With Promise Returned Error
body: <p>I'm implementing typescript into my project for the first time and I have an error coming from <code>onPress</code> which calls <code>toggleModal</code>. <strong>The error is coming from onPress</strong></p>
  
  <p>According to the <a href="https://facebook.github.io/react-native/docs/datepickerandroid" rel="nofollow noreferrer">React Native docs</a>, DatePickerAndroid.open() does the following:</p>
  
  <blockquote>
    <p>Returns a Promise which will be invoked an object containing action,
    year, month (0-11), day if the user picked a date. If the user
    dismissed the dialog, the Promise will still be resolved with action
    being DatePickerAndroid.dismissedAction and all the other keys being
    undefined.</p>
  </blockquote>
  
  <p>Can someone clarify if the error is coming from the following and how to fix it?</p>
  
  <ul>
  <li>The promise DatePickerAndroid.open() since it the response may or may not be returned</li>
  <li>Do I need to type onPress as a function with <code>onPress: Function</code>?</li>
  </ul>
  
  <p><strong>Error</strong></p>
  
  <pre><code>src/DatePicker.tsx:109:25 - error TS2769: No overload matches this call.
    Overload 1 of 2, '(props: Readonly&lt;TouchableOpacityProps&gt;): TouchableOpacity', gave the following error.
      Type '(props: Props) =&gt; Promise&lt;void&gt;' is not assignable to type '(event: GestureResponderEvent) =&gt; void'.
        Types of parameters 'props' and 'event' are incompatible.
          Type 'GestureResponderEvent' is missing the following properties from type 'Props': title, onPress, onValueChange, mode
    Overload 2 of 2, '(props: TouchableOpacityProps, context?: any): TouchableOpacity', gave the following error.
      Type '(props: Props) =&gt; Promise&lt;void&gt;' is not assignable to type '(event: GestureResponderEvent) =&gt; void'.
  
  109       &lt;TouchableOpacity onPress={toggleModal} style={styles.fieldTextContainer}&gt;
  </code></pre>
  
  <p><strong>Types</strong></p>
  
  <pre><code>// TypeScript: Types
  interface Props {
    title: string,
    onPress: Function,
    onValueChange: Function,
    mode: 'calendar' | 'spinner' | 'default',
    minDate?: Date | number;
    maxDate?: Date | number;
  }
  
  interface AndroidProps {
    action: 'dateSetAction' | 'dismissedAction',
    newDate?: Date;
    year?: number;
    month?: number;
    day?: number;
  }
  </code></pre>
  
  <p><strong>toggleModal</strong></p>
  
  <pre><code>// Toggle Modal
    const toggleModal = async (props: Props) =&gt; {
      try {
        // Check Platform (iOS)
        if (Platform.OS === 'ios') {
          // React Hook: Toggle Modal
          toggle((modalVisible) =&gt; !modalVisible);
        }
  
        // Check Platform (Android)
        if (Platform.OS === 'android') {
          const { action, year, month, day } : AndroidProps = await DatePickerAndroid.open({
            date: date,
            mode: props.mode,
          });
  
          // Action: Date Set
          if (
             action === DatePickerAndroid.dateSetAction
             &amp;&amp; year !== undefined
             &amp;&amp; month !== undefined
             &amp;&amp; day !== undefined
          ) {
            // New Date
            let newDate:Date = new Date(year, month, day);
  
            // Select Date
            selectDate(newDate);
          }
  
          // Action: Dismissed
          if (action === DatePickerAndroid.dismissedAction) {
            // Do Nothing
          }
        };
      }
      catch (error) {
        console.log(error);
      }
    };
  </code></pre>
  
  <p><strong>DatePicker.tsx</strong></p>
  
  <pre><code>  &lt;TouchableOpacity onPress={toggleModal} style={styles.fieldTextContainer}&gt;
      &lt;Text style={styles.fieldText} numberOfLines={1}&gt;{date ? moment(date).format('MMM Do, YYYY') : 'Select'}&lt;/Text&gt;
  
      &lt;Icon name="ios-arrow-forward" size={22} style={styles.arrowForward}/&gt;
    &lt;/TouchableOpacity&gt;
  </code></pre>