如果目前没有其他答案,我会选择在 JavaScript 文件顶部定义 JSON
作为一种类型,像这样:
/**
* Define JSON
* @typedef {string} JSON
*/
然后,在我的函数定义中使用JSON
类型。
请参阅下面以@param
开头的行:
/**
* Compresses JSON data
* @function compressJSON
* @param {JSON} myJSON - any valid JSON
* @returns {string} a compressed version of the JSON input
*/
更多阅读:
@typedef {string} JSON
然后使用@param {JSON}
?(参见:https://jsdoc.app/tags-typedef.html) - Rounin