google / google/closure-compiler
Overrided interface properties does not inherit type information
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I have followed code:
``` js
/**
* @interface
*/
var Itf = function(){};
/** @type {boolean} */
Itf.prototype.prop;
/**
* @constructor
* @implements {Itf}
*/
var Cls = function(){}
/** @override */
Cls.prototype.prop;
```
Compiling it with "--compilation_level ADVANCED_OPTIMIZATIONS --jscomp_warning reportUnknownTypes --warning_level VERBOSE" I get a warning:
```
test.js:17: WARNING - could not determine the type of this expression
Cls.prototype.prop;
^
```
If I add `@type {boolean}` to `Cls.prototype.prop` all is fine.
It seems compiler is unable to infer type from `Itf.prototype.prop`.
Initializing overrided property resolves a problem, but in my case it should be uninitialized (it's type actually `{(boolean|undefined)}`).
See discussion: https://groups.google.com/forum/#!topic/closure-compiler-discuss/gdKj25kAWeg
Contributor guide
Assessment
This issue has not been assessed yet.