5

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?

4

1 回答 1

7

您可以设置标志--warning_level=VERBOSE,相当于

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

还有一些检查将被关闭,如果需要,您必须明确启用它们。默认情况下,afaik 无法启用所有功能。

有关警告/错误类型的完整列表,请参阅https://code.google.com/p/closure-compiler/wiki/Warnings

于 2013-04-24T05:58:07.053 回答