title: Typescript Express unit rest case issues
body: <p>I am using typescript with express in my project. I am using mocha and chai for unit testing. My package.json is as follows:</p>
  
  <pre><code>{
    "name": "node_ts",
    "version": "1.0.0",
    "description": "",
    "main": "dist/server.js",
    "scripts": {
      "lint": "./node_modules/.bin/tslint --project \".\"",
      "build": "babel src --out-dir lib --extensions \".ts,.tsx\"",
      "serve": "npm run build &amp;&amp; tsc &amp;&amp; node lib/server.js",
      "compile": "tsc &amp;&amp; node lib/server.js",
      "start": "nodemon -e ts --exec \"npm run build &amp;&amp; npm run compile\"",
      "test": "mocha --compilers babel-register-ts src/**/*.spec.ts"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
      "@babel/cli": "^7.2.3",
      "@babel/core": "^7.2.2",
      "@babel/plugin-proposal-object-rest-spread": "^7.3.1",
      "@babel/preset-env": "^7.3.1",
      "@babel/preset-typescript": "^7.1.0",
      "@types/chai": "^4.1.7",
      "@types/mocha": "^5.2.5",
      "babel-register": "^6.26.0",
      "chai": "^4.2.0",
      "mocha": "^5.2.0",
      "nodemon": "^1.18.9",
      "ts-node": "^8.0.2",
      "tslint": "^5.12.1",
      "typescript": "^3.3.1"
    },
    "dependencies": {
      "@babel/plugin-proposal-class-properties": "^7.3.0",
      "@babel/register": "^7.0.0",
      "@types/chai-http": "^3.0.5",
      "@types/express": "^4.16.1",
      "babel-register-ts": "^7.0.0",
      "chai-http": "^4.2.1",
      "express": "^4.16.4"
    }
  }
  </code></pre>
  
  <p>when i am running my server using</p>
  
  <pre><code>npm run start
  </code></pre>
  
  <p>I am getting the following issues.</p>
  
  <pre><code>node_modules/chai-http/types/index.d.ts:51:19 - error TS2430: Interface 'ChaiHttp.Response' incorrectly extends interface 'import("/home/anshu/projects/node_ts/node_modules/@types/superagent/index").Response'.
    Types of property 'setEncoding' are incompatible.
      Type '(encoding: string) =&gt; void' is not assignable to type '(encoding: string) =&gt; this'.
        Type 'void' is not assignable to type 'this'.
  
  51         interface Response extends request.Response {}
                       ~~~~~~~~
  
  node_modules/chai-http/types/index.d.ts:52:19 - error TS2430: Interface 'Agent' incorrectly extends interface 'SuperAgentStatic'.
    Types of property 'del' are incompatible.
      Type '(url: string, callback?: (err: any, res: Response) =&gt; void) =&gt; Request' is not assignable to type '(url: string, callback?: CallbackHandler) =&gt; SuperAgentRequest'.
        Types of parameters 'callback' and 'callback' are incompatible.
          Types of parameters 'res' and 'res' are incompatible.
            Type 'ChaiHttp.Response' is not assignable to type 'import("/home/anshu/projects/node_ts/node_modules/@types/superagent/index").Response'.
              Types of property 'setEncoding' are incompatible.
                Type '(encoding: string) =&gt; void' is not assignable to type '(encoding: string) =&gt; Response'.
                  Type 'void' is not assignable to type 'Response'.
  
  52         interface Agent extends request.SuperAgentStatic {
                       ~~~~~
  
  
  Found 2 errors.
  </code></pre>
  
  <p>Also when I am trying to run my test case using</p>
  
  <pre><code>mocha --compilers babel-register-ts src/**/*.spec.ts
  </code></pre>
  
  <p>I am getting the error as : TypeError: chai.request is not a function</p>
  
  <p>My test file is as follows:</p>
  
  <pre><code>#hello.ts    
      import app from "../app";
      import * as chai from "chai";
      import chaiHttp from "chai-http";
      import "mocha";
  
      chai.use(chaiHttp);
      const expect = chai.expect;
  
      describe("Hello API Request", () =&gt; {
        it("should return response on call", () =&gt; {
          return chai.request(app).get("/")
            .then(res =&gt; {
              expect(res).to.eql("lee");
            });
        });
      });
  </code></pre>
  
  <p>I think this is due to chai-http. Can anyone help to overcome this issue or provide any alternate solution.</p>