0

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.

Mistalis
  • 17,793
  • 13
  • 73
  • 97
FirstCape
  • 639
  • 13
  • 30
  • What content do you write in the TS file? I type this TypeScript sample code (https://github.com/Microsoft/TypeScriptSamples/blob/master/greeter/greeter.ts) in a TS fie after installing angularjs and angularjs.TypeScript.DefinitelyTyped packages, everything is fine. Please share the detailed steps to help us reproduce your problem. – Weiwei Dec 14 '16 at 01:35
  • I have updated the question with each step I made. I have tried using different "starting projects" but they all produce the same results. – FirstCape Dec 14 '16 at 06:52
  • After installing above packages and build, I get different errors and I only have five .d.ts files (https://1drv.ms/i/s!AkHKK8SV6besg2XcFCHqXvM3xGcX). All the errors occurs when installing angularjs.TypeScript.DefinitelyTyped package. I'm afraid that there has any problem on this package. If possible, please share a sample project here. – Weiwei Dec 14 '16 at 07:47
  • What's the detailed error message you get when building or compiling? – Eddie Chen - MSFT Dec 20 '16 at 02:43

1 Answers1

1

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
Aniruddha Das
  • 20,520
  • 23
  • 96
  • 132
  • Thanks, I removed the typings folder and it cannot find Angular. I haven't used any NPM at all yet, so I don't have any node_modules. Unfortunately I just had to reinstate the typings folder. – FirstCape Dec 13 '16 at 19:18
  • as you deleted typing.json and types folder, now you are using @types. so make sure to run npm install so that @ types folder will – Aniruddha Das Dec 13 '16 at 20:21