28

I have setup Webstorm to recognise and compile my coffeescript files.

I have installed the AngularJS plugin and can successfully write my controllers etc in plain old javascript.

When I try to write my angular related code in CoffeeScript however I do not get any IDE support: code-completion, intellisense etc.

As a sign that all is not well, the angular variable itself is not recognised, as shown in the image below.

enter image description here

Question: How do I enable support for AngularJS in CoffeeScript files?

Thanks

biofractal
  • 18,963
  • 12
  • 70
  • 116

3 Answers3

48

To fix the specific problem Unresolved variable or type angular you need to make sure the angular javascript libraries have been Enabled (see image below).

You do this via the WebStorm settings:

File -> Settings -> Javascript -> Libraries

Managing Javascript Libraries

Here is the relevant help section: Configuring JavaScript Libraries

biofractal
  • 18,963
  • 12
  • 70
  • 116
  • This is a good post, because regarding to Webstorm, http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/, this is activated when the library is loaded. Wich is NOT true. – petur Nov 05 '14 at 11:32
  • For me, this isn't the solution. It does solve the `Unresolved variable or type angular` notification, but I never had issues because of this. My problem lies within the testing of using this `.coffee` file, it still fails on `ReferenceError: angular is not defined` – Mathieu Brouwers Jan 19 '16 at 12:37
13

With webstorm 10 you are going to go to the preferences window and from there select Languages & Frameworks > JavaScript > Libraries. Then click the download button, select TypeScript community stubs from the dropdown at the top of the list, find angular and click download and install.

If you are using jshint be sure to go to the jshint settings find the Predefined option and add angular:true to suppress warnings.

Blake
  • 151
  • 1
  • 4
  • 3
    Thanks for the WS10.0 instructions! A minor clarification is that there are >10 angular items available for download and none are named "angular". downloading "angularjs" worked for me. – Bill Tarbell Apr 30 '15 at 21:45
  • The problem with TypeScript community stubs is that there have no JSDocs so if I cmd+click a function to go to its definition I have no documentation about how to use it – Guy Sep 29 '15 at 01:05
  • Is it possible to automatically use every library that is available in bower and/or npm? – Jelle den Burger Jul 28 '17 at 13:01
3

In WebStorm v.11

  • go to "Settings" -> "Plugins" -> "Browse repositories".
  • Search and install "Angular Templates".
  • Profit

    Settings screenshot

Valery
  • 31
  • 1