Open timdawborn opened 5 years ago
Laura Hacker on the mailing list has pointed out that extern namespaces should be annotated with /** @const */
instead of /** @type {!Object} */
(as per https://github.com/google/closure-compiler/wiki/A-word-about-the-type-Object#namespaces). This does fix the false positive, so perhaps that incorrect annotation is somehow related to the cause of the false positive.
$ cat externs.js
/** @type {!Object} */
let SomeLibrary;
/** @const */
SomeLibrary.someThing;
SomeLibrary.someThing.update;
$ /usr/local/bin/closure-compiler --externs externs.js --js example.js --jscomp_warning '*'
var MyInterface=function(){},MyClass=function(){};MyClass.prototype.update=function(){};
$ /usr/local/bin/closure-compiler --externs externs.js --js empty.js --jscomp_warning '*'
$
Internal Google issue http://b/128990360 created.
Mailing list link to thread that spawned this bug report: https://groups.google.com/d/topic/closure-compiler-discuss/0JAsjIFc5Rs/discussion
Closure outputs false positive messages
WARNING - property update already defined on interface <name>; use @override to override it
when compiling with an extern that defines an untyped symbol calledupdate
. Changing the name of the symbol fromupdate
to anything else seems to fix the false positive. Adding type annotations to the symbol also seems to fix the false positive.Compiler version latest:
Repro:
This is a false positive as
EventTarget
does not define any symbol calledupdate
.In the above example, either changing
SomeLibrary.someThing.update
to be called anything else (e.g.SomeLibrary.someThing.somethingElse
) or adding a type annotation to it (e.g./** @type {!Object} */
) causes this false positive to go away.These false positive errors continue to seemingly any interface used in code:
The
MyInterface
interface clearly does not define a method calledupdate
.