title: Type definition for an object, which takes (self) reference on its values for a type
body: <p>Is it possible to define a type for an object, where one keys type takes reference on the values of another key?</p>
  <p>Let's say we want to have a type <code>Configuration</code> where <code>languages</code> can be defined. How can I make sure that the key <code>defaultLanguage</code> is one of the languages? The <code>languages</code> should act as union type.</p>
  <p>It is possible to write..</p>
  <pre><code>export const languages = ['de-CH', 'en-GB'] as const;
  type Language = typeof languages[number];
  
  export const defaultLanguage: Language = 'de-CH';
  </code></pre>
  <p>.., but is it also possible to write the type for an object, which represents the same without extract the <code>languages</code>?</p>
  <pre><code>type Configuration = {
    languages: string[],
    defaultLanguage: // A type which takes the values of languages and uses them as an union type here
  }
  </code></pre>
  <p>Here two simple test cases:</p>
  <pre><code>const goodConfig: Configuration = {
    languages: ['de-CH', 'en-GB'],
    defaultLanguage: 'de-CH'
  }
  
  const badConfig: Configuration = {
    languages: ['de-CH', 'en-GB'],
    defaultLanguage: 'de-DE' // &lt;- type error
  }
  </code></pre>