Typescript/Resharper 9. Duplicate identifier
Asked Answered
C

3

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.

Chiaroscuro answered 2/2, 2015 at 8:55 Comment(7)
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...)Drachma
Indeed, I am not using the same root folder. I started to delete all <reference> to make this error disappear and I'm now trying to add them one by one to solve errors without having the problem above.Clotheshorse
Even when I unload the "dependent" project, I still get these annoying highlighting errors Try restarting after unloadingExpostulate
For the moment, I could get rid of this errors by removing all <reference> 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)Clotheshorse
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.Bedlam
Unfortunately, now ReSharper doesn't handle this well. There exist two issues in YouTrack for that: youtrack.jetbrains.com/issue/RSRP-428536, youtrack.jetbrains.com/issue/RSRP-430212, please upvote. Thanks.Dietrich
Thank you Anton. I upvoted both. Were you able to attach this SO question as well ?Clotheshorse
P
2

This is fixed in ReSharper 2016.2.

Prink answered 7/9, 2016 at 14:24 Comment(0)
M
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"
  ]
....
Mike answered 13/11, 2016 at 20:18 Comment(0)
H
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.

Hygroscope answered 12/12, 2015 at 0:34 Comment(2)
No this part appears in just one file.Clotheshorse
The other file is in "node_modules". Here's what I use for tsconfig. Add the "exclude" part to your project and it should work.Hygroscope

© 2022 - 2024 — McMap. All rights reserved.