How to fight tons of unresolved variables warning in WebStorm?

前端 未结 6 1822
陌清茗
陌清茗 2020-12-04 09:19

I have a function that takes data from server:

function getData(data){
    console.log(data.someVar);
}

WebStorm says that someVar

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 09:59

    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
     */
    

提交回复
热议问题