【问题标题】:How would one go about using JSDoc to document a function inside of a JSON object?如何使用 JSDoc 记录 JSON 对象内的函数?
【发布时间】:2021-08-13 23:32:47
【问题描述】:

我正在尝试在我的代码中为不和谐机器人记录函数参数 messageclient。但我不知道该怎么做。下面是一些大致遵循我的代码的示例代码:

var discord = require("discord.js");

module.exports = {
   name: "exampleCommand",
   aliases: ["example", "example2"],
   execute(message, client){
   message.channel.send("example")
   }
}

我尝试过的一些事情:

/*
 * Execute command
 * @param {discord.Message} message - The message that was sent
 * @param {discord.Client} client - The discord bot client
*/
execute(message, client){
message.channel.send("example")
}
}

我在这里的另一个问题中发现了这一点,但也没有这样做:

/*
 * @param {name:string, aliases:Array, execute(discord.Message, discord.Client)}
*/
{
    name:"exampleCommand",
    aliases:["example", "example2"],
    execute(message, client){
    message.channel.send("example")
    }
}

我假设我的 IDE(Visual Studio 代码)应该自动检测 JSDoc cmets 并给出正确的 IntelliSense 建议,但它只是表明它们的类型仍然是 any。在 JSON 中记录此函数的正确方法是什么?

【问题讨论】:

    标签: javascript jsdoc


    【解决方案1】:

    这比我最初想象的要简单得多。我错误地启动了我的 JSDOC cmets。我用/* 开始它们,而我应该用/** 开始它们。这个小修复使一切按预期工作。

    【讨论】:

      猜你喜欢
      • 2019-04-06
      • 2017-11-05
      • 1970-01-01
      • 2013-05-30
      • 2021-05-04
      • 2017-11-20
      • 2016-06-03
      • 2015-07-12
      • 2012-08-12
      相关资源
      最近更新 更多