Javascript autocompletion on identically named vars in different scopes

I have multiple different Javascript modules, each with a local variable called "mod" representing the modules instance. The modules have different methods and properties and reside in different files.

When typing "mod." in one of the module methods the autocompletion of IntelliJ shows a list of all members of all modules.

In my opinion IntelliJ should be smart enough to recognice the variable as a local one and not display autocompletion items from locals in other scopes just having the same name.

Example: http://temp.codeworx.ch/global-autocompletion.png
(not the real module structure, example is created to show the basic problem)

Is this a bug or could it be a feature that I don't understand?
Is there a way to work around it - maybe marking it as local via a documentary comment (already tried different jsDoc definitions)?

I'm using IntelliJ 2016.2

Please sign in to leave a comment.