繁体   English   中英

如何将另一个模块中的类型用作JSDoc返回/ param类型

[英]How to use a type from another module as a JSDoc return/param type

我正在尝试使用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;
};

正如你所看到的,这个函数返回从一个RichEmbed对象discord.js模块,但WebStorm似乎并不喜欢这样。

WebStorm似乎不喜欢这样

那么,我如何使用JSDoc中另一个模块的类型?

因为WebstormProblem的任何模块都带有. 它的模块名称中的点/句点可能会导致问题。

似乎在我的最终工作的解决方法是,使用ESMA6并使用反引用来要求模块。

定期报价

定期报价

有反引号

有背引号

暂无
暂无

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

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