Search code examples
angularjsvisual-studionugetdefinitelytypedangularjs-1.6

Install Definitely Typed Angular from Visual Studio NuGet, getting repeated errors "Duplicate Identifiers"


I have installed the angularjs, and Definitely Typed Angular from the NuGet packages on Visual Studio. This all installed fine, with no errors. However whenever I start to try to write to a TS file, I get angular errors throughout the d.ts folder. When I hover over these errors I see "Duplicate Identifier 'angular'", and on the declare modules bit, I see "Ambient modules cannot be nested in other modules."

I have not done anything else other than install these two packages from NuGet.

Here is a picture of my folder structure:FolderStructure

EDIT:

As included above, I have started with a WebAPI project within Visual Studio. Using NuGet I have installed 'angularjs 1.6' and 'angularjs.TypeScript.DefinitelyTyped'.

From there I have created a 'app.ts' file. There is nothing else I have done. Building or compiling throws the errors described above.


Solution

  • It happens when both typings and @types available in your project. Both downloads same types defination which makes the duplicate error.

    You can delete either @types/ definition or typings.json to remove one extra types defination

    you do the below to handle this problem

    deleteing typings

    • delete typings folder
    • delete typing.json

    deleting @types

    • delete all @types/ dependencies from package.json
    • delete @types folder from node_modules