TypeScript: Extend Express.Session interface with own class
<p>I'm working on a Typescript project with npm packages. I want to add a property to the Express.Session interface.</p>

<p>example Class:</p>

<pre><code>class User {
    name: string;
    email: string;
    password: string;
}

export = User;
</code></pre>

<p>New d.ts file for the interface definition (don't want to edit express-session.d.ts):</p>

<pre><code>declare namespace Express {
    interface Session {
        user: User
    }
}
</code></pre>

<p>app.ts</p>

<pre><code>import User = require('./User');

function (req: express.Request, res: express.Response) {
    req.session.user //I want to use it like this.
}
</code></pre>

<p>the problem is, that User is not known in de d.ts file. But neither require nor import the User-file fixes that.</p>

<p>How can I add my own class to the session interface?</p>