title: How to add index signature in TypeScript
body: <p>I am trying to use reduce with Typescript to reach a total count of incoming messages. I'm confused on how to add an index signature. I keep getting the error: " Element implicitly has an 'any' type because type '{}' has no index signature." on variables newArray and counts[k]. I have read through several similar questions but have not figured out how to apply them to my specific scenario. I am new to JavaScript and TypeScript. </p>
  
  <p>Here is my array: </p>
  
  <pre><code>        var data = [
          { time: '9:54' }, 
          { time: '9:54' },
          { time: '9:54' },
          { time: '9:55' }, 
          { time: '9:55' },
          { time: '9:55' },
          { time: '9:55' },
          { time: '9:56' }, 
          { time: '9:56' },
          { time: '9:56' },
          { time: '9:56' },
          { time: '9:57' }, 
          { time: '9:57' },
          { time: '9:57' },
          { time: '9:57' },
          { time: '9:57' }
      ];
  </code></pre>
  
  <p>This is how I need my array for use in a rechart graph:</p>
  
  <pre><code>        var dataWithCounts = [
          { time: '9:54', messages: 3 }, 
          { time: '9:55', messages: 4 }, 
          { time: '9:56', messages: 4 }, 
          { time: '9:57', messages: 5 }
      ];
  </code></pre>
  
  <p>With the help of 'Just a Student's' answer from this Stack Overflow question: <a href="https://stackoverflow.com/questions/44387647/group-and-count-values-in-an-array">Group and count values in an array
  </a>, I have the following. </p>
  
  <pre><code>        var counts = data.reduce((newArray, item) =&gt; {
             let time = item.time;
             if (!newArray.hasOwnProperty(time)) {
                 newArray[time] = 0;
             } 
             newArray[time]++;
             return newArray;
          }, {});
  
          console.log(counts);
  
          var countsExtended = Object.keys(counts).map(k =&gt; {
             return { time: k, messages: counts[k] };
         });
  
         console.log(countsExtended);
  </code></pre>
  
  <p>Where and how do I declare an index signature? Below are various things I've tried. </p>
  
  <ul>
  <li><p><code>let newArray: { [time: string] };</code> and receive a duplicate identifier error. </p></li>
  <li><p>adding string to the parameter <code>var counts = data.reduce((newA:string, item)</code> gives me an error "Element implicitly has an 'any' type because index expression is not of type 'number'."</p></li>
  <li><p>adding <code>newA[time].toString()</code>gives me errors, "The left-hand side of an assignment expression must be a variable or a property access."</p></li>
  </ul>