0

I'm trying to build --prod my angular project and it keeps giving me this error

Failed to compile.

node_modules/@types/node/index.d.ts:73:11 - error TS2300: Duplicate identifier 'IteratorResult'.

73 interface IteratorResult<T> { }
             ~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6
    41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
            ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.
node_modules/typescript/lib/lib.es2015.iterable.d.ts:41:6 - error TS2300: Duplicate identifier 'IteratorResult'.

41 type IteratorResult<T, TReturn = any> = IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
        ~~~~~~~~~~~~~~

  node_modules/@types/node/index.d.ts:73:11
    73 interface IteratorResult<T> { }
                 ~~~~~~~~~~~~~~
    'IteratorResult' was also declared here.

I tried to install node modules again but I'm still getting this error.

1
  • 1
    Try npm install --save-dev @types/node and see Commented Mar 8, 2020 at 16:16

2 Answers 2

2

Add skipLibCheck: true to your tsconfig.json file. This prevents type checking the declaration files so you should not have the issue anymore. Here is also a link to the description in the documentation.

Possibly also upgrading some of the type definitions as suggested in the comment could help maybe you are using very old versions or you have duplicate references.

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

1 Comment

I had trouble using Angular WebWorkers with localize and this solved the issue. Thanks!
1

in my case, I get the TS2300: Duplicate identifier error when compiling my main project for the following reason:

In the my-custom-library.module.ts, I accidentally entered the path of the component causing the error with the wrong case.

import { InputPasswordComponent } from './components/input-Password/input-Password.component';

instead of

import { InputPasswordComponent } from './components/input-password/input-password.component';

This is confusing because no error is thrown while compiling the custom library. (ng build --prod).

Obviously, the skipLibCheck: true solution does not work in this particular case.

1 Comment

That was my problem too, I messed up the camelcasing in my component template and styleUrls. skipLibCheck is not a solution because it does not fix the problem, it just ignore it. Which can have consequences in the future.

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.