3

I wonder.. what exactly I should do to make WebStrom (or IntelliJ IDEA) resolve my 'angular' variable.

I follows this guy but that maybe deprecated already.

On my vendor.d.ts:

/// <reference path="../typings/jquery/jquery.d.ts" />
/// <reference path="../typings/angularjs/angular.d.ts" />

My package json:

{
  "name": "angular_ts",
  "version": "0.1.0",
  "description": "",
  "repository": {},
  "dependencies": {
    "grunt": "~0.4.5",
    "grunt-ts": "~3.0.0"
  }
}

My issue on that screenshot ('angular' is not resolved.. can not go to definition of it, as a result - multiple implementations of 'module'): angular is not resolved, having multiple implementations

So, what exactly I should do to make 'angular' resolved in .ts file in WebStorm?

UPDATE: I do not have yet angularjs sources in my project. But one of the options where it redirects me is "node_modules/grunt-ts/tasks/inerfaces.d.ts" file. Even if I exclude 'node_modules' folder from my project.

ses
  • 13,174
  • 31
  • 123
  • 226

2 Answers2

4

You have to do a few things to get this to work correctly. I don't know what that tutorial told you to do, but it's not the WebStorm usual way of doing it.

Firstly, you need to make WebStorm ignore all the AngularJS source files in your project. This is why you're getting the multiple implementations warning.

  • Open your "project" side panel that displays the file tree.
  • Find where you put your angular.min.js source files, and right click the file.
  • Select "Mark as Plain Text". WebStorm will now ignore that file from intellisense for JavaScript.

You have to now add AngularJS to your list of External Libraries for that project.

  • Click "File / Settings"
  • Expand the "Languages & Frameworks" node
  • Expand the "JavaScript" node
  • Select the "Libraries" section.

This is where you install third-party TS files for libraries. Select the "angularjs-DefinitelyTyped" library, but this doesn't come with WebStorm. You have to download and install it.

  • Click the "Download..." button.
  • Change the dropdown on the dialog from "Official libraries" to "TypeScrypt community stubs".
  • Find "angularjs", select it and click "Download and Install".

That's basically what I do. The key is to exclude the JS files in your project that will interfere with intellisense.

When you install external libraries to a WebStorm project via the settings. It doesn't actually add those files to the project. They are only added to the intellisense space used by the IDE.

Reactgular
  • 52,335
  • 19
  • 158
  • 208
  • yep..in my case i should ignore "node_modules" folder I guess. But when I do so - it still sees them in that folder. I do not have yet AngularJS source (except *.d.ts-files) – ses Mar 02 '15 at 21:09
  • @ses you can exclude the entire folder. Right click and select "Mark directory as..." – Reactgular Mar 02 '15 at 21:09
  • 1
    Ok, I can confirm intellij support. Not stoked that you have to include manual .d.ts reference though – danwild Oct 13 '15 at 22:26
0

Ok.

Since I did not have yet angularjs sources (yet) in my project. And one of the options where it redirects me is "node_modules/grunt-ts/tasks/inerfaces.d.ts" file. Even if I exclude 'node_modules' folder from my project.

My solution is to remove node_modules from the Project Structure -> Libraries there was reference to 'node_modules' (also)..

But it is basically the same principle as Mathew suggested.

(Hope that will not break another stuff in the project)

ses
  • 13,174
  • 31
  • 123
  • 226
  • By default WebStorm will ignore everything in node_modules. If it's not doing this, then it doesn't see your project as a NodeJS project. So I would start over. Delete your `.idea` folder and delete your `node_modules` folder, and create a new project. Select "Node Express App" as the project type and select your old source code folder as the project folder. After the project is created. Right click on `package.json` and select "npm install" from the menu to rebuild your `node_modules` folder. Hopefully this will fix your WebStorm setup. Good luck! – Reactgular Mar 03 '15 at 01:23