title: Defining an interface for an array in Typescript
body: <p>I'm not yet familiar with Typescript, and I'm having troubles to define a simple array.</p>
  
  <p>My goal is to have an array where the key is a string and its values are of types <em>Sound</em>.</p>
  
  <p>I have defined an interface like that:</p>
  
  <pre><code>interface SoundsArrayType {
      [key: string]: Sound;
  }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>class SoundManager {
      private sounds: SoundsArrayType;
  
      constructor() {
        // error: Type 'undefined[]' is not assignable to type 'SoundsArrayType'.
        if(!this.sounds) this.sounds = [];
      }
  
      pauseAll() {
          for(let sound of this.sounds) {
              // error: Type 'SoundsArrayType' must have a '[Symbol.iterator]()' method that returns an iterator.
              sound.pause();
          }
      }
  }
  </code></pre>
  
  <p>I'm not sure how to fix these errors. I read the <a href="https://www.typescriptlang.org/docs/handbook/interfaces.html" rel="nofollow noreferrer">Interfaces page</a> from the Typescript site but I'm still stuck.</p>