title: TypeScript Express routes
body: <p>I am following a tutorial from <a href="https://blog.risingstack.com/building-a-node-js-app-with-typescript-tutorial/" rel="nofollow noreferrer">Building a Node.js App with TypeScript Tutorial</a>. I want to seperate the routes. So I tried to create a route folder and created a test.ts file with below content:</p>
  
  <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 {Router} from "express";
  
  let router = Router();
  router.get('/', get);
  /**
   * GET /
   * @param req
   * @param res
   * @param next
   */
  export async function get(req, res, next) {
      try {
          res.send("Testing...");
      } catch (err) {
          console.log('err', err);
          next(err);
      }
  }
  
  export {router};</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now I am trying to use it in server.ts files as below :</p>
  
  <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 * as express from "express";
  import * as TestRoute from './routes/test';
  
  class App {
      public express : express.Application;
  
      constructor() {
          this.express = express();
          this.mountRoutes();
      }
  
      private mountRoutes() : void {
          const routes: express.Router = express.Router();
          routes.use('/test', TestRoute);
          this.express.use('/', routes);
      }
  }
  
  export default new App().express;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But in this line <code>routes.use('/test', TestRoute);</code> TypeScript is throwing an error :</p>
  
  <p><code>Argument of type ... is not assignable to parameter of type 'RequestHandlerParams'.
  Argument of type ... is not assignable to type '(RequestHandler | ErrorRequestHandler)[]'.
  Property 'includes' is missing in type ...
  </code>
  ... is the path to my test.ts file.</p>
  
  <p>Could anybody help me identify what is this error and also can you give me a basic structure of creating routes and including it in TypeScript Apps. I am using TypeScript 2.7.</p>