title: Why TS throwing an error when using conditional types?
body: <p>I am trying to use conditional typing with Typescript but tsc throwing an error.</p>
  <pre><code>interface Player {
      name: string;
      position: string;
      leg: string;
  }
  
  interface Coach {
      name: string;
      licence: string;
  }
  
  type Role = 'coach' | 'player';
  
  
  function getPerson&lt;T extends Role&gt;(role: T): T extends 'coach' ? Coach : Player {
      if (role === 'coach') {
          return {} as Coach; // Type 'Coach' is not assignable to type 'T extends &quot;coach&quot; ? Coach : Player'
      } else {
          return {} as Player; // Type 'Player' is not assignable to type 'T extends &quot;coach&quot; ? Coach : Player'
      }
  }
  
  const person = getPerson('coach'); // const person: Coach
  const person2 = getPerson('player'); // const person2: Player
  </code></pre>
  <p>Could someone explain to me why it does not work? And how I should refactor my code to get proper types?</p>