Rhushikesh Rhushikesh - 29 days ago 14
Node.js Question

angular typing and nodejs typing 'node.d.ts' conflict

I am working on nodejs application in typescript with angular which is also in typescript. i have use gulp to transpile the files to js. but when i run command to transile my angular file it gives me error TS2300: Duplicate identifier

enter image description here

here is my gulp.config.js

module.exports = function () {
var config = {
allTs:'./src/**/*.ts',
typeings:'./typings/**/*.ts',
server:'./server.ts',
tsOutPutPath:'./app',
allNgTs:'./client/**/*.ts',
ngOut:'./public/scripts/src'
};
return config;
}


here is my gulp task

gulp.task('compile-ng', function () {

var sourceTsFiles = [
config.typeings,
config.allNgTs
]

del(['public/scripts/**/*.js','public/scripts/**/*.html']).then(paths => {
console.log('Deleted files and folders:\n', paths.join('\n'));
});
var tsResult = gulp
.src(sourceTsFiles)
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));

return tsResult.js
.pipe(sourcemaps.write('../map'))
.pipe(gulp.dest(config.ngOut));
});

Answer

Add ngTypeings:'./node_modules/angular2/typings/**/*.ts', to gulp.config.json file and use this angular2 typing in task instead of typeings

 var sourceTsFiles = [
        config.ngTypeings,
        config.allNgTs
    ]
Comments