englercj / tsd-jsdoc

Compiles JSDoc annotated JavaScript into a Typescript Definition file (.d.ts)
MIT License
316 stars 42 forks source link

Better support for typedef @property #135

Closed mramato closed 4 years ago

mramato commented 4 years ago

Given the following JSDoc

/**
 * @typedef {Object} BillboardGraphics.ConstructorOptions
 *
 * Initialization options for the BillboardGraphics constructor
 *
 * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the billboard.
 */

tsd-jsdoc was producing the following TS code

/**
 * Initialization options for the BillboardGraphics constructor
 * @property [show = true] - A boolean Property specifying the visibility of the billboard.
 */
type ConstructorOptions = {
    show?: Property | boolean;
};

@property is not valid TS markup and the actual property, show, does not include its description or default value.

After this change the same JSDoc markup produces much nicer code that handles both of these:

/**
 * Initialization options for the BillboardGraphics constructor
 */
type ConstructorOptions = {
    /**
     * A boolean property specifying the visibility of the billboard.
     * @defaultValue true
     */
    show?: Property | boolean;
};

I updated the tests, to match the new output and manually verified its what I would expect.

mramato commented 4 years ago

Thanks @englercj, I accepted your changes so I think this is ready.

mramato commented 4 years ago

Thanks @englercj! Any idea when tsd-jsdoc will get an updated npm release?

mramato commented 4 years ago

@englercj Are there any plans to do a new release anytime soon? I would like to make use of this PR and I didn't want to fork/publish to a different package just to use it.

I know you are busy and I'm still a complete stranger, but long term I have no problem helping out with maintaining this repository once I earn your trust, since CesiumJS is not dependent on it. Thanks!

englercj commented 4 years ago

There are some bugs and regressions that came up recently. I'm waiting for those to get fixed first.