问题描述:

The manual says I can use:

 --warnings_whitelist_file VAL : A file containing warnings to

suppress. Each line should be of the

form

<file-name>:<line-number>? <warning-d

escription>

This is what my whitelist looks like:

ef-utils.js:1 Redeclared variable: ef

ef-utils.js:1 Variable ef first declared in externs-ko.js

ef-validation.js:1 Redeclared variable: ef

ef-validation.js:1 Variable ef first declared in externs-ko.js

And I am still getting warnings while compiling:

ef-utils.js:1: WARNING - Redeclared variable: ef

?var ef = (function (ns, ko) {

^

ef-utils.js:1: WARNING - Variable ef first declared in externs-ko.js

?var ef = (function (ns, ko) {

^

ef-validation.js:1: WARNING - Redeclared variable: ef

?var ef = (function (ns, ko) {

^

ef-validation.js:1: WARNING - Variable ef first declared in externs-ko.js

?var ef = (function (ns, ko) {

^

网友答案:

I just toyed around with the current WhitelistWarningsGuard. I found out that

  • Line numbers are completely ignored: they are stripped both from the input file and the encountered warnings.
  • File names are formatted as they are for output, i.e. as they occur on the command line.
  • There is a colon after the file name, followed by two spaces, followed by the message text without indicator of the severity (WARNING, ERROR).
  • The main effect of the whitelist appears to be turning errors into warnings. So when applied to warnings, there will be no effect at all.
  • The WhitelistBuilder mentioned by Tibos is there in the code, but I see no way to use it from the command line.

As it is, that feature appears to be mostly useless for my use cases…

网友答案:

You should use the WhitelistBuilder to build the whitelist file. From the looks of it, you need absolute paths to the files, not relative.

网友答案:

As MvG correctly stated as this flag is implemented it's useless. Though, with pretty light changes to the compiler's code it can be turned to what we all expect from it: suppressing errors and warnings we don't want to see.

See details here: Suppressing or resolving compiler errors in goog.base

相关阅读:
Top