title: Iterate over an enum with typescript and assign to an enum
body: <p>I am attempting to iterate over all the values in an enum, and assign each value to a new enum. This is what I came up with....</p>
  
  <pre><code>enum Color {
      Red, Green
  }
  
  enum Suit { 
      Diamonds, 
      Hearts, 
      Clubs, 
      Spades 
  }
  
  class Deck 
  {
      cards: Card[];
  
      public fillDeck() {
          for (let suit in Suit) {
              var mySuit: Suit = Suit[suit];
              var myValue = 'Green';
              var color : Color = Color[myValue];
          }
      }
  }
  </code></pre>
  
  <p>The part <code>var mySuit: Suit = Suit[suit];</code> doesn't compile, and returns the error  <code>Type 'string' is not assignable to type 'Suit'</code>.</p>
  
  <p>If I hover over <code>suit</code> in the for loop, it shows me <code>let suit: string</code>. <code>var color : Color = Color[myValue];</code> also compiles without error. What am I doing wrong here as both examples with Suit and Color look identical to me. </p>
  
  <p>I'm on TypeScript version 2.9.2 and this is the contents of my tsconfig.json</p>
  
  <pre><code>{
      "compilerOptions": {
          "target": "es6",
          "module": "commonjs",
          "sourceMap": true
      }
  }
  </code></pre>
  
  <p>Is there a better way to iterate over all the values in an enum, whilst maintaining the enum type for each iteration?</p>
  
  <p>Thanks, </p>