title: Typescript is not recognising the type of user from express-session
body: <p>I'm retrieving the user object from the database and setting it on the express-session:</p>
  <pre><code>export const postLogin = async (
      request: Request,
      response: Response,
      next: NextFunction
  ): Promise&lt;void&gt; =&gt; {
      try {
          request.session.user = await UserModel.findById('6127bd9d204a47128947a07d').orFail().exec()
          response.redirect('/')
      } catch (error) {
          next(error)
      }
  }
  </code></pre>
  <p>Then I call the Mongoose method <code>populate()</code> on the user object to get the cart associated with it:</p>
  <pre><code>export const getCart = async (
      request: Request,
      response: Response,
      next: NextFunction
  ): Promise&lt;void&gt; =&gt; {
      try {
          const userWithCartProducts = await request.session.user
              .populate('cart.items.productId')
              .execPopulate()
      } catch (error) {
          next(error)
      }
  }
  </code></pre>
  <p>But here I'm getting an error: <code>TypeError: request.session.user.populate is not a function</code></p>
  <p>I have defined the custom user type on express-session like following:</p>
  <pre><code>declare module 'express-session' {
      interface SessionData {
          user?: DocumentType&lt;User&gt;
      }
  }
  </code></pre>
  <p>As you can see in above definition of <code>user</code>, I'm using <code>DocumentType&lt;User&gt;</code> because I'm typing my models using <a href="https://typegoose.github.io/typegoose/docs/guides/quick-start-guide" rel="nofollow noreferrer">Typegoose</a>. I'm not sure if this is how it's done for Typegoose.</p>
  <p>What am I doing wrong? Any input would be much appreciated.</p>