我正在使用angular也在typescript中的angularcript中的nodejs应用程序。我已经使用gulp将文件转换为js。但是当我运行命令来转换我的角度文件时,它会给我错误 TS2300:重复标识符
这是我的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;
}
这是我的gulp任务
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));
});
答案 0 :(得分:0)
你的tsconfig.json文件应该排除node_modules和任何可能与angular d.ts冲突的d.ts文件,即:
{
"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"
]
}
答案 1 :(得分:-1)
将ngTypeings:'。/ node_modules / angular2 / typings / ** / * .ts'添加到gulp.config.json文件并在任务中使用此angular2键入而不是输入
var sourceTsFiles = [
config.ngTypeings,
config.allNgTs
]