namespace vs module keywords in TypeScript
<p>I'd like to extend Express' Request interface to include user information.  This is common and has been asked here before, so I've been able to accomplish it with the following:</p>

<pre><code>import { IHttpUser } from './user.interface';


declare module "express" {
    export interface Request{
        user?: IHttpUser;
    }
}
</code></pre>

<p>Great - that works.  Without having to use any imports I can just go req.user wherever I am and I have typing information for it.</p>

<p>From what I understand using <code>module</code> is not the recommended way to do this.  I should be using <code>namespace</code>.  So I'd like to be able to go:</p>

<pre><code>import { IHttpUser } from './user.interface';

declare namespace Express {
    export interface Request{
        user?: IHttpUser;
    }    
}
</code></pre>

<p>...but I can't because if you have an <code>import</code> at the top this won't be picked up as being available globally (I apologize I don't know the correct terminology here).</p>

<p>So what is the "correct" way to do this?  It works like I have it, but since I'm supposed to move to using <code>namespace</code> I'd like to learn that way.</p>