title: dynamically access enum in typescript by key
body: <pre><code>export enum MyEnum{
      Option1,
      Option2,
      Option3
  }
  
  
  string x = 'Option1';
  </code></pre>
  
  <p><code>MyEnum[x]</code> throws an error: </p>
  
  <blockquote>
    <p>Type string is not assignable to type MyEnum</p>
  </blockquote>
  
  <p>however:
  <code>MyEnum['Option1']</code> works.</p>
  
  <p>I need to use <code>MyEnum[x]</code> though (in a method that returns a MyEnum), where x is a calculated value that results in one of the valid enum options, how do I go about it? </p>