Search code examples
meteortypescriptangular-meteor

Typescript Duplicate identifier error


I am getting the following error when I try to run my angular-meteor client (ionic serve):

[00:29:20]  typescript: node_modules/meteor-typings/1.3/main.d.ts, line: 657 
            Duplicate identifier 'Status'. 

     L657:    type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline';

[00:29:20]  typescript: node_modules/meteor-typings/1.3/main.d.ts, line: 695 
            Duplicate identifier 'Status'. 

     L695:      type Status = 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline';

[00:29:20]  transpile failed 

The error in the source code file is: TS2300:Duplicate identifier 'Status'.

The project is built using this tutorial: https://angular-meteor.com/tutorials/whatsapp2/ionic/setup Most files are identical to here: https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp

Ionic Framework: 2.1.0
Ionic Native: 2.4.1
Ionic App Scripts: 1.1.3
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.3.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

You can see all the involved files in this codebase.

Any ideas what is going on? Where to look next? I admit I am a bit lost. I reverted all my code changes since it last worked and removed the node_modules and reinstalled the project requirements. I still get the same error although as far as I see it nothing changed.

I am grateful for any guidance/ideas.


Solution

  • I had this in my tsconfig file:

    "types": [
      "meteor-typings",
      "@types/underscore"
    ]
    

    As soon as I removed 'meteor-typings', it worked!

    "types": [
      "@types/underscore"
    ]
    

    In my package.json file I have:

      "devDependencies": {
        "@ionic/app-scripts": "1.1.3",
        "@types/meteor": "^1.3.32",
        "@types/underscore": "^1.7.36",
        "meteor-typings": "^1.3.1",
        "tmp": "0.0.31",
        "typescript": "2.0.9",
        "typescript-extends": "^1.0.1"
      },
    

    Somehow I guess it was already part of the transpile process and the additional line in tsconfig made it appear doubly so. (This is my personal guess and I do not know why) :)