title: Typescript: How to populate object properties with their full name
body: <p>I have an variable defined like this:</p>
  
  <pre><code>interface MyObjects {
    Troll : {
      strength : string;
      dexterity : string;
      wisdom : string;
    },
    Child : {
      health : string;
      wellness : string;
    },
    Kitten : {
      sneakFactor : string;
      color : string;
    }
  }
  
  let myObjects : MyObjects;
  </code></pre>
  
  <p>Is there a way to use TypeScript to populate <strong>myObjects</strong> so that each string contains the fully qualified name like this:</p>
  
  <pre><code>myObjects.Troll.strength = 'Troll_strength';
  myObjects.Troll.dexterity= 'Troll_dexterity';
  myObjects.Troll.wisdom = 'Troll_wisdom';
  myObjects.Child.health = 'Child_health';
  //etc
  </code></pre>
  
  <hr>
  
  <p><strong>Update 1:</strong>
  I was hoping to use something like Object.keys( myObjects ) to get all the keys to then iterate over, but I can't get the keys of an uninitialized variable.</p>
  
  <hr>
  
  <p><strong>Update 2:</strong>
  I got a little further by using:</p>
  
  <pre><code>declare function keys&lt;T extends object&gt;() : Array&lt;keyof T&gt;;
  const k = keys&lt;MyObjects&gt;();
  </code></pre>
  
  <p>I now have all the key names at the root saved in the k array.  I can access each of the sub objects like this:</p>
  
  <pre><code>myObjects[k]
  </code></pre>
  
  <p>...but I'm now not sure how to get an array of all the sub properties of <strong>myObjects[k]</strong> since I don't have a type defined for each of those.</p>