在TypeScript中使用JSDoc记录回调参数

时间:2018-07-26 13:07:51

标签: typescript jsdoc

我想用JSDoc文档注释对回调函数的参数进行注释。我该怎么办?

/** Get something.
 * @param options What to get
 * @param callback A function to invoke when the value has been fetched.
 */
get(options: GetOptions, callback: (details: GetDetails) => void): void;

如果这是JavaScript,我会这样做:

/** The callback for the get method.
 * @callback GetCallbackFunction
 * @param {GetDetails} details The details and the value that was fetched.
 */

/** Get something.
 * @param {GetOptions} options What to get
 * @param {GetCallbackFunction} callback A function to invoke when the value has been fetched.
 */
function get(options, callback);

0 个答案:

没有答案
相关问题