title: Arrays of a specific type in typescript
body: <p>I define an array of a specific type in typescript. When assigning values that do not correspond to the type, error messages are generated as required. An assignment of the type <em>any</em> works, even if the type is not correct.</p>
  
  <p>Do I misunderstand the type definition of an array? Or do I underestimate the "power" of the anys :-)</p>
  
  <p>Here is a brief example:</p>
  
  <pre><code>export class ItemList {
  
    items: Array&lt;string&gt; = [];
  
    constructor() {
  
      // push a string directly =&gt; works
      this.items.push('item 1');
  
      // push a string variable =&gt; works
      let item2:string = 'item 2';
      this.items.push(item2);
  
      // push a number variable =&gt; doesn't work
      let item3 = 3;
      this.items.push(item3);
  
      // push a number as any type =&gt; works
      let item4:any = 4;
      this.items.push(item4);
  
    }
  
  }
  
  let itemList = new ItemList();
  </code></pre>
  
  <p>The error from the tsc is: </p>
  
  <p><code>error TS2345: Argument of type 'number' is not assignable to parameter of type</code> 'string'.</p>
  
  <p>Funny thing: the <a href="https://plnkr.co/edit/FiXFG8RMkK66bBtUMVSo" rel="nofollow noreferrer">plunkers</a> here works.</p>