Eraldo
Eraldo

Reputation: 545

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.

Upvotes: 0

Views: 1318

Answers (3)

Stanley85
Stanley85

Reputation: 417

Just to clarify further: Within the api/tsconfig.json you leave the "meteor-typings" in types[] as is. Inside the root folder you remove the additional "meteor-typings" inside types[] then it should run without errors. Dont forget to add the softlink to node_modules inside the api folder.

For windows users this is done with:

mklink /d \node_modules ..\node_modules

There should be no package.json inside the api folder as described inside the tutorial.

Thanks for the fix.

Upvotes: 0

Andy Dorman
Andy Dorman

Reputation: 121

FWIW I started having this problem when I updated Ionic from 2.0.0 to 2.2.0.

The fix worked for me and I had the exact tsconfig.json file as in the tutorial:

"types": [
  "meteor-typings",
  "@types/underscore",
  "@types/meteor-accounts-phone",
  "@types/meteor-collection-hooks"
]

Removing "meteor-typings" fixed the problem. I am not sure why.

So I expect the tutorial may need updating as when someone updates to the latest Ionic. I will post an issue in their github repo.

Upvotes: 1

Eraldo
Eraldo

Reputation: 545

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) :)

Upvotes: 1

Related Questions