I'm developing a web app, using angular 1.5, typescript 2.4.0, moment: 2.18.1, and gulp for project assembling.
Here is my tsconfig.json:
{
"files": [
"src/app/main.ts",
"types/**/*.ts"
],
"compilerOptions": {
"noImplicitAny": false,
"target": "es2015",
"allowSyntheticDefaultImports": true
}
}
Inside my date-range-picker.component.ts. I'm importing moment lib, as was proposed in the main documentation:
import * as moment from 'moment';
Which works fine for the main gulp project assembling task that relies on tsify plugin.:
var browserifyIt = browserify({
basedir: '.',
debug: true,
entries: paths.browserifyEntries,
cache: {},
packageCache: {}
}).plugin(tsify);
gulp.task('bundle', ['views'], function () {
return browserifyIt
.transform('babelify', {
presets: ['es2015'],
extensions: ['.ts']
})
.bundle()
.on('error', interceptErrors)
.pipe(source(fileNames.buildJs))
.pipe(ngAnnotate())
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write(paths.sourcemapPath))
.pipe(gulp.dest(paths.build));
});
But for the compiling of the tests I decided to use task employing tsProject():
const testSrcPaths = {
....,
componentTests: 'src/app/components/**/*.test.ts',
....
};
gulp.task('component-tests:compile', function () {
return gulp.src(testSrcPaths.componentTests).pipe(tsProject())
.on('error', interceptErrors)
.js.pipe(gulp.dest(`${paths.testsDist}/components`));
});
Which leads to the following error:
date-range-picker/date-range-picker.component.ts(2,25): error TS2307: Cannot find module 'moment'.
What can be done to fix it?