Using import for modules in NodeJS causes type errors
<p>TSLint warns against using the <code>var</code> keyword in TypeScript, so I have been using <code>import</code> when importing modules. However, when I do this for local modules, it gives me an error when I tried to use the module.</p>

<p>In a file <code>routes/main.ts</code> I have:</p>

<pre><code>import express = require("express");
let router = express.Router();
router.get("/", (req, res, next) =&gt; { ... });

module.exports = router;
</code></pre>

<p>In <code>app.ts</code> I have:</p>

<pre><code>/// &lt;reference path="../../typings/main.d.ts" /&gt;
import express = require("express");
...
import routes = require("./routes/main");
let app = express();
app.use(routes); // The type error is here.
...
</code></pre>

<p>Using <code>import routes</code> causes the following type error when I use it with <code>app.use(routes);</code>:</p>

<pre><code>app.ts(36,13): error TS2345: Argument of type 'typeof ".../source/server...'
is not assignable to parameter of type 'RegExp'.
</code></pre>

<p>To fix this I can cast it to a particular type:</p>

<pre><code>app.use(&lt;express.Router&gt;routes);
</code></pre>

<p>But there are places where type casting is not as clean. I can switch to using the var keyword when I import the module:</p>

<pre><code>var routes = require("./routes/main");
let app = express();
app.use(routes); // No errors.
</code></pre>

<p>But is there a way to satisfy both the compiler and tslint? Or should I not use the <code>"no-var-requires": true</code> setting in tslint when using the CommonJS module style?</p>