title: How to map an enum to another enum in typescript?
body: <p>I want to map one object's property that has an enum type to another object's property that is other enum type.</p>
  
  <p>I've tried with <code>type1.a as Enum2</code> or <code>Enum2[type1.a]</code> with no success.</p>
  
  <p>Here is my simplified code problem:</p>
  
  <pre class="lang-js prettyprint-override"><code>enum Enum1 {
    N = 0,
    A = 1,
    B = 2
  }
  
  enum Enum2 {
    A = 1,
    B = 2
  }
  
  interface Type1 {
    a: Enum1;
  }
  
  interface Type2 {
    a: Enum2;
  }
  
  const type1: Type1 = {
    a: Enum1.A
  };
  
  const type2: Type2 = {
    a: type1.a
  };
  </code></pre>
  
  <p><a href="https://www.typescriptlang.org/play/#src=enum%20Enum1%20%7B%0D%0A%20%20N%20%3D%200%2C%0D%0A%20%20A%20%3D%201%2C%0D%0A%20%20B%20%3D%202%0D%0A%7D%0D%0A%0D%0Aenum%20Enum2%20%7B%0D%0A%20%20A%20%3D%201%2C%0D%0A%20%20B%20%3D%202%0D%0A%7D%0D%0A%0D%0Ainterface%20Type1%20%7B%0D%0A%20%20a%3A%20Enum1%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20Type2%20%7B%0D%0A%20%20a%3A%20Enum2%3B%0D%0A%7D%0D%0A%0D%0Aconst%20type1%3A%20Type1%20%3D%20%7B%0D%0A%20%20a%3A%20Enum1.A%0D%0A%7D%3B%0D%0A%0D%0Aconst%20type2%3A%20Type2%20%3D%20%7B%0D%0A%20%20a%3A%20type1.a%0D%0A%7D%3B" rel="noreferrer">try it</a></p>
  
  <p>Throws the error:</p>
  
  <pre><code>Type 'Enum1' is not assignable to type 'Enum2'.
  (property) Type2.a: Enum2
  </code></pre>