title: Flowtype: Subtype that makes optional property required
body: <p>Given the following Flow type alias (note that <code>payload</code> is an optional property):</p>
  
  <pre><code>type Action = { type: string, payload?: any }
  </code></pre>
  
  <p>How would I create a subtype of Action where <code>payload</code> is <strong>not</strong> optional anymore?</p>
  
  <p>Generics doesn't get me anywhere because that works only on the type of <code>payload</code> itself, not the fact that it's optional. Preferably I'd like to be able to simply do this:</p>
  
  <pre><code>type MoreSpecificAction extends Action = { payload: any }
  </code></pre>
  
  <p>Working with a specific type where I know <code>payload</code> is not optional would allow me to avoid a lot of undefined checks. As a bonus I could make the type more specific too, but I can already achieve that using generics.</p>
  
  <h3>Solution</h3>
  
  <p>As explained in the accepted answer by Lewis, the solution is to use the spread operator along with <code>$Exact&lt;Action&gt;</code>. However, babel-eslint currently does not support this syntax, but there's a workaround using comments. Here's my final solution:</p>
  
  <pre><code>type LoadAttendeesAction = {
    payload: Array&lt;Attendee&gt;,
    /* :: ...$Exact&lt;Action&gt; */
  };
  </code></pre>
  
  <p>One caveat is that <code>Action</code> will need to be in scope, but ESLint won't consider it being used, so you may need:</p>
  
  <pre><code>// eslint-disable-line no-unused-vars
  </code></pre>