google / google/closure-compiler

Overloading parent method

Open
#393 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Why i can't do something like this:

``` js
/** @constructor */
function Foo() {}

/**
* @param {string} a
* @return {string}
*/
Foo.prototype.get = function (a) { return ''; }

/**
* @constructor
* @extends {Foo}
*/
function Foo2() {}

/**
* @override
* @param {number} b
*/
Foo2.prototype.get = function (a, b) { return ''; }
```

---

Warning: JSC_HIDDEN_SUPERCLASS_PROPERTY_MISMATCH: mismatch of the get property type and the type of the property it overrides from superclass Foo.

---

I think it's strange behavior. Also, i can't override parent parameters.

``` js
/** @constructor */
function Foo() {}

/**
* @param {string} a
* @return {string}
*/
Foo.prototype.get = function (a) { return ''; }

/**
* @constructor
* @extends {Foo}
*/
function Foo2() {}

/**
* @override
* @param {number} a
*/
Foo2.prototype.get = function (a) { return ''; }
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.