title: In a Typescript declaration, how to have one value dependent to the type of another?
body: <p>I have the following code:</p>
  <pre class="lang-js prettyprint-override"><code>type ValidationResult = 'OK' | 'MISSING_FIELDS' | 'DUPLICATED_FIELD';
  
  type ValidationResultOkDetails = null;
  type ValidationResultMissingFieldsDetails = [string];
  type ValidationResultDuplicatedField = string;
  
  type Validation = {
    result: ValidationResult,
    details: any
  }
  </code></pre>
  <p>Is there a way in Typescript to tell the compiler that when the field <code>result</code> of <code>Validation</code> is 'OK', <code>details</code> is of type <code>ValidationResultOkDetails</code>, when it is 'MISSING_FIELDS', <code>details</code> should be <code>ValidationResultMissingFieldsDetails</code> and so on?</p>