title: Mapping enum in typescript
body: <p>What is the proper way to map enum in typescript?</p>
  
  <p>For instance I am playing around with an online typescript code editor and this works fine:</p>
  
  <pre><code>class Message
  {
      name: string;
      min: number;
      max: number;
      messageType: MessageType;
  }
  
  enum MessageType
  {
      none,
      email,
      sms
  
  }
  
  var jsonObj = {
      "name": "some name",
      "min": 0,
      "max": 10,
      "messageType": MessageType.email
  
  }
  
  var messageInstance: Message = &lt;Message&gt;jsonObj;
  
  console.log(messageInstance);
  </code></pre>
  
  <p>However, in my IDE <code>MessageType.email</code>shows an error of "value expected" if I use it in a json file.</p>
  
  <p>If I try:</p>
  
  <pre><code>"messageType": "MessageType.email"
  </code></pre>
  
  <p>In the online code editor then that generates an error.</p>
  
  <p>I am just getting started and can't find any clear instructions on how this should be done.</p>
  
  <p>edit:</p>
  
  <p>I just realised enums are number based so <code>"messageType": 2</code> or whatever corresponding number would be the correct way to go.</p>
  
  <p>Is there any way to make the enum readable in the json file (i.e. something like MessageType.email as a value) as when viewed alone the json file doesn't have the enum definitions so might be confusing so I'd rather do it that way if possible..</p>