title: NodeJs in Typescript
body: <p>I would like to use this way when I'm writing app.ts file.
  There are some issues concerning .d.ts imports, I don't get full api exposed of <code>express</code>. The issue is that I don't get full autocompletion in Webstorm2016 (haven't tried it vscode - not relevant for me for now).</p>
  
  <pre><code>///&lt;reference path="../../typings/main.d.ts"/&gt;
  import * as express from 'express';
  import * as logger  from 'morgan';
  import * as bodyParser from 'body-parser';
  import {join} from 'path';
  
  /* local imports*/
  import * as env from '../../tools/tasks';
  
  
  class Startup {
      private _app: express.Express;
      private _port: number;
  
      constructor() {
          this._app  = express();
          this._port = env.settings.PORT;
  
          this.initialize();
          this.setupViews();
          this.listener();
      }
  
      private initialize() : void {
          // this._app.[use] =&gt; not recognized
          this._app.use(logger('dev')); 
          this._app.use(express.static(join(__dirname, 'public')));
          this._app.use(bodyParser.json());
          this._app.use('/', this.router());
      }
  
      private setupViews() : void {
          // this._app.[engine] =&gt; not recognized
          // this._app.[set]    =&gt; not recognized
          this._app.engine('.html', require('ejs').__express);
          this._app.set("views", join(__dirname, "views"));
          this._app.set("view engine", "html");
      }
  
      private router(): express.Router {
          /* routes */
          let index: express.Router = this._app.get('/', (request: express.Request, response: express.Response) =&gt; {
              response.render('index', { title: 'This is express initial' });
          });
          return index;
      }
  
      private listener() : void {
          let server: any =  this._app.listen(this._port, () =&gt; {
              var listeningPort: number = server.address().port;
              console.log('The server is listening on port: ' + listeningPort);
          });
      }
  }
  
  declare var app = new Startup();
  </code></pre>
  
  <p>This is my compilation error list:</p>
  
  <pre><code>src/server/app.ts(5,20): error TS2307: Cannot find module 'path'.
  src/server/app.ts(8,22): error TS2307: Cannot find module '../../tools/tasks'.
  src/server/app.ts(25,13): error TS2339: Property 'use' does not exist on type 'Express'.
  src/server/app.ts(26,13): error TS2339: Property 'use' does not exist on type 'Express'.
  src/server/app.ts(26,37): error TS2304: Cannot find name '__dirname'.
  src/server/app.ts(27,13): error TS2339: Property 'use' does not exist on type 'Express'.
  src/server/app.ts(28,13): error TS2339: Property 'use' does not exist on type 'Express'.
  src/server/app.ts(32,13): error TS2339: Property 'engine' does not exist on type 'Express'.
  src/server/app.ts(32,29): error TS2304: Cannot find name 'require'.
  src/server/app.ts(33,13): error TS2339: Property 'set' does not exist on type 'Express'.
  src/server/app.ts(33,31): error TS2304: Cannot find name '__dirname'.
  src/server/app.ts(34,13): error TS2339: Property 'set' does not exist on type 'Express'.
  src/server/app.ts(39,41): error TS2339: Property 'get' does not exist on type 'Express'.
  src/server/app.ts(40,13): error TS2339: Property 'render' does not exist on type 'Response'.
  src/server/app.ts(46,32): error TS2339: Property 'listen' does not exist on type 'Express'.
  src/server/app.ts(54,17): error TS1039: Initializers are not allowed in ambient contexts.
  </code></pre>
  
  <p>typings.json:</p>
  
  <pre><code>        {
            "ambientDependencies": {
               "body-parser": "registry:dt/body-    parser#0.0.0+20160317120654",
   "express":"github:DefinitelyTyped/DefinitelyTyped/express/express.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
              "morgan": "registry:dt/morgan#1.2.2+20160317120654",
              "node": "registry:dt/node#4.0.0+20160319033040",
              "systemjs": "registry:dt/systemjs#0.18.4+20160316155526"
        }
      }
  </code></pre>
  
  <p>Actually have found an answer for that issue. For some reason <code>typings</code> stripping the two definitions of:
  <br/></p>
  
  <pre><code> - express-serve-static-core/express-serve-static-core.d.ts"
   - serve-static.d.ts
  </code></pre>
  
  <p>if you install both of them it's starting showing autocompletion. </p>