otris / jsdoc-tsd

JSDoc template for generating TypeScript definition files based on JSDoc comments.
MIT License
29 stars 7 forks source link

transform object key and property description #25

Closed wehrstedt closed 6 years ago

wehrstedt commented 6 years ago

In JSDoc, you have the possibility to describe an object param as follow:

/**
 * @typedef {object} myCustomType
 * @property {string} myProp
 */

/**
 * @param {Object<string, myCustomType>} myParam Description
 */
  function test(myParam) {
  }

With this syntax, you define that the param myParam has some string properties with which value can only be of type myCustomType.

The typescript equivalent would be

function test(myParam: { [key: string]: myCustomType }): void;
wehrstedt commented 6 years ago

The current generated output looks like this:

declare interface myCustomType {
    myProp: string;
}

/**
 * 
 * @param myParam Description
 */
declare function test(myParam: Object.<string, myCustomType>): void

Thats not a vailid syntax