title: How to declare an object whose properties are of type string only using TypeScript?
body: <p>I have a configuration array in my component like this.</p>
  
  <pre><code>...
  config: ButtonConfig[];
  ...
  this.config.push(new ButtonConfig(...));
  ...
  </code></pre>
  
  <p>Today, I realized that it makes more sense to have the array behave like a dictionary so I can access the particular elements not by a numeric index but rather canonically by a name. I want to be able to do <code>config.submitButton</code> and not <code>config[3]</code> (even if I have an enum declared that maps <em>submitButton</em> to the requested index).</p>
  
  <pre><code>...
  config = { };
  ...
  this.config.submitButton = new ButtonConfig(...);
  ...
  </code></pre>
  
  <p>This works but I'm now allowing a bunch of <code>any</code>'s to spoof my code base, which is bad. I want the object to be aware that only things of type <code>ButtonConfig</code> can be put into it.</p>
  
  <p>I can declare a class with the fields because I want the number of them to be dynamically addable in the future, so the following won't do.</p>
  
  <pre><code>export class ButtonConfigs {
    submitConfig: ButtonConfig, ...
  }
  </code></pre>
  
  <p>I've check <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#type-assertions" rel="nofollow noreferrer">the docs</a> and <a href="https://stackoverflow.com/questions/12787781/type-definition-in-object-literal-in-typescript">some examples</a> not really recognizing what I'm looking for. Is it possible at all or an I confusing myself?</p>