Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type checking with closure compiler not implicitly on?

I am compiling files and get working compiled code but the annotations seem to be completely ignored; no warnings no errors. Using calcdeps.py to compile my code with the following command:

set calc="D:\software\closure compiler\library\closure\bin\calcdeps.py"
c:\Python27\python.exe %calc% ^
--path D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\ ^
--input D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\mmt\Mediator.js ^
--input D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\mmt\DomDependent.js ^
--input D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\mmt\WorkFlow.js ^
--input D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\mmt\Messenger.js ^
--input D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\mmt\data.js ^
--compiler_jar "D:\software\closure compiler\compiler.jar" ^
--output_mode compiled ^
--compiler_flags="--compilation_level=ADVANCED_OPTIMIZATIONS" ^
--compiler_flags="--formatting=PRETTY_PRINT" ^
--output_file D:\flex_sdk_4.6\projects\EnglishConverter\bin\js\main.js
pause

For example in Messenger.js I have a function:

/**
 * Replaces words in matches with a yes/no/all box
 * @param {Array} matches contains the items of myApp.data that matched words in text
 * @param {string} text contains the cleaned up user input (no html)
 */
myApp.Messenger.builtReplacewithOptions=function(matches,text){

The variable matches has to be an Array and all code calling this function call it with an Array. To test type checking I changed the Array to string like so:

 * @param {string} matches contains the items of myApp.data that matched words in text

Compiled again but no warning or error is given. tried to add a parameter to the compiler in the batch file:

--compiler_flags="--jscomp_warning=checkTypes" ^

Now I get warnings. My question is: do I have to turn on all kinds of checking? Is there a way that all checks are on and I only explicitly turn off some?

like image 802
HMR Avatar asked Apr 24 '13 05:04

HMR


1 Answers

You can set the flag --warning_level=VERBOSE, which is equivalent to

--jscomp_warning=checkTypes --jscomp_error=checkVars \
--jscomp_warning=deprecated --jscomp_error=duplicate \
--jscomp_warning=globalThis --jscomp_warning=missingProperties \
--jscomp_warning=undefinedNames --jscomp_error=undefinedVars

There are still some checks which will be off and which you have to enable explicitly if you want them. There is no way afaik to enable all by default.

For a complete list of warning/error types, see https://code.google.com/p/closure-compiler/wiki/Warnings.

like image 136
Felix Kling Avatar answered Sep 18 '22 16:09

Felix Kling