0

I am very new to TypeScript and have just been setting up a project with Grunt. When compiling I receive a large amount duplicate errors in relation to the TypeScript grunt-typescript folder. Any advice would be appreciated!

 Bens-MacBook-Pro:Chapter1 bendavies$ Grunt Running "watch" task Waiting... >> File "app.ts" changed. Running "typescript:base" (typescript) task >> node_modules/grunt-typescript/node_modules/typescript/lib/lib.core.d.ts(83,5): error TS2300: Duplicate identifier 'configurable'. 

This is just a subset of the errors, but they all seem to be duplicate related!

Cheers!

Here is my tsconfig.json file if that's any help!

 { "compilerOptions": { "outDir": "tasks", "target": "ES5", "module": "commonjs", "noEmitOnError": true, "diagnostics": true, "noLib": true, "experimentalDecorators": true }, "files": [ "src/index.ts", "node_modules/typescript/lib/lib.core.d.ts", "typings/lib.support.d.ts" ], "exclude": [ "node_modules", "typings/browser.d.ts", "typings/browser/**" ] } 

2 Answers 2

0

As you have not included your tsconfig.json - I might guess that you missed to exclude node_modules folder.

Try with 'exclude' section set like in the sample below:

{ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "moduleResolution": "node", "module": "commonjs", "target": "es6", "sourceMap": true, "outDir": "bin", "declaration": true }, "exclude": [ "node_modules", "typings/browser.d.ts", "typings/browser/**" ] } 
Sign up to request clarification or add additional context in comments.

6 Comments

Hi I gave this a go but it still produces the error! I've added my tsconfig.json file if you could please give that a look over!
you do not need 'files' section. try without it.
tsc automatically include lib.core.d.ts. And lib.support.d.ts will be included as it is not explicitly excluded
Unfortunately get the same problem! Also tried deleting the troublesome libraries but then it complains about not finding variables, can't win! haha!
Do you get the same errors if you build without grunt with pure tsc? You can also try to setup build using gulp (gulp task will be somewhat like this: stackoverflow.com/questions/35956888/gulp-and-ts-compilation/…) and see if error will persist. If you do not get the errors - then its an issue with your grunt config/setup.
|
0

Resolved the issue by modifying the GruntFile.js to a more specific set of sources. Here is the GruntFile I am using now!

module.exports = function(grunt){ grunt.loadNpmTasks('grunt-typescript'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), typescript: { base: { src: ['*.ts'], options:{ module: 'commonjs', target: 'ea5', sourceMap: true } } }, watch: { files: '*.ts', tasks: ['typescript'] } }); grunt.registerTask('default',['watch']); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.