title: Array with different objects in TypeScript
body: <p>How can I set a superior class in TypeScript when collecting various different objects in one array that inherit from the same class so that TypeScript doesn't show an error?</p>
  
  <p>I'm trying it like this:</p>
  
  <pre><code>interface IVehicle{
      modelName: string
  }
  
  interface ICar extends IVehicle{
      numberOfDoors: number,
      isDropTop: boolean
  }
  
  interface IBike extends IVehicle{
      hasDynamo: boolean
  }
  
  
  var vehicles: IVehicle[] =
      [
          {
              modelName: "carModelName", // Error
              numberOfDoors: 4,
              isDropTop: true
          },
          {
              modelName: "bikeModelName",
              hasDynamo: true
          }
      ]
  </code></pre>
  
  <p>Doing it this way, I'm getting errors.</p>
  
  <p>I'm just able to add objects of the superior interface <code>IVehicle</code> if I don't want any errors shown.</p>