title: Flow - intersection with union types error: "Property cannot be accessed on any member of intersection type"
body: <p>Code can be tried <a href="https://flow.org/try/#0C4TwDgpgBAMg9gYwIbAJZwHZQLxQN4BQUUANiqsAK4AmEAXFBpQLYBGEATgDRGmYDmFGvUYt2HAgF8oAMigAKQsRKJymACrgRAcgRxKGYBxDaexPQaMgGAZyOoM-KVAA++XiuRoNWhtrsoEKa8AcD0dhwOTpIAlAQEehh2UDZwzBDwXugYDJlqWLhKpORUtAwATAAMZnyOQmVQVTWe+ZqQfhaGxsHm+l3WUNoAqgDKAILaUvGJyfwQwHneGABqSCSU0LjyLUu5qksxtvaOOAB87sSoAGYKO9kAdHc+kDjYuLp9VtpxxMQc85QOFgnhh7p0rLwICQbBBeH8AUC+FlMPdQrDJEA" rel="nofollow noreferrer">here</a></p>
  
  <p>I have a type that is an intersection of union types:</p>
  
  <pre><code>type Location = {
    latitude: number,
    longitude: number
  } &amp; ({
    locationType: 'country',
    country: string
  } | {
    locationType: 'state',
    state:string
  })
  </code></pre>
  
  <p>I have another function that does something based on one of the union types:</p>
  
  <pre><code>const getLocationValue = (location: Location): string =&gt; {
    if (location.locationType === 'country')
      return location.country
    else
      return location.state
  }
  </code></pre>
  
  <p>However, this gives me the error: </p>
  
  <blockquote>
    <p>property <code>country</code>. Property cannot be accessed on any member of intersection type</p>
  </blockquote>
  
  <p>^ property <code>state</code>. Property cannot be accessed on any member of intersection type</p>
  
  <p>Flow should be able to understand that if locationType is country, then it should have a country property.</p>
  
  <p>What am I doing wrong?</p>