title: How to make a props function optional
body: <p>I know you can make props optional with a ?, like this:</p>
  <pre><code>type: 'goal' | 'course',
  onSaveCourse?: (title: string, date: Date) =&gt; void;
  onSaveGoal?: (text: string) =&gt; void;
  </code></pre>
  <p>But if the prop is a function(as in the snippet above) typescript complains, once such a function is called, that it won't put up with &quot;possibly undefined&quot;.</p>
  <p>How could this be resolved?</p>
  <p><strong>Motivation of the above snippet:</strong>
  It's an edit modal that should be used in two cases ( 'goal' | 'course')
  and I don't want to be forced to pass the onSave function I don't need for either case.</p>