Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google closure variable window/event/console/... is undeclared error

I'm trying to compile one of my HTML5 project using Google Closure. I'm recieving several errors that I don't know how to solve. In fact, it's the same error but for different variables.

Here the errors messages:

variable window is undeclared variable event is undeclared variable console is undeclared variable Audio is undeclared

These variables are Javascript built-in variables. If I compile this same project directly in command-line, it works. But, in my case, I need to compile this project using an ant file (build process). My ant build script is using the same jar file that I use in command-line. With the option warnings="verbose", it doesn't work. If I remove it, it works. If I would like to use the option warnings-"verbose", what I have to do? Please explain me the difference.

Could somebody help me please? Thank you!

like image 493
Jeep87c Avatar asked Dec 27 '22 23:12

Jeep87c


1 Answers

The option --warnings=verbose sets the compiler to "ninja mode"; i.e. every single variable in your file should be declared (an annotated!) correctly. For example, the window variable is unknown to the compiler, but Closure has an implementation of window (independent of the platform used). If your variables are included in some other file, use externs. If yo still want to use Verbose mode without the 'undeclared variable' error, use the flag --jscomp_off=checkVars

like image 137
zakelfassi Avatar answered May 02 '23 11:05

zakelfassi