2017-07-30 40 views
1
错误

我经常收到即使我排除tsconfig.jsonnode_modules目录,目录包含的所有打字稿文件位于此错误:重复标识符“元素”在打字稿

{ 
    "compilerOptions": { 
     "module": "system", 
     "noImplicitAny": true, 
     "removeComments": true, 
     "preserveConstEnums": true, 
     "sourceMap": true 
    }, 
    "include": [ 
     "src/ts/*.ts" 
    ], 
    "exclude": [ 
     "node_modules", 
     "**/*.spec.ts" 
    ] 
} 

这是我Gulpfile:

const gulp = require('gulp'); 
const sass = require('gulp-sass'); 
const ts = require('gulp-typescript'); 
const tsProject = ts.createProject('tsconfig.json'); 

const tasks = { 
    css:() => { 
     return gulp.src('./src/scss/*.scss') 
      .pipe(sass().on('error', sass.logError)) 
      .pipe(gulp.dest('./dist/css')); 
    }, 
    js:() => { 
     return tsProject.src() 
      .pipe(tsProject()) 
      .js.pipe(gulp.dest('./dist/js/')); 
    } 
}; 

gulp.task('js',() => { 
    tasks.js(); 
}); 

gulp.task('css',() => { 
    tasks.css(); 
}); 

这是错误跟踪:

$ gulp js 
[22:37:05] Using gulpfile ~/Development/proj/gulpfile.js 
[22:37:05] Starting 'js'... 
[22:37:05] Finished 'js' after 29 ms 
/Users/apple/Development/proj/node_modules/typescript/lib/lib.d.ts(7617,11): error TS2300: Duplicate identifier 'Element'. 
/Users/apple/Development/proj/node_modules/typescript/lib/lib.d.ts(7716,13): error TS2300: Duplicate identifier 'Element'. 
src/ts/main.ts(1,7): error TS2300: Duplicate identifier 'Element'. 
[22:37:07] TypeScript: 3 semantic errors 
[22:37:07] TypeScript: emit succeeded (with errors) 
Done in 3.76s. 

回答

1

它在我将Element类的名称更改为Elem后,我的main.ts正在工作 - 看起来像Element是保留名称。