title: Converting String array to Enum in Typescript
body: <p>I am playing around with Typescript a little.</p>
  
  <p>Suppose I have an <code>object</code> such as this</p>
  
  <pre><code>let colors = {
      RED: "r",
      GREEN: "g",
      BLUE: "b"
  }
  </code></pre>
  
  <p>Now I want to convert this into an <code>enum</code> type</p>
  
  <pre><code>enum Colors = {
      RED = "r",
      GREEN = "g",
      BLUE = "b"
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I want the generated <code>typings</code> for the <em>colors</em> object such that
  if I add another <code>key</code> to the colors object, It should be included in the <code>typings</code>.</p>
  
  <p>If I do </p>
  
  <pre><code>colors['YELLOW'] = "y"
  </code></pre>
  
  <p>then the generated <code>typings</code> should be </p>
  
  <pre><code>declare enum colors {
      RED = "r",
      GREEN = "g",
      BLUE = "b",
      YELLOW = "y"
  }
  </code></pre>
  
  <p>instead, the generate typings are </p>
  
  <pre><code>declare const colors {
       [x: string]: string        
  }
  </code></pre>
  
  <p>How can I achieve this?</p>