Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Overloaded getter/setter in ES6 class produces wrong output #557

Open
@bchociej

Description

@bchociej

The recipes doc illustrates how to document a method that is an overloaded getter/setter depending on parameters. But the following code produces what I believe to be wrong output:

class RTLSDR extends EventEmitter {
    // ...

    /**
     * Get the device's crystal frequencies.
     * @return {XtalFreqs} - current crystal frequencies
     * @throws {Error} the device is closed
     */
    /**
     * Set the device's crystal frequency(ies).
     * @param {number} rtlFreq - the crystal frequency to set on the RTL device
     * @param {number} [tunerFreq=rtlFreq] - the crystal frequency to set on the tuner, if different
     * @return {this}
     * @throws {Error} the device is closed
     */
    xtalFreq(rtlFreq, tunerFreq) {
        this.assertOpen();

        if (rtlFreq) {
            librtlsdr.set_xtal_freq(this.device, rtlFreq, tunerFreq || rtlFreq);
            return this;
        }

        return librtlsdr.get_xtal_freq(this.device);
    }

    // ...
} // end of class

This produces two signatures in the HTML output (which is correct) but the "get" signature is not what I want:

Get the device's crystal frequency(ies).
xtalFreq(rtlFreq: any, tunerFreq: any): XtalFreqs

Set the device's crystal frequency(ies).
xtalFreq(rtlFreq: number, tunerFreq: [number]): this

I believe the "get" output should be:

Get the device's crystal frequency(ies).
xtalFreq(): XtalFreqs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions