@async

.. @async::
语法

@async

概述

The @async tag indicates that a function is asynchronous, meaning that it was declared using the syntax async function foo() {}. Do not use this tag for other types of asynchronous functions, such as functions that provide a callback. This tag is available in JSDoc 3.5.0 and later.

通常, 您不需要使用此标记, 因为JSDoc会自动检测异步函数并在生成的文档中标识它们. 但是, 如果要为代码中未出现的异步函数编写虚拟注释, 则可以使用此标记告诉JSDoc该函数是异步的.

示例

The following example shows a virtual comment that uses the @async tag:

Virtual comment with @async tag
/**
 * Download data from the specified URL.
 *
 * @async
 * @function downloadData
 * @param {string} url - The URL to download from.
 * @return {Promise<string>} The data from the URL.
 */