title: Typescript recursive method call to Omit property and method
body: <p>I have specification like this</p>
  
  <pre><code>type SpecificType&lt;U, T extends keyof U&gt; = {
      Name: T,
      Value: U[T]
  }
  
  class Builder&lt;TItems&gt; {
      private items: SpecificType&lt;TItems, any&gt;[] = [];
  
      and&lt;TType extends keyof TItems&gt;(type: TType, value: TItems[TType]): Builder&lt;Omit&lt;TItems, TType&gt;&gt; {
          return this.append(this.create(type, value));
      }
  
      append&lt;TType extends keyof TItems&gt;(item: SpecificType&lt;TItems, TType&gt;): Builder&lt;Omit&lt;TItems, TType&gt;&gt; {
          this.items.push(item);
          return this as Builder&lt;Omit&lt;TItems, TType&gt;&gt;;
      }
  
      build(): SpecificType&lt;any, any&gt;[] {
          return this.items;
      }
  
      private create&lt;TType extends keyof TItems&gt;(type: TType, value: TItems[TType]): SpecificType&lt;TItems, TType&gt; {
          return {
              Name: type,
              Value: value
          }
      }
  }
  </code></pre>
  
  <p>Builder is building items based upon generic type, which is basically map between name and type like so:</p>
  
  <pre><code>type Types = {
      "Type1": undefined,
      "Type2": { MaxAge: number }
  }
  </code></pre>
  
  <p>And here is how I use builder</p>
  
  <pre><code>const itemBuilder = new Builder&lt;Types&gt;();
  itemBuilder
      .and("Type1", undefined)
      .and("Type2", { MaxAge: 3 });
  </code></pre>
  
  <p>I have 2 questions</p>
  
  <ol>
  <li>I'm omitting specific type mapping with each call to <code>and</code> or <code>append</code> because those methods can be called only once per specific <code>key</code> in <code>TItems</code> (or in this case <code>Types</code>). Is it possible to also remove <code>and</code> and <code>append</code> when all <code>TItems</code> keys have been used? Currently if I call another <code>and</code> on <code>itemBuilder</code> autocomplete will offer this: <code>and(type: never, value: never)</code>. It would be much better if there was no <code>and</code> and <code>append</code> in autocomplete for <code>itemBuilder</code> after those first 2 calls.</li>
  <li>If you look at first <code>and</code> call on <code>itemBuilder</code>, since <code>Type1</code> mapping is <code>undefined</code>, I have to pass <code>undefined</code> as value. Is it possible to somehow pass just name to <code>and</code> method if it doesn't have mapping - because resulting <code>SpecificType</code> is just <code>{ Name: string }</code> and I don't need <code>value</code> (or I could declare mapping somehow different without using <code>undefined</code> maybe??)</li>
  </ol>