简体   繁体   English

正确的方法将JSDoc与匿名对象和该对象的功能一起使用

[英]Correct way to use JSDoc with anonymous object and functions of this object

Currently using Webstorm in a project with Dojo (1.10), and ESRI API Javascript. 当前在具有Dojo(1.10)和ESRI API Javascript的项目中使用Webstorm。

I have a function that accept a Widget (Object/Class), but the Webstorm show me some warnings because of JSDoc. 我有一个接受小部件(对象/类)的函数,但是由于JSDoc,Webstorm向我显示了一些警告。

Code: 码:

/**
 * Init toolbar
 *
 * @param {Object} [options] - Toolbar options
 * @param {string} [options.title=Default title] - Main title
 * @param {ToolbarWidget} toolbarObj - Toolbar widget to set
 */
initToolbar: function(options, toolbarObj) {
  ...
  toolbarObj.set('title', _title);
}

The first warning was on ' toolbarObj '. 第一个警告在“ toolbarObj ”上。 I get a message ' Unresolved variable or type '. 我收到消息“无法解析的变量或类型 ”。

This was easy to resolve. 这很容易解决。 Just included the following JSDoc: 仅包含以下JSDoc:

/**
 * A dojo widget (toolbar).
 * @typedef {Object} ToolbarWidget
 */

Now, the another warning was the ' set ' function of toolbarObj. 现在,另一个警告是toolbarObj的“ 设置 ”功能。 I get a warning with the following message: ' unresolved function or method set() '. 我收到以下消息警告:' 未解决的函数或方法set() '。

Already tried @name, @function (maybe not in the correct way)! 已经尝试了@name,@function(可能不是正确的方式)!

I known this is optional (is just a warning), but, I like to document everything in the right way. 我知道这是可选的(只是警告),但是,我想以正确的方式记录所有内容。 So, how I can document the 'set' function of a anonymous object/dojo widget?! 那么,如何记录匿名对象/ dojo小部件的“设置”功能?

What about 关于什么

/**
 * A dojo widget (toolbar).
 * @typedef  {Object} ToolbarWidget
 * @property {function} set 
 */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM