title: TypeScript vs Legal JavaScript: An index must be of type 'string', 'number', 'symbol', or 'any'
body: <p>From typescriptlang.org:</p>
  
  <blockquote>
    <p><em>TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.</em></p>
  </blockquote>
  
  <p>This is false.</p>
  
  <p>Here, I have the error:</p>
  
  <pre><code>An index expression argument must be of type 'string', 'number', 'symbol', or 'any'
  </code></pre>
  
  <p>This is caused by the [ inline-map ] expression:</p>
  
  <pre><code>test = { true: 'Y', false: 'N', undefined: 'IDK', null: 'Nah', 0: 'none' }[ true ];
  </code></pre>
  
  <p>Isn't a <code>Boolean</code> a type "<code>&lt;any&gt;</code>"??? Pretty infuriating, since I use this syntax left right &amp; center.</p>
  
  <p>Moreover, the following works just fine:</p>
  
  <pre><code>{ true: 'Y', false: 'N', undefined: 'IDK', null: 'Nah', 0: 'none' }[ undefined ];
  { true: 'Y', false: 'N', undefined: 'IDK', null: 'Nah', 0: 'none' }[ null ];
  </code></pre>
  
  <p>The colloquial, "Anything that's legal JavaScript is perfectly legal TypeScript" is outright a false statement.</p>
  
  <p>Obviously, I can write it as:</p>
  
  <pre><code>{ true: 'Y', false: 'N', undefined: 'IDK', null: 'Nah', 0: 'none' }[ ''+true ];
  </code></pre>
  
  <p>But <strong>why is <code>Boolean</code> not of type <code>any</code>???</strong></p>
  
  <p>Is this a bug of TypeScript?</p>
  
  <p>Has this been reconciled in TS 2.1?</p>
  
  <p>Can I correct this issue in <code>tsconfig.json</code> or another way?</p>