title: Typescript: How to branch based on type
body: <p>I have something like this:</p>
  
  <pre><code>interface A {
    a1: string;
    a2: number;
    a3: boolean;
  }
  
  interface B {
    b1: number;
    b2: boolean;
    b3: string;
  }
  
  function foo&lt;K1 extends keyof A, K2 extends keyof B&gt;(input: K1 | K2) {
    if (input keyof A ) { // &lt;--- THIS IS WRONG!
      console.log('got A type');
    } else {
      console.log('got B type');
    }
  }
  
  foo('a1');
  foo('b2');
  </code></pre>
  
  <p>How do I update the if statement so that it branches correctly based on type?</p>
  
  <p>i've tried <strong>keyof, typeof, instanceof</strong> .... none of which are correct.</p>