s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 179 forks source link

Duplicate identifier error #135

Open yaroslavya opened 8 years ago

yaroslavya commented 8 years ago

Im trying to switch from ts-loader to the awesome-typescript-loader. I did the following: npm install awesome-typescript-loder --save-dev Then in my webpack config I imported the ForkCheckerplugin like that: var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; And changed the ts-loader configuration to the following: { test: /\.ts$/, loader: 'awesome-typescript-loader', exclude: [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/] }, So its just ts-loader without the ignoreDiagnostics part of it. After running the build I get a lot of these:

ERROR in MyAwesomeNg2Project\typings\browser\ambient\core-js\core-js.d.ts (3033,5): error TS2300: Duplicate identifier 'export='.

I tried to adjust my tsconfig.json to exclude these typings like that: "exclude": [ "node_modules", "typings/main", "typings/main.d.ts", "typings/browser/ambient/node/index.d.ts", "typings/browser/ambient/node/node.d.ts", "typings/browser/ambient/core-js/core-js.d.ts", "typings/browser/ambient/core-js/index.d.ts", "typings/browser/ambient/jasmine/index.d.ts", but it doesnt make any effect. It seems that I need to provide the Duplicate identifier suppression to ignoreDiagnostics analogue of the ts-loader. But I didnt find any way to do this.

layton-glympse commented 8 years ago

I'm getting a similar issue. I upgraded from 1.1.1 which was constantly throwing random, unreliable errors about files not being findable that existed (it would output the correct path). Upon upgrade to ^2.0.0 (which gave me 2.1.1) those errors went away. However once I run npm start, after about 60 seconds (once I'm already using the site locally) I'll get a massive massive dump of errors complaining about duplicate identifier (over 40,000 errors). Here's my tsconfig exclude array:

  "exclude": [
    "./node_modules",
    "./typings/main.d.ts",
    "./typings/main"
  ],

This is pretty frustrating since exclude seems to do nothing in the 2.0.0 releases.

BorntraegerMarc commented 7 years ago

I've started a new angular2 project and included the following dev dependency: "@types/mocha": "2.2.33",

It installs correctly however when I run: webpack --config webpack.config.dev.js --progress --profile --watch

I get:

[at-loader] node_modules/@types/jasmine/index.d.ts:15:18 
    Duplicate identifier 'xit'. 

[at-loader] node_modules/@types/mocha/index.d.ts:33:13 
    Duplicate identifier 'describe'. 

[at-loader] node_modules/@types/mocha/index.d.ts:34:13 
    Duplicate identifier 'xdescribe'. 

[at-loader] node_modules/@types/mocha/index.d.ts:39:13 
    Duplicate identifier 'it'. 

[at-loader] node_modules/@types/mocha/index.d.ts:40:13 
    Duplicate identifier 'xit'. 

My webpack config file:

var webpack = require('webpack');

module.exports = {
    devtool: 'cheap-module-eval-source-map',

    output: {
        path: './public/js/app',
        publicPath: "/js/app/",
        filename: 'bundle.js',
        chunkFilename: '[id].chunk.js'
    },
    entry: {
        'app': './assets/app/main.polymer.ts'
    },

    resolve: {
        extensions: ['.js', '.ts']
    },

    module: {
        loaders: [
            {
                test: /\.ts$/,
                loaders: [
                    'awesome-typescript-loader',
                    'angular2-template-loader',
                    'angular2-router-loader'
                ]
            },
            {
                test: /\.html$/,
                loader: 'html'
            },
            {
                test: /\.css$/,
                loader: 'raw'
            }
        ]
    },

    plugins: [
        new webpack.ContextReplacementPlugin(
            // The (\\|\/) piece accounts for path separators in *nix and Windows
            /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
            './src' // location of your src
        )
    ]
};

Same thing happens with @types/jasmine: Just found out that the errors:

[at-loader] node_modules/@types/jasmine/index.d.ts:9:18 
    Duplicate identifier 'describe'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:11:18 
    Duplicate identifier 'xdescribe'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:13:18 
    Duplicate identifier 'it'. 

[at-loader] node_modules/@types/jasmine/index.d.ts:15:18 
    Duplicate identifier 'xit'. 

Apparently the issue was introduced with awesome-typescript-loader V 2.2.2. Versions under that works fine (tried 2.2.1 down to 1.11).

BorntraegerMarc commented 7 years ago

@s-panferov Any plans on fixing this issue?

jemise111 commented 7 years ago

Any update here? Or if not a fix does anyone know how to disable type checking for one .d.ts file. The "exclude" option in tsconfig doesn't seem to be doing the trick.

BorntraegerMarc commented 7 years ago

@jemise111 you should be able to set it with "types". For example:

"types": ["chai-http", "core-js", "mocha"]

nihiluis commented 7 years ago

any news ?

i'm using a local package as a dependency. both have react-router-dom as typings and I get duplicate error on these.