title: TypeScript - storing a class as a map value?
body: <p>I have few classes. <code>Test~</code> classes extend <code>FrameModel</code>.  </p>
  
  <p>How can I create a map from <code>string</code> to subclasses of <code>FrameModel</code>?</p>
  
  <pre><code>import FrameModel from '../../FrameModel';
  import TestShipModel from './TestGeneratorModel';
  import TestGeneratorModel from './TestGeneratorModel';
  import TestPlanetModel from './TestGeneratorModel';
  
  export class DiscriminatorMappingData
  {
      static mapping: { [key: string]: typeof FrameModel } = {
          "TestShip": TestShipModel,
          "TestGenerator": TestGeneratorModel,
          "TestPlanet": TestPlanetModel,
      }
  }
  </code></pre>
  
  <p>This ends up with an error:</p>
  
  <p>DiscriminatorMappingData.ts(8,5): error TS2322: Type '{ [x: string]: typeof "...' is not assignable to type '{ [key: string]: typeof "...'.<br>
    Index signatures are incompatible.<br>
      Type 'typeof "...models/T...' is not assignable to type 'typeof ".../FrameModel"'.<br>
        Property 'FrameModel' is missing in type 'typeof ".../models/T...'.</p>
  
  <p>I assume this can be done with generics but I'm not sure how.</p>