5

ファイルをコンパイルして、コンパイルされたコードを動作させていますが、注釈は完全に無視されているようです。警告もエラーもありません。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){

一致する変数は配列である必要があり、この関数を呼び出すすべてのコードは配列で呼び出します。型チェックをテストするために、次のように配列を文字列に変更しました。

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

再度コンパイルしましたが、警告やエラーは発生しません。バッチ ファイルでコンパイラにパラメータを追加しようとしました:

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

今、私は警告を受け取ります。私の質問は次のとおりです。すべての種類のチェックをオンにする必要がありますか? すべてのチェックをオンにして、一部のみを明示的にオフにする方法はありますか?

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

オフになるチェックがいくつかあり、必要に応じて明示的に有効にする必要があります。デフォルトですべてを有効にする方法はありません。

警告/エラー タイプの完全なリストについては、https://code.google.com/p/closure-compiler/wiki/Warningsを参照してください。

于 2013-04-24T05:58:07.053 に答える