JavaScript - definition hash-tables
Hi !
We use in our JS-based project hash tables, and can't get autocomplete, find usages etc. Example code:
var Class1 = function()
{
this.Method1 = function(a, b){}
}
var c = new Class1();
c.Method1(); // <- Wotk fine !
var hash = {};
hash['some_key'] = c;
hash['some_key'].Me... //<- Nothing
hash['another_key'] = new Class1();
hash['another_key'].Me... //<- Nothing again
Possible (with using some special syntax or JSDoc comments) fix my code for work autocomplete etc ?
Please sign in to leave a comment.
Please, file youtrack issue with example and we will support it
This code is simple:
// -------------------------------------------------------------------------------------------------------------------------------------
var Class1 = function()
{
this.PublicMethod = function()
{
}
}
var Class2 = function()
{
this.PublicMethod2 = function()
{
}
}
function Function1()
{
return new Class1();
}
var object1 = new Class1();
object1.PublicMethod();
var array1 = [object1];
array1[0].PublicMethod(); // IDE don't understand what type of array[0] is Class1 and not show PublicMethod1 in autocomplete dropdown list. If I press Ctrl+Space again - I will see PublicMethod1 but PublicMethod2 also visible.
var associativeArray1 = {};
associativeArray1["someKey"] = new Class1();
associativeArray1["someKey"].PublicMethod(); // same about type - IDS think what associativeArray1["someKey"] just simple object
var object2 = Function1();
object2.PublicMethod1(); // same problem - how mark Function1 as returning Class1 ?
// -------------------------------------------------------------------------------------------------------------------------------------
I don't known how realyze this - maybe JSDoc comments help ?