documentationjs / documentationjs/documentation
Overloaded getter/setter in ES6 class produces wrong output
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 481
- PR merge metrics
- No merged PRs in 30d
Description
The [recipes doc](https://github.com/documentationjs/documentation/blob/master/docs/RECIPES.md#overloaded-methods) 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
Contributor guide
Assessment
This issue has not been assessed yet.