I'm using the closure compiler and I have two classes that I would like to assert have a minimum set of methods/properties. To accomplish this, I've created an interface ... e.g.:
goog.scope(function() {
/**
* @interface
*/
namespace.Foo = function() {};
var Foo = namespace.Foo
/**
* @return {string}
*/
Foo.prototype.bar = function() {};
}); // goog.scope
The problem is that Foo.prototype.bar
doesn't have a return
statement, so the closure linter complains even though closure itself is completely happy.
Line 38, E:0218: Found @return JsDoc on function that returns nothing
Line 56, E:0218: Found @return JsDoc on function that returns nothing
Of course, if I remove the @return
annotations then closure is unhappy and throws warnings about overriding a method and returning something incompatible with the interface. I don't want to disable this warning because that's pretty much the reason why I wrote the interface in the first place (to make sure that all of the implementors are doing what they need to do).
Is there any magical incantation that I can use to disable that warning in the closure linter just in this file?
Try the following:
/**
* @return {string}
*/
namespace.Foo.prototype.bar;
Interfaces don't need any function body at all. I suspect they are only visible to the compiler and don't even wind up in your code at all.
Or, because you are using goog.scope
you can write:
/**
* @return {string}
*/
Foo.prototype.bar;