How can moment.js be imported with typescript?
<p>I'm trying to learn Typescript. While I don't think it's relevant, I'm using VSCode for this demo.</p>

<p>I have a <code>package.json</code> that has these pieces in it:</p>

<pre><code>{
  "devDependencies": {
    "gulp": "^3.9.1",
    "jspm": "^0.16.33",
    "typescript": "^1.8.10"
  },
  "jspm": {
    "moment": "npm:moment@^2.12.0"
  }
}
</code></pre>

<p>Then I have a Typescript class <code>main.js</code> like this:</p>

<pre><code>import moment from 'moment';
export class Main {
}
</code></pre>

<p>My <code>gulpfile.js</code> looks like this:</p>

<pre><code>var gulp = require('gulp');
var typescript = require('gulp-tsb');
var compilerOptions = {
                        "rootDir": "src/",
                        "sourceMap": true,
                        "target": "es5",
                        "module": "amd",
                        "declaration": false,
                        "noImplicitAny": false,
                        "noResolve": true,
                        "removeComments": true,
                        "noLib": false,
                        "emitDecoratorMetadata": true,
                        "experimentalDecorators": true
                      };
var typescriptCompiler = typescript.create(compilerOptions);
gulp.task('build', function() {
  return gulp.src('/src')
    .pipe(typescriptCompiler())
    .pipe(gulp.dest('/dest'));
});
</code></pre>

<p>When I run gulp build, I get the message: <code>"../main.ts(1,25): Cannot file module 'moment'."</code></p>

<p>If I use <code>import moment = require('moment');</code> then jspm will work and bring in the module when I run the application, but I'm still receiving the build error.
I also tried:</p>

<pre><code>npm install typings -g
typings install moment --ambient --save
</code></pre>

<p>Instead of making the problem better though, it got worse. Now I get the above error on build as well as the following: <code>"../typings/browser/ambient/moment/index.d.ts(9,21): Cannot find namespace 'moment'."</code></p>

<p>If I go to the file provided by typings and add at the bottom of the file:</p>

<pre><code>declare module "moment" { export = moment; }
</code></pre>

<p>I can get the second error to go away, but I still need the require statement to get moment to work in my <code>main.ts</code> file and am still getting the first build error.</p>

<p>Do I need to create my own <code>.d.ts</code> file for moment or is there just some setup piece I'm missing?</p>