title: Typescript and Express Validator custom validation types
body: <p>When using the custom method of express validator I'm getting error</p>
  
  <pre><code>Argument of type '(userDoc: User | null) =&gt; Promise&lt;never&gt; | undefined' is not assignable to parameter of type '(value: User | null) =&gt; PromiseLike&lt;never&gt;'.
    Type 'Promise&lt;never&gt; | undefined' is not assignable to type 'PromiseLike&lt;never&gt;'.
      Type 'undefined' is not assignable to type 'PromiseLike&lt;never&gt;'.
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import express from 'express';
  import { body } from 'express-validator/check'
  import User from '../models/User';
  
  import { login, signUp } from '../controllers/auth';
  const router = express.Router();
  
  router.post(
    '/sign-up',
    [
      body('username', 'User Name should be atlest 4 characters long')
        .isLength({ min: 4 })
        .isString()
        .trim()
      .custom((username: string, { req }) =&gt; {
        return User.findOne({ username }).then(userDoc =&gt; {
          if (userDoc) {
            return Promise.reject('User Name is already taken');
          }
        });
      })
    ],
    signUp,
  );</code></pre>
  </div>
  </div>
  </p>