title: Typescript enum static checking
body: <p>I'm still not sure how to make sense of typescript enums.</p>
  <p>Consider this:</p>
  <pre><code>enum Int { a, b };
  const array: Int[] = [];
  array.push(Int.a); // ok
  array.push(0); // same
  array.push(1); // this is b
  array.push(123); // works
  array.push(-3e6); // also works
  </code></pre>
  <p>So any <code>number</code> is compatible to <code>Int</code> ??</p>
  <p>I'm aware that I can dynamically check since the <code>enum</code> declaration also generates an object declaration, unless we use <code>const enum</code>. But I was exprecting the static type to be <code>0 | 1</code> and not <code>number</code>.</p>
  <p>Now for string enums:</p>
  <pre><code>enum Str { a = 'a', b = 'b' };
  const array: Str[] = [];
  array.push(Str.a); // ok
  array.push('a'); // fails
  </code></pre>
  <p>So coming from the previous exemple, one might have thought that <code>Str</code> would be compatible with <code>string</code>, but no. It's not event compatible with <code>&quot;a&quot; | &quot;b&quot;</code>.</p>
  <p>Can someone help me make sense of that ?</p>
  <p>Specifically, I'm looking at some insight on why things work this way, and is there a way to have the compiler check things for us ?</p>