如何使用jsdoc在webstorm中记录类型? [英] How can I document a type in webstorm using just jsdoc?
本文介绍了如何使用jsdoc在webstorm中记录类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我编写以下代码时,注释器告诉我 BrowserSelector
未在第二个typedef中定义:
When I write the following code, the annotator tells me that BrowserSelector
is not defined in the second typedef:
/**
* @typedef {{name: String, minVer: Number, maxVer: Number}} BrowserSelector
*/
/**
* @typedef {{type:String, browser: BrowserSelector, attribute: Object}} Selector
*/
我认为它没有将类型与名称相关联。我怎样才能做到这一点?
I believe it is not associating the type with the name. How can I do that?
我不想为它添加实际代码,只需添加jsdoc评论。
I would prefer not to add actual code for it, just jsdoc comments.
推荐答案
我正在使用这种评论风格为'struct'类型:
I'm using this comment style for 'struct' like types:
/**
* @name BrowserSelector
* @property {String} name
* @property {Number} minVer
* @property {Number} maxVer
*/
/** @type {BrowserSelector|*} */
var mySelector = {}; // no warning because of '*' in @type :S
mySelector.name = 'foo'; // no warning :)
mySelector.id = 'bar'; // warning :)
这篇关于如何使用jsdoc在webstorm中记录类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文