-1

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));
});
Rhushikesh
  • 3,630
  • 8
  • 45
  • 82

2 Answers2

0

Your tsconfig.json file should exclude node_modules and any d.ts files that may conflict with angular d.ts i.e:

{
  "compilerOptions": {    
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude":[    
    "fonts",
    "images",
    "img",
    "libs",
    "navigation",
    "node_modules",
    "pagehtmls",
    "typings"
  ]
}
eko
  • 39,722
  • 10
  • 72
  • 98
-1

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
    ]
Rhushikesh
  • 3,630
  • 8
  • 45
  • 82