How to fight tons of unresolved variables warning in WebStorm?
Use JSDoc:
/** * @param {{some_unres_var:string}} data */function getData(data){ console.log(data.some_unres_var);}
JSDoc the object. Then its members.
/** * @param data Information about the object. * @param data.member Information about the object's members. */function getData(data){ console.log(data.member);}
@property
for local variables (non parameters).- Tested in PyCharm. @Nicholi confirms it works in WebStorm.
- The
{{ member:type }}
syntax Andreas suggested may conflict with Django templates. - Thanks to Jonny Buchanan's answer citing the @param wiki.
To document arrays of objects, use []
brackets as JSDoc suggests:
/** * @param data * @param data.array_member[].foo */
All other answers are incorrect for the general case. What if you don't get data
as a parameter? You don't have JSDoc then:
function niceApiCall(parameters) { const result = await ... // HTTP call to the API here for (const e of result.entries) { .. // decorate each entry in the result } return result;}
WebStorm will warn that "result.entries" is an unresolved variable (field).
The general solution is to add an @namespace
declaration:
function niceApiCall(parameters) { /** @namespace result.entries **/ const result = await ... // HTTP call to the API here for (const e of result.entries) { .. // decorate each entry in the result } return result;}