重复的标识符'元素' TypeScript中的错误

时间:2017-07-30 10:38:43

标签: typescript

即使我在node_modules中排除了tsconfig.json目录,并且包含了所有TypeScript文件所在的目录,我仍然不断收到此错误:

{
    "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 个答案:

答案 0 :(得分:1)

我在Element中将Elem课程的名称更改为main.ts之后,现在可以正常工作了 - 看起来Element是保留名称。