[英]How to use a type from another module as a JSDoc return/param type
I'm trying to use JSDoc to document some functions of a bot I'm making: 我正在尝试使用JSDoc来记录我正在制作的机器人的一些功能:
const Discord = require("discord.js");
/**
* Returns and empty embed with the bot's default settings
* @param u - The user that executed the command
* @returns {Discord.RichEmbed}
*/
exports.getDefaultEmbed = function(u) {
let embed = new Discord.RichEmbed();
embed.setColor(0xFA632A);
if (u) embed.setFooter(u.tag, u.displayAvatarURL);
return embed;
};
As you can see, this function returns a RichEmbed object from the discord.js
module, but WebStorm doesn't seem to like that. 正如你所看到的,这个函数返回从一个RichEmbed对象
discord.js
模块,但WebStorm似乎并不喜欢这样。
So, how do I use a type from another module in JSDoc? 那么,我如何使用JSDoc中另一个模块的类型?
Because of WebstormProblem any modules with a .
因为WebstormProblem的任何模块都带有
.
dot/period in it's module name can cause problems. 它的模块名称中的点/句点可能会导致问题。
A workaround that seems to work on my end is, Use ESMA6 and use backquotes to require the module. 似乎在我的最终工作的解决方法是,使用ESMA6并使用反引用来要求模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.