title: How to use momentjs in TypeScript
body: <p>I have an <a href="https://github.com/zurfyx/angular-library-starter-kit" rel="nofollow noreferrer">Angular 5 library</a> project and I want to use <code>momentjs</code> version <code>2.20.1</code>.</p>
  
  <p>I followed <a href="https://momentjs.com/docs/#/use-it/typescript/" rel="nofollow noreferrer">moment docs</a> on how to install for TypeScript and for the most part everything works. When I test my library using <code>ng test</code> I have no problems however when I try to package the lib with <code>npm run build</code> I get</p>
  
  <blockquote>
    <p>Cannot call a namespace ('moment')</p>
  </blockquote>
  
  <p>when using <code>import * as moment from 'moment';</code>. And I get</p>
  
  <blockquote>
    <p>moment has no default export.</p>
  </blockquote>
  
  <p>when using <code>import moment from 'moment';</code> and setting <code>"allowSyntheticDefaultImports": true</code>.</p>
  
  <p>How do I properly install and use <code>momentjs</code>?</p>