title: How to "weaken" multiple properties of a type
body: <p>When working with autogenerated class/interface files (through something like Swagger Codegen), it often becomes necessary to modify these models. For instance, suppose you have an autogenerated <code>HighSchool</code> class.</p>
  
  <pre class="lang-ts prettyprint-override"><code>export interface HighSchool {
      schoolTypeCode: number;
      name: string;
      state: string;
      city: string;
  }
  </code></pre>
  
  <p>Let's say we create an enum to make working with known <code>schoolTypeCode</code> values easy.</p>
  
  <pre class="lang-ts prettyprint-override"><code>export const enum HighSchoolTypeCode {
      USHighSchool,
      GED,
      OnlineSchool
  }
  </code></pre>
  
  <p>Rather than modifying the autogenerated <code>HighSchool</code> interface to use this enum, which will be overwritten once autogeneration is reexecuted, I can create my own <code>HighSchool</code> interface in a separate file and retype the <code>schoolTypeCode</code> by "weakening" it using a helper type, <a href="https://github.com/Microsoft/TypeScript/issues/3402#issuecomment-385975990" rel="nofollow noreferrer">as described in this GitHub issue response</a>.</p>
  
  <pre class="lang-ts prettyprint-override"><code>export interface HighSchool extends Weaken&lt;HighSchool, 'schoolTypeCode'&gt; {
    schoolTypeCode?: HighSchoolTypeCode;
  }
  </code></pre>
  
  <p>Here is the <code>Weaken</code> helper type:</p>
  
  <pre class="lang-ts prettyprint-override"><code>type Weaken&lt;T, K extends keyof T&gt; = {
    [P in keyof T]?: P extends K ? any : T[P];
  };
  </code></pre>
  
  <p>The limitation here is that only one property can be weakened at a time. Can this helper type be reworked to take in an array of property names? While this syntax might not be correct, I'm imagining it being used something like this:</p>
  
  <pre><code>interface WeakenedType extends Weaken&lt;OriginalType, ['foo', 'bar']&gt; {
      foo?: FooEnum;
      bar?: BarEnum;
  }
  </code></pre>