title: Omit properties of a class with generic type
body: <p>I'm working on a <a href="https://github.com/insurgent-lab/ts-entity/tree/refactor/add-strict-null-check" rel="nofollow noreferrer">Typescript entities library</a> (encoding/decoding JSON &lt;=> Classes).</p>
  
  <p>I'm trying to get the type checking right, and I successfully implemented it on my <code>Entity</code> class, but I can't get it right on my <code>EntityBuilder</code> class.</p>
  
  <p>The reason is that <code>Entity</code> works with class instances, but <code>EntityBuilder</code> works with classes.</p>
  
  <p>Here is a code sample (<a href="https://www.typescriptlang.org/play/?strictPropertyInitialization=false&amp;useDefineForClassFields=true&amp;target=99&amp;module=5&amp;ts=3.8.0-dev.20191224&amp;ssl=30&amp;ssc=59&amp;pln=30&amp;pc=66#code/MYGwhgzhAECC0G8CwAoa7oA8Bc0B2ArgLYBGApgE4DcqG0AXroaZTSgL6qpmYAOA9hQAu0UJBgBRPEICWQgJ4AhAjJAATSoloYA9ACo92jHujLVa6GDzQy0ufOj8SAKzLARAMwr8i0CPwIKYDJoNTAhMAA6I3Q9HRjeAhIQGWA-CNk0khV1AHk8MgAeABUbTCFbNRgreQA+AAps8wBhcChcYoAaPwCgsgARcLBcXKI5Eu6Aci8fACl-PEmAH0mhfnn+RdqASg6tNDoMIQALGQhI4GO3AGtW8QA1MBS1e0actTuobbYYumBNiAiWyyBS4GrQAC8+DIAHdoE11J8IPVvlwDodoDIPNA3i02ud-nhARQCO5BJCIVDYBQKGB5BcAUISWSKNtRAD+CAyJEQPwAOb1fyBYKDCLbNEY9A6HTQGEhWwQQIhE7haAAAxmRA2eDVmOqADcwKowMkQpBoCczr9dDL-gR1H4ZEReCAHORLHg8PwMmQLDC5Md1QABYryXhkeq5FxuITbNXW9BYnEKcP8bHA+yRTXailQ6YEPDuGSbSZs5DoyUZhRZ7xahaC3oioaoisYihkISBaxV+RsSXQdg2EAQELl-vodudijWIV9UVgSwwUrS0IlkRjPAWIhkBMDmKcFAxfSGVsmMwOoj22Qu+V2WRkGCaj2WGl0xzY2fBUJDaKn+IVxJklSdJwmAhE1AAWRqEoGnApEOm6T8BiGEYxiECZoGmWttWWVZ1gWSZagAbQAXV2aBilI-Z+0tAkrmAW58UeZ5Xjg-EW13Scux6YVkIiSIiDAXh6h7edIVqC1TnOcD8iKYpYPeJFulE5sWzoA8jwMX4TGaejrkxbEF0NZ5RHxWVzV4cRfUk7wCD5Y5f0OOIEgoGRDQqEDMlEPSkWYmQXgUXFEXxME8HkMtdyTeoUzINN4UUsyAEJKUwjwCyLEsItbSUTm8OECjhCQaUEepJiRdl7QsL0RHdDwAk3Us+0lA91NQDSUCkEElHeShIhkgp6lgboEHYbYgA" rel="nofollow noreferrer">Typescript playground</a>):</p>
  
  <pre class="lang-js prettyprint-override"><code>class A {
      x: number;
      z: number;
  }
  
  export class EntityBuilder {
      /**
       * Build an entity object from source data.
       */
      public static buildOne&lt;T extends any&gt;(buildClass: T, sourceData: Omit&lt;T, 'fromJson'|'toJson'&gt;): T {
          this.checkClassValidity(buildClass);
  
          const entity: any = new buildClass();
  
          if (buildClass.constructor === Array.constructor) console.log(sourceData)
  
          // we ensure that `fromJson` is available as this
          // could simply be annotated with `@Type(Object)`
          if (typeof entity.fromJson === 'function') {
            entity.fromJson(sourceData);
            return entity;
          } else {
            return sourceData as T // don't mind me
          }
      }
  
      /**
       * Build multiple entities from an array of source data.
       */
      public static buildMany&lt;T&gt;(buildClass: T, sourceData: Omit&lt;T, 'fromJson'|'toJson'&gt;[]): T[] {
          this.checkClassValidity(buildClass);
  
          return sourceData.map(entityData =&gt; this.buildOne&lt;T&gt;(buildClass, entityData));
      }
  
      /**
       * Check if a valid class was passed through.
       */
      private static checkClassValidity(buildClass: any) {
          if (typeof buildClass !== 'function') {
              throw new Error('Class could not be found');
          }
      }
  }
  
  EntityBuilder.buildOne(A, {})
  </code></pre>
  
  <p>the last line returns the following error:</p>
  
  <pre><code>Argument of type '{}' is not assignable to parameter of type 'Pick&lt;typeof A, "prototype"&gt;'.
    Property 'prototype' is missing in type '{}' but required in type 'Pick&lt;typeof A, "prototype"&gt;'.
  </code></pre>
  
  <p>while I expect it to tell me the second argument is missing the <code>x</code> and <code>z</code> properties.</p>
  
  <p>I'm omitting <code>fromJson</code> and <code>toJson</code> as these are methods from my <a href="https://github.com/insurgent-lab/ts-entity/blob/refactor/add-strict-null-check/src/Entity.ts" rel="nofollow noreferrer"><code>Entity</code> class</a> that should be use as a mother class for <code>class A</code> (not included for a straightforward code example).</p>
  
  <p>I could really use a hand on this, I've been on it the whole afternoon and I think I've checked pretty much every SO and Github thread.</p>
  
  <p>Thanks in advance.</p>