Skip to content Skip to sidebar Skip to footer

Suppressing Or Resolving Compiler Errors In Goog.base

I use Closure Compiler on my sources and recently decided to enable the most strict mode via --jscomp_warning=reportUnknownTypes. Alas, it triggered a lot of warnings inside the go

Solution 1:

So, I decided to go the path with silencing warnings in the base.js. For that I've investigated compiler sources (thanks to the authors it's open source) and I found out that flag description doesn't match its actual effect. The description says:

A file containing warnings to suppress. Each line should be of the form <file-name>:<line-number>? <warning-description>

But in fact this guard intercepts matching errors and converts them into warnings. Moreover, line numbers are completely ignored. I see no use of this flag with such behavior but I bet authors had a good reason to implement it this way.

Anyways, I forked from the main branch and fixed flag's behavior. Now matched errors and warnings are actually suppressed (silenced). Line numbers are now considered in the matching.

Syntax of the whitelist file is very similar to the error/warning output. For example if you get error (or warning) like this:

..\js\google\base.js:120: ERROR - could not determine the type of this expression if (goog.getObjectByName(namespace)) { ^

Then the relevant record in the whitelist file will be:

..\js\google\base.js:120 could not determine the type of this expression

You may add content of multiline errors as comments preceding them with # but only first line will be used for matching.

If this is what you need you may obtain the binary via one of the two ways:

Post a Comment for "Suppressing Or Resolving Compiler Errors In Goog.base"