title: const enum in Typescript
body: <p>I have a React application that is using Typescript. Right now I'm running into an issue with const enum. Here's my enum:</p>
  
  <pre><code>export const enum Snack {
      Apple = 0,
      Banana = 1,
      Orange = 2,
      Other = 3
  }
  </code></pre>
  
  <p>The service I'm trying to match up to isn't returning the value, but the index of the item within the enum. So, for instance, if the user is set to snack on an apple, the service is returning a 0 for that user instead of 'Apple'. Ideally, I'd like to do something like:</p>
  
  <pre><code>var snackIndex = UserSnack.type; // returning 0 in this example
  var userSnack = Snack[snackIndex]; // would return 'Apple'
  </code></pre>
  
  <p>When I try something similar I'm getting the following error:</p>
  
  <p><em>error TS2476: A const enum member can only be accessed using a string literal.</em></p>
  
  <p>Since the service I'm receiving the data from doesn't return the string, I'm having issues getting this working.</p>
  
  <p>Any help is appreciated.</p>