1

I'm constantly getting this error even though I excluded node_modules directory in tsconfig.json, and included directory where all TypeScript files are located:

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

This is my 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();
});

This is the error trace:

$ 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 Answer 1

1

It works now after I changed the name of Element class to Elem in my main.ts - looks like Element is reserved name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.