title: Accessing object with square brackets in typescript
body: <p>Simplified version of what I'm trying to accomplish.</p>
  <pre><code>const colors = {
    red: &quot;#8b0000&quot;,
    green: &quot;#008b00&quot;,
  }
  
  const logColor = (color: string) =&gt; {
    console.log(colors[color])
  }
  </code></pre>
  <p>This error comes from inside the console.log()</p>
  <pre><code>Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ red: string; green: string; }'.
  
  No index signature with a parameter of type 'string' was found on type '{ red: string; green: string; }'.
  </code></pre>
  <p>What do I need to do to fix that?</p>