title: How do you do an exhaustive switch case in Typescript with string enums that refer to other string enums
body: <p>I have a string enum that is a subset of the values from another string enum. I am trying to do an exhaustive switch case across the former.</p>
  
  <p>This is a contrived example of the construct I am attempting to represent in Typescript</p>
  
  <pre><code>const enum Color {
      BLUE = 'Blue',
      YELLOW = 'Yellow',
      RED = 'Red'
  }
  
  const enum SupportedColor {
      BLUE = Color.BLUE,
      YELLOW = Color.YELLOW
  }
  
  
  function doSomething(colorFromOutsideInput: string): boolean {
      const supportedColor: SupportedColor = (colorFromOutsideInput as unknown) as SupportedColor;
      switch (supportedColor) {
          case SupportedColor.BLUE:
              return true;
          case SupportedColor.YELLOW:
              return true;
          default:
              return invalidColor(supportedColor);
      }
  }
  
  function invalidColor(supportedColor: never): never {
      throw new Error();
  }
  </code></pre>
  
  <p>In this code, the default in the switch case fails compilation with </p>
  
  <pre><code>Argument of type 'SupportedColor' is not assignable to parameter of type 'never'.
  </code></pre>
  
  <p>If I were to do this switch case across the <code>Color</code> enum instead of <code>SupportedColor</code> enum, it would work.</p>
  
  <p>Based on reading in the typescript docs, I see no evidence of why the compiler treats the two enums differently because they evaluate to the same strings.</p>