title: TS how use generic condition in class constructor
body: <p>why TS wont allow me do this?
  From my test everything seem work ! no ?</p>
  <pre><code>    constructor(public readonly vtype: T) {
          // if KEYS.buffer ? is ValurBuffer or Valur ! why this no pass ?
          if (vtype === KEYS.buffer) {
              this.valur = new ValurBuffer(vtype);
          } else {
              this.valur = new Valur(vtype);
          }
      }
  </code></pre>
  <p><code>Type 'Valur&lt;T&gt;' is not assignable to type 'T extends VKEY.buffer ? ValurBuffer&lt;T&gt; : Valur&lt;T&gt;'.ts(2322)</code></p>
  <p>here a context code.</p>
  <pre><code>
  
  const enum KEYS {
      string = 'string',
      number = 'number',
      boolean = 'boolean',
      array = 'array',
      buffer = 'buffer',
  }
  
  type VALUES = {
      readonly [KEYS.string]: string;
      readonly [KEYS.number]: number;
      readonly [KEYS.boolean]: boolean;
      readonly [KEYS.array]: Array&lt;string | number | boolean&gt;;
      readonly [KEYS.buffer]: ReadonlyArray&lt;Token&lt;any&gt;&gt;;
  }
  
  
  export class Token&lt;T extends KEYS&gt; {
      readonly valur: T extends KEYS.buffer ? ValurBuffer&lt;T&gt; : Valur&lt;T&gt;;
      constructor(public readonly vtype: T) {
          // if KEYS.buffer ? is ValurBuffer or Valur ! why this no pass ?
          if (vtype === KEYS.buffer) {
              this.valur = new ValurBuffer(vtype);
          } else {
              this.valur = new Valur(vtype);
          }
      }
  }
  
  
  class Valur&lt;T extends KEYS&gt; {
      readonly Token: Token&lt;T&gt;;
      protected _value: VALUES[T];
      get value() {
          return this._value;
      }
      set value(value) {
          this._value = value;
      }
      constructor(public readonly vtype: T, shemas?: {}) {}
  }
  class ValurBuffer&lt;T extends KEYS.buffer&gt; {
      readonly Token: Token&lt;T&gt;;
      protected readonly _value: VALUES[T];
      get value() {
          return this._value;
      }
      add(v:VALUES[T]){}
      constructor(public readonly vtype: T, shemas?: {}) {}
  }
  
  
  const test1 = new Token(KEYS.array)
  test1.valur.value;
  test1.valur.value = [5];
  const test2 = new Token(KEYS.buffer);
  test2.valur.value
  test2.valur.value=[];
  test2.valur.add([new Token(KEYS.boolean)])
  </code></pre>
  <p><a href="https://www.typescriptlang.org/play?strictPropertyInitialization=false&amp;ssl=28&amp;ssc=6&amp;pln=21&amp;pc=1#code/LAKAxg9gdgzgLgAgKZQK4FsEGkCiBNAZQQG9QFyF4AnASygHMEBeBAcmrvtYBoyK10AIyRVmbAcKo8%205QRAgAbJAEMoY1nMUqo0kBQTKqVZQE91h4yd37BqAGZ2R62w5G6AvqFBwTAByQIAGoAggAyAKo4RCykehRUKgAm0ApmANq4hAB0HAwAugBclHC0DADcMggJyslQqQgZ%20ARZEiKFCK1UFXHk1bX1jdmaSqrtw9rd%20n0p6ZnNFqbtwUamADy5jAA%20HRiSCNvjqgB8k-FJMw1zWS6OVO0ASud1JsuWqwAqEADWKKuqJkcTqBPCAvCAkAAPXwQKiIMAKZQwGAIT4-KAfZAQuAoRLIuZHEiVabPBAAN2UClQVCK70x2KguOwTWu9luCAA-EEKVSAEKskQfAlFQLcqiC07kSCwEqoMBwGEACl8qEEChoYCqT3qpJ8-hpAEpCT19AgAPSmhA0OxMob80ScmjIkWUqh81yiGFcl0IACECAA7gALMxwQOOjoQBC%20RHI9mVfRWhAKnV%20AJMdM25o3ESG2Im-MIUOOrLk70sKBIf1e3l25O6pD6iUm9zIBQwAJ5gv6IswEuisQVqvOql11ON%20MUEH6EEgsHwmPVsW0yH0xn4o1TLVmVEoGnfX7vIHG3xUCDYuVIRIIAD6pdQSGFYUiBDS7zyTfoSEQd6QCtzE96L8qTUHsslvbkkCbKcKHbb8IOTCD-2Nbsw17cDKTTMkIKgyopWoWV5SoJUVTVDViW1esaW4ShAyQdBEXZIpiHcXMZ1AeckUXN1bgxFccTxZlsyoAlO0AmoLh3KA9zRcVKhPM8kAvK9yLMdD70fCIolfd9Kk-OCML-DcCwSOBgMLVCwJ-HDjRqRJkwKEJNJfN99WY3DoHwuVFWVVV1U1cSSRTPUUWomBaPomBGJIFjouBMF2I8xBsXgABGAdKxRfcoAVK4FhMfVvCQVK%20xdEr726ZK4BSsqqDKzC0gAVh08BEsLIq4AAJnSqtJJywS7XHEBKo6mq6sK%20ARrvWqfyYNJmuG0bbIVNJB0ytE%20qGeQRigfU8n1IA" rel="nofollow noreferrer">TSPLAYGROUND</a></p>