title: Discriminated union discriminated on optional property
body: <p>I've been trying but failing to get this union type to work as I want, is this just not supported?</p>
  <pre><code>type TestA = { href: string; a: string };
  type TestB = { href?: never; b: string };
  
  type TestUnion = TestA | TestB;
  
  const test = (x: TestUnion) =&gt; {
    if (x.href) {
      console.log(&quot;X is TestA&quot;, x.a);
    } else {
      console.log(&quot;x should be TestB, but is TestUnion&quot;, x.b); // error
    }
  };
  </code></pre>