title: How to fix ts(2322) when using a case switch and generics?
body: <p>I've been trying to use a switch case to map through values, using Typescript. For example, to get the string version of a number.</p>
  
  <pre><code>function getNumber(id) {
    switch (id) {
      case 1:
        return 'one';
      case 2:
        return 'two';
      case 3:
        return 'three';
    }
  }
  </code></pre>
  
  <p>I want to use Typescript to make sure that a valid key is passed, therefore I've tried the following interface and used it to extract the allowed keys</p>
  
  <pre class="lang-js prettyprint-override"><code>interface Numbers {
    1: 'one';
    2: 'two';
    3: 'three';
  }
  
  function getNumber&lt;K extends keyof Numbers&gt;(id: K) {
  }
  </code></pre>
  
  <p>So far so good! In fact if I try <code>getNumber(4)</code> I get an error.</p>
  
  <p>The issue happens with the return type. I'm expecting <code>Numbers[K] | void</code> to be returned.</p>
  
  <pre class="lang-js prettyprint-override"><code>function getNumber&lt;K extends keyof Numbers&gt;(id: K): Numbers[K] | void {
    switch (id) {
      case 1:
        return 'one';
      case 2:
        return 'two';
      case 3:
        return 'three';
    }
  }
  </code></pre>
  
  <p>But instead, I'm getting the error <code>Type '"one"' is not assignable to type 'void | Numbers[K]'.ts(2322)</code>.</p>
  
  <p>I'm seeing this with TS 3.5.1 and with previous versions I don't see the issue.</p>
  
  <p>Any idea?</p>