【发布时间】:2013-04-17 13:14:10
【问题描述】:
我正在编译文件并获得工作编译代码,但注释似乎完全被忽略了;没有警告没有错误。使用 calcdeps.py 通过以下命令编译我的代码:
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
例如在 Messenger.js 我有一个函数:
/**
* 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){
变量matches必须是一个数组,所有调用这个函数的代码都用一个数组调用它。为了测试类型检查,我将数组更改为字符串,如下所示:
* @param {string} matches contains the items of myApp.data that matched words in text
再次编译但没有给出警告或错误。尝试在批处理文件中向编译器添加参数:
--compiler_flags="--jscomp_warning=checkTypes" ^
现在我收到警告。我的问题是:我必须打开各种检查吗?有没有办法让所有检查都打开而我只明确关闭一些?
【问题讨论】:
标签: javascript google-closure-compiler strong-typing