JavaScript 中重写构造函数的签名不匹配警告

问题描述 投票:0回答:0

我正在尝试重写父类的构造函数。 然而 PHPstorm 给了我一个警告,因为构造函数重写不兼容,因为签名不匹配。 为什么它首先给我一个警告? JavaScript 是否不允许重写具有不同签名的构造函数?

它似乎运行良好,控制台中没有显示任何错误。

class DDDSelector {
    /**
     * @typedef {NodeList} DDDSelector_elements - array of elements this selector is selecting
     */

    /**
     * @param {string|null} [tag] - html element tag name
     * @constructor
     */
    constructor(tag = null) {
        if (tag) {
            this.DDDSelector_elements = [document.createElement(tag)];
        }
    }
}

class PageDots extends DDDSelector {
    /**
     * @typedef {DDDSelector} holder - the wrapper element for the dots.
     * @typedef {Array.<DDDSelector>} dots - an array of dots
     * @typedef {DDDSelector} selectedDot
     */

    /**
     * Creates all dots for one slideshow.
     * @param {number} count - the number of dots to create
     * @param {Flickity} slideshow - the slideshow
     * @constructor
     */
    constructor(count, slideshow) {
        super('div');
    }

}

javascript phpstorm webstorm
© www.soinside.com 2019 - 2024. All rights reserved.