I have an Angular application generated using Yeoman gulp typescript generator.
Suddenly without any apparent reason (change in project) during build typescript started throwing errors:
.tmp/typings/moment/moment-node.d.ts(6,16): error TS2300: Duplicate identifier 'moment'.
[22:08:34] [TypeScript] TypeScript error: .tmp/typings/moment/moment-node.d.ts(6,16): error TS2300: Duplicate identifier 'moment'.
.tmp/typings/moment/moment.d.ts(8,13): error TS2300: Duplicate identifier 'moment'.
See below content of below files for the reference.
I removed 'tsd:install' from gulp script
task to prevent build from overriding d.ts files and tsd.d.ts file. Then tried to modify tsd.d.ts to fix problem (I tried to remove moment-node, moment, change order,I also tried to edit moment.d.ts and moment-node.d.ts, nothing worked :/).
My tsd.json file:
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": ".tmp/typings",
"bundle": ".tmp/typings/tsd.d.ts"
}
My script.js (gulp taks):
'use strict';
var path = require('path');
var gulp = require('gulp');
var conf = require('./conf');
var browserSync = require('browser-sync');
var $ = require('gulp-load-plugins')();
var tsProject = $.typescript.createProject({
target: 'es5',
sortOutput: true
});
gulp.task('scripts', ['tsd:install'], function () {
return gulp.src(path.join(conf.paths.src, '/app/**/*.ts'))
.pipe($.sourcemaps.init())
.pipe($.tslint())
.pipe($.tslint.report('prose', { emitError: false }))
.pipe($.typescript(tsProject)).on('error', conf.errorHandler('TypeScript'))
.pipe($.concat('index.module.js'))
.pipe($.sourcemaps.write())
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app')))
.pipe(browserSync.reload({ stream: true }))
.pipe($.size())
});
Generated tsd.d.ts:
/// <reference path="angular-local-storage/angular-local-storage.d.ts" />
/// <reference path="angular-ui-router/angular-ui-router.d.ts" />
/// <reference path="angularjs/angular-animate.d.ts" />
/// <reference path="angularjs/angular-cookies.d.ts" />
/// <reference path="angularjs/angular-mocks.d.ts" />
/// <reference path="angularjs/angular-resource.d.ts" />
/// <reference path="angularjs/angular-sanitize.d.ts" />
/// <reference path="angularjs/angular.d.ts" />
/// <reference path="bootstrap/bootstrap.d.ts" />
/// <reference path="d3/d3.d.ts" />
/// <reference path="jquery/jquery.d.ts" />
/// <reference path="moment/moment.d.ts" />
/// <reference path="moment/moment-node.d.ts" />
/// <reference path="toastr/toastr.d.ts" />
If you point to a specific version like 1.4.1 instead of "master" for the ref: - I think it will fix it for you. It work for me.
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "1.4.1",
"path": ".tmp/typings",
"bundle": ".tmp/typings/tsd.d.ts"
}