title: TypeScript object with dynamic but required property type
body: <p>I have the following scenario. I need to create an object with a property that can be one of two possible types (custom classes).</p>
  
  <pre><code>export class MyType1 {
     // some properties
  }
  
  export class MyType2 {
     // some properties
  }
  
  class CustomType = MyType1 | MyType2
  
  class Config {
     propOne: boolean;
     dynamicParam: { [key: string ]: CustomType }
  }
  </code></pre>
  
  <p>The <em>Config</em> object would be used as provided below:</p>
  
  <pre><code>let config: Config = {
     propertyOne: true,
     dynamicParam: {
        key1: {
           // properties from one type
        },
        key2: {
           // properties from another type
        }
     }
  }
  </code></pre>
  
  <p>If I specify the type of the property when I define the object, as show below:</p>
  
  <pre><code>   key1: &lt;MyType1&gt; {
  
     }
  </code></pre>
  
  <p>I get intellisense for properties of MyType1 class. If I don't specify the type however, I get intellisense for the properties of both, MyType1 and MyType2 classes (since the type of dynamicParam property is CustomType [union type]).</p>
  
  <p>My question is, is it possible to make required type definition when defining the object, so that when I try to define a property as:</p>
  
  <pre><code>   key1: {
  
     }
  </code></pre>
  
  <p>I get an error that a type must be specified?</p>