-
Notifications
You must be signed in to change notification settings - Fork 1.2k
@suppress annotations
Aaron Fellin edited this page Jul 19, 2018
·
41 revisions
If you cannot easily fix a JsCompiler warning, you can suppress it using the @suppress
annotation in the function's JSDoc block or the @fileoverview
block or any assignment in statement position.
/**
* ...
* Good; suppresses within the entire function.
* Also, this suppresses multiple warnings.
* @suppress {visibility|underscore}
*/
function blah() {
/** @suppress {visibility} */ // Good; suppresses within this declaration only.
otherClass.privateField_ = blah;
/** @suppress {checkTypes} */ // Bad; doesn't work.
foo(incompatible.type);
/** @suppress {missingRequire} */ // Good; this is an exception (see below).
foo(blah.not.required);
}
Some specific @suppress
annotations are allowed elsewhere:
-
@suppress {extraRequire}
is valid just before agoog.require(...);
statement. -
@suppress {switch}
is valid on a switch statement. -
@suppress {missingRequire}
is valid on any statement.
All other annotations can only be suppressed for a function, file, or declaration. You cannot suppress most warnings for a single line within a function.
The full list of suppressions accepted by the parser can be found in the jsdoc.suppressions
list here.
The specific warnings included in each suppression can be found here (note that not all groups are recognized as suppressions)