title: Using moment.js in Angular 2 typescript application
body: <p>I'm struggling in using moment.js library inside an Angular 2 Typescript app. Even after reading the answer to <a href="https://stackoverflow.com/q/35166168/1031097">this question</a> I can't get it to work.</p>
  
  <p>This is what I did so far:</p>
  
  <ul>
  <li>I installed moment.js using npm, so I can find the library under node_modules/moment/moment.js</li>
  <li><p>I configured System.js to retrieve moment library:</p>
  
  <pre><code>System.config({
      packages: {
        app: {
          format: 'register',
          defaultExtension: 'js'
        },
        moment: {
          main: 'moment.js',
          type: 'cjs',
          defaultExtension: 'js'
        }
      },
      map: {
        moment: 'node_modules/moment'
      }
  });
  </code></pre></li>
  <li>I installed typescript typings with <code>typings install moment-node --ambient --save</code> and <code>typings install moment --ambient --save</code>, so I can see the correct typings inside typings/main/ambient/moment-node and typings/main/ambient/moment</li>
  </ul>
  
  <p>Now, if in my code I use <code>import * as moment from 'moment';</code> typescript compilation run smooth and I can see the correct suggestion inside Atom editor (if I start with <code>moment().</code> I can see year(), month(), etc.). However if I run my code inside the browser, it gives an error saying that 'moment is not a function' (debugging I can see that moment is an object with lots of methods).</p>
  
  <p>If I write <code>import moment from 'moment';</code> the code in the browser runs fine, however typescript compilation fails with 'module moment has no default export' and I can't get any suggestion from Atom while writing code.</p>
  
  <p>What am I doing wrong? What's the correct way to import moment.js (and any non typescript library) inside an Angular 2 typescript application?</p>