title: Is there a way to use the value from a specific key in a type declaration as the type of another key in that same declaration (in Typescript)?
body: <p>Let's say I'm trying to create a Variable type that takes a <em>type</em> key which has a type of <em>string</em>: is there a way to access the value from the key called <em>type</em> and use that as the type for another key in that type declaration? (Without using Generic Types)</p>
  <p>For example,</p>
  <pre><code>type Variable = {
    name: string;
    required: boolean;
    type: string;
    defaultValue: Variable[&quot;type&quot;];
  }
  
  const newWorkingVar: Variable = {
    name: &quot;count&quot;,
    required: true,
    type: &quot;number&quot;,
    defaultValue: 22 // This should work
  }
  
  const newErrorVar: Variable = {
    name: &quot;count&quot;,
    required: true,
    type: &quot;number&quot;,
    defaultValue: &quot;test&quot; // This should error
  }
  </code></pre>