title: Typescript with MongoDB findOne method not working with generic
body: <p>I am writing a class to clean up a lot of my existing database code. The first step for this was writing a class to manage <code>Collection</code>s for me, which I attempted to do using a class with a generic.</p>
  <pre class="lang-js prettyprint-override"><code>interface MongodbItem {
      _id?: ObjectID
  }
  
  class CollectionManager&lt;DataType extends MongodbItem&gt; {
      database: Database;
      collection: Collection&lt;DataType&gt;;
      // ...
      async get(id?: ObjectID) {
          if (!id) return await this.collection.find({}).toArray();
          return await this.collection.findOne({ _id: id });
      }
  }
  
  </code></pre>
  <p>However, despite defining the <code>DataType</code> generic as having that <code>_id</code> Typescript gives me the following error (On the line with the <code>.findOne</code>):</p>
  <pre><code>Argument of type '{ _id: ObjectID; }' is not assignable to parameter of type 'FilterQuery&lt;DataType&gt;'.
    Type '{ _id: ObjectID; }' is not assignable to type '{ [P in keyof DataType]?: Condition&lt;DataType[P]&gt;; }'
  </code></pre>
  <p>reading through the handbook it looks like extending the generic in the way I am should enforce that it has an <code>_id</code> property, so I do not know why this error is still occuring.</p>