title: How to query string enums in TypeScript strict mode?
body: <p><strong>TypeScript 2.8.4 in strict mode</strong></p>
  
  <p>I've got an enum like this:</p>
  
  <pre><code>export enum TabIndex {
    Editor = 'editor',
    Console = 'console',
    Settings = 'settings',
    Outputs = 'outputs'
  }
  </code></pre>
  
  <p>Out of which I'm creating a Map like this:</p>
  
  <pre><code>tabs = new Map(&lt;[string, string][]&gt;Object.keys(TabIndex).map((key: any) =&gt; [TabIndex[key], key]));
  </code></pre>
  
  <p>Later on, I'm trying to get a particular member out of that Map using a query parameter which should be available in the Map:</p>
  
  <pre><code>const tabParam = this.urlSerializer.parse(this.location.path()).queryParams.tab; // this thign is either 'editor', 'console', 'settings', ... etc.
  </code></pre>
  
  <p>And then I do</p>
  
  <pre><code>if (this.tabs.has(tabParam)) { // at this point we know the tab is available
    this.selectTab(TabIndex[this.tabs.get(tabParam)!]); // here, TS thinks the index may be undefined, that's why I'm using the non-null assertion operator "!"
  }
  </code></pre>
  
  <p>This code still makes TS unhappy. It errors out with:</p>
  
  <pre><code>Element implicitly has an 'any' type because index expression is not of type 'number'.
  </code></pre>
  
  <p>And it is true, the index type is a string. But I know that and that's how it's supposed to be because enums support string values. Anybody an idea how to make TS happy here?</p>
  
  <p>I did some research and <a href="https://github.com/Microsoft/TypeScript/issues/17800#issuecomment-345397371" rel="nofollow noreferrer">this issue</a> comment suggests this workaround using <code>keyof typeof</code>:</p>
  
  <pre><code>const tabParam: keyof typeof TabIndex = this.urlSerializer.parse(this.location.path()).queryParams.tab;
  </code></pre>
  
  <p>This just makes TypeScript unhappy again:</p>
  
  <pre><code>Type 'string' is not assignable to type '"Editor" | "Console" | "Settings" | "Outputs"'
  </code></pre>