typescript & angularjs intellisense issues

Hello all,

I havent been using intellij for very long so im still not familiar with all the functionality and settings.

My question is regarding the intellisence & autocompletion of typescript classes/objects when they are used in in angular templates.

When using a top-level attribute, like

<div ng-controller='BigController as someCtrl'>
     <div>{{someCtrl.someVal}}</div>

It correctly recognices someVal as an attribute of someCtrl. When using 'find-declaration' it also correctly goes to someVal in the corrrect .ts file.

However when going 1 level 'deeper' it doesnt work as expected.

<div ng-controller='BigController as someCtrl'>
     <div>{{someCtrl.someFunc(1).otherVal}}</div>

In this case sometimes otherVal is unresolved according to the editor. Even though otherVal is available in the autocomplete. After a restart intellij it can resolve otherVal. However when using the find declaration (ctrl+b) it points to the js file generated from the ts file and not the original ts file. In ts i added correct typing to variables and functions.

Is this a bug? Is there somewhere i can tell intellij to first look into .ts or to not look into the generated .js files ?

3 comments
Comment actions Permalink

To exclude generated .js files from navigation, please try the following:
- in Settings/Languages & Frameworks/JavaScript/Libraries, press Add to create a new library
- using 'Attach files', add all your generated .js files to the library (you can use Ctrl to select multiple files)
- make sure to disable this library ('Enable' checkbox should be unchecked)

As for resolving/completion issue, can you check if it persists after invalidating caches (File/Invalidate caches, restart)? If it does, can you attach a sample project that shows up the issue?

0
Comment actions Permalink

What i have done now is to generate a single js file from all the typescript files. This js file is generated in a directory which i marked as 'Exclude'. I hope this way the generated js file does not confuse the analyser of intellij.

I still notice the recognition of functions and variables is somewhat flaky. I followed your suggestion and invalidated the cache + restart. This didnt help anything (but in the past i noticed just a restart worked for a while). The strange thing now is the autocomplete does work wel and suggest functions which the editor marks as wrong.

{{($index / 3).floor() * 27}}

In this angularjs-javascript code floor has a red line under it stating : "Unknown function 'floor' less... (Ctrl+F1)"

yet if i press ctrl+space (autocomplete) after

($index / 3).<ctrl+space>

The editor suggests floor (and all other functions like abs() acos() etc) so it does know the function.

The same problem occurs with typescript variables nested two classes deep. It autocompletes the functions correctly but the editor says 'unresolved method or function'

mainCtrl.sub.callSubFunc()

while it autocompletes correctly with callSubFunc()

mainCtrl.sub.<ctrl+space>


So as far as i can see the autocomplete is smarter then the fault recognition (shouldnt they be the same?)... which is kind of weird because intellij marks its own suggestions incorrect.

If this is not enough i can try to make a sample project showing this behaviour. I am still a novice user of intellij though (just got a licence of intellij after being kind of a netbeans fan) so it takes some effort since its pretty different then what i am used to.

0
Comment actions Permalink
If this is not enough i can try to make a sample project showing this behaviour.

yes, please:)

0

Please sign in to leave a comment.