title: Express Mongoose populate pre typescript what type?
body: <p>I'm updating an old javascript express app
  to a brand new typescript app.
  I've a problem with typing populate</p>
  <pre><code>/* Kind of like a middleware function after creating our schema (since we have access to next) */
  /* Must be a function declaration (not an arrow function), because we want to use 'this' to reference our schema */
  const autoPopulatePostedBy = function (next) {
    this.populate('postedBy', '_id username avatar');
    this.populate('comments.postedBy', '_id username avatar');
    next();
  };
  
  /* We're going to need to populate the 'postedBy' field virtually every time we do a findOne / find query, so we'll just do it as a pre hook here upon creating the schema */
  postSchema.pre&lt;IPostSchema&gt;('findOne', autoPopulatePostedBy).pre&lt;IPostSchema&gt;('find', autoPopulatePostedBy);
  /* Create index on keys for more performant querying/post sorting */
  
  postSchema.index({ postedBy: 1, createdAt: 1 });
  
  export default model&lt;IPostSchema&gt;('Post', postSchema);
  </code></pre>
  <p>I've got error for next and this, typescript point out
  to type any and for pre</p>
  <pre><code>Argument of type '&quot;findOne&quot;' is not assignable to parameter of type 'RegExp | MongooseDocumentMiddleware | MongooseDocumentMiddleware[]'
  </code></pre>
  <p>How can I fix it?</p>