How to document resolved values of JavaScript promises

后端 未结 2 562
栀梦
栀梦 2021-01-02 03:35

Given this code :

function asyncFoo() {
  return new Promise(function (fulfill, reject) {
    doAsyncStuff(function(err, data) {
      if(err) reject(new Er         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 04:11

    I like to specify that it's an async function with @async and specify the fulfilled return with @returns and error with @throws

    /**
     * @async
     * @returns {Bar}
     * @throws {Error}
     */
    function asyncFoo() { ... }
    

提交回复
热议问题