title: Typescript property does not exist on union type
body: <p>This is a situation I have ran into a couple of times, it seems like it should be fairly straightforward, but I can't find a solution that doesn't set the type to any</p>
  
  <p>A function takes one of two different objects as the argument, checks which object has been received, and returns the corresponding field.</p>
  
  <p>This is a simplified version of the problem, but the issue is that the two objects are only distinguishable by their properties(which have no overlap), and I can't access any of the properties, because they're not present on the other type.</p>
  
  <pre><code>type Obj1 = {
    message: string
  }
  
  type Obj2 = {
    text: string
  }
  
  const getText = (obj: Obj1 |obj2): string =&gt; {
    if (obj.message) {
      return obj.message
    }
  
    return obj.text
  }
  </code></pre>