11

I get a lot of "Duplicate identifier" errors in Visual Studio 2013 which make my code unreadable since I installed Resharper 9.

Duplicate identifier

The only reason I can see that there are duplicate errors, is that in another project, these files are included and thus compiled another time. But it should not interfere. Even when I unload the "dependent" project, I still get these annoying highlighting errors. IPosition is not only the only one affected, ILabel, ILabelExample, etc. all got the same error on all fields.

These errors are highlighted in the code, but not in the error list - and compilation is fine.

Related questions:

What setting should I change to make them disappear? Thank you for helping.

Community
  • 1
  • 1
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
  • I understand that you include the file containing the interface in two or more .ts files, right? Perhaps using relative paths but not using the same root folder? Try to use all these relative paths starting from the same root folder. That works for me... (The compiler perhaps considers two *different* relative paths targeting the same file as *two different paths* and that is reason for "duplicate identifier" problem...) – zbynour Feb 02 '15 at 10:56
  • Indeed, I am not using the same root folder. I started to delete all to make this error disappear and I'm now trying to add them one by one to solve errors without having the problem above. – Mikaël Mayer Feb 02 '15 at 11:22
  • `Even when I unload the "dependent" project, I still get these annoying highlighting errors` Try restarting after unloading – basarat Feb 02 '15 at 23:30
  • For the moment, I could get rid of this errors by removing all comments. But if I do that, then I get compile errors and files which are not compiled in the folder (I have a custom build step) – Mikaël Mayer Feb 03 '15 at 08:50
  • I have the same problem. I searched for duplicate but didn't found anything! Also I tried to clear resharper cache but didn't solved. – alisabzevari Feb 03 '15 at 10:33
  • 5
    Unfortunately, now ReSharper doesn't handle this well. There exist two issues in YouTrack for that: https://youtrack.jetbrains.com/issue/RSRP-428536, https://youtrack.jetbrains.com/issue/RSRP-430212, please upvote. Thanks. – Anton Feb 03 '15 at 11:28
  • Thank you Anton. I upvoted both. Were you able to attach this SO question as well ? – Mikaël Mayer Feb 05 '15 at 09:21

3 Answers3

2

This is fixed in ReSharper 2016.2.

Doug Domeny
  • 4,410
  • 2
  • 33
  • 49
1

Try checking the bin folder. It can contain .ts files and it generates duplication. You need to add the bin folder to the exclusion list. Something like this:

....
"exclude": [
    "node_modules",
    "wwwroot/lib",
    "bin"
  ]
....
Julia Path
  • 2,356
  • 15
  • 21
VitalickS
  • 59
  • 1
  • 4
0

You have the part export interface IPosition in two files. You should get two identical errors in two different files.

Just add one of those files (or folders) to tsconfig.json to the "ignore" key.

Louay Alakkad
  • 7,132
  • 2
  • 22
  • 45
  • No this part appears in just one file. – Mikaël Mayer Dec 12 '15 at 11:17
  • 1
    The other file is in "node_modules". [Here's](https://github.com/urbanmassage/opool/blob/master/tsconfig.json#L8-L10) what I use for `tsconfig`. Add the "exclude" part to your project and it should work. – Louay Alakkad Dec 12 '15 at 14:53