otris/jsdoc-tsd

Support callback-Type

Closed this issue · 1 comments

For JS-Callbacks you have the possibility to describe a callback function with the @callback-annotation. The module generates currently an empty interface for that

Example:

/**
  * Description of my callback
  * @memberof myNamespace
  * @callback myCallback
  * @param {string} param1 Description of param1
  * @returns {string} Description of the return value
  */

/**
  * Description of my function
  * @memberof myNamespace
  * @param {myNamespace.myCallback} callback My callback param
  */
function test(callback) {
    // ...
}

Generated output:

declare namespace myNamespace {
    interface myCallback {
    }

    function test(callback: myCallback): void;
}

Expected output:

declare namespace myNamespace {
    declare type myCallback = (param1: string) => string;

    function test(callback: myCallback): void;
}

implemented with e4fcd8b