【发布时间】:2018-03-28 09:14:04
【问题描述】:
我正在尝试将输入参数记录到 javascript 中的函数中,但我不知道如何在 jsdoc 中执行此操作。
我查看了 jsdoc 文档,该文档建议使用 @callback 注释是必需的,但 Visual Studio Code (vscode) 并未按照屏幕截图突出显示它。
location 参数的智能感知显示它是 any 类型而不是 locator 类型(参数为 id 的函数返回 Location)。
显示函数调用作为参数传递的函数的示例代码:
class Location {
constructor(position, count) {
this.position = position;
this.count = count;
}
}
const items = {
'USB Cable': new Location('Desk Drawer', 123),
Keyboard: new Location('Desk Surface', 1),
};
/**
* A locater.
* @param {string} id
* @returns {Location}
*/
const locaterA = id => items[id];
/**
* Finds the item by its unique id.
* @callback locater
* @param {string} id
* @returns {Location}
*/
/**
* Attempt to find the item with the given locater.
* @param {string} id
* @param {locater} locater
*/
const locate = (id, locater) => locater(id);
const result = locate('USB Cable', locaterA);
console.log(result);
这是我在做什么的问题,vsdoc不支持用例,还是vscode不支持?
【问题讨论】:
标签: javascript node.js visual-studio-code jsdoc