title: Refining broad, primitive types into enum types in Flow
body: <p>I'm writing a function that accepts a string, and if the string value is a member of an enum, I'd like to treat it like the type I've defined for that enum. A simplified example:</p>
  
  <pre><code>const FRUITS = Object.freeze({
    APPLE: 'APPLE',
    BANANA: 'BANANA',
  });
  
  type Fruit = $Values&lt;typeof FRUITS&gt;
  
  function fruitChecker(input: string) {
    if (Object.values(FRUITS).includes(input)) {
      (input: Fruit);
    }
  }
  </code></pre>
  
  <p><a href="https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAxnAdgZwC5gBiASgKoCSAKgMpgC8YA8gEYBWApungHRQBO7dgC92ACgDeqMGACCABTkAZAKIAuMAHJ5S5RoA0UsACEZAOTMz1Gk+fP7UAXwCUAblSo8ATwAO7InwBXAEsCBgASADUAQxgA9hwAHi9fOCgiMipqAD53KACsLiDsMH5gvABhAAtOAGt2PlEgrG8AvHV8PiaAcycwSWkgtNEWDi5uADcYuJxREgoaJ24m9FiAE3jG5tanXv7pME2Wtv8y10MHRyA" rel="nofollow noreferrer">Example in Flow's web editor</a></p>
  
  <p>Flow throws an error saying my input in that conditional is not a Fruit. But how can my input not be a Fruit as I've defined it? Is there a right way to perform operations on an enum member after refining the input from a broader, primitive type?</p>