In JetBrains WebStorm 6, NodeJS/Javascript how can you define, in the comments a JSON example?

Tag: node.js , webstorm Author: ys2004888_ Date: 2013-04-01

I have a function with a json parameter that comes with the same structure each time.

/**
 * @param box {object}
*/
function testBox( box )

I am looking for a way to instruct the autocomplete of a structure I insert in that input parameter aside for the fact that it is an {object}. I am looking to avoid typos in coding the function.

I have noticed if I add a structured json to a var, later in the function the IDE hints of the structure, but in the case of a function parameter, I don't do such a thing.

How might one do this?

Best Answer

please, see the following thread: https://groups.google.com/forum/?fromgroups#!topic/jsdoc-users/vR5REZ1I8Jc - the recommended way of documenting this is using @typedef WebStorm does support JSDoc @typedef annotation. In case oif any problems with resolving/typehinting, please, feel free to file a bug to http://youtrack.jetbrains.com/issues/WEB

comments:

related question, autocomplete gives me a thousand suggestions from many locations. Your suggestion does appear to work but those suggestions are drowned in the list of many things.
please, try unchecking Settings/javascript/Weaker type guess for completion. Reducing the libraries scope (assign them only to those files that use them instead of enabling them for the whole project) may also help to reduce the number of suggestions