san*_*hez 5 javascript google-closure-compiler google-closure-templates
java -jar SoyToJsSrcCompiler.jar --shouldGenerateJsdoc --outputPathFormat
simple.js --srcs simple.soy
Run Code Online (Sandbox Code Playgroud)
SoyToJsSrcCompiler生成一个如下所示的js文件:
if (typeof templates == 'undefined') { var templates = {}; }
if (typeof templates.simple == 'undefined') { templates.simple = {}; }
/**
* @param {Object.<string, *>=} opt_data
* @param {(null|undefined)=} opt_ignored
* @return {string}
* @notypecheck
*/
templates.simple.tinyButton = function(opt_data, opt_ignored) {
.....
};
Run Code Online (Sandbox Code Playgroud)
我正在使用Closure Compiler with --warning_level=VERBOSE和 --compilation_level ADVANCED_OPTIMIZATIONS
我收到这个警告:
simple.js:1: WARNING - Variable referenced before declaration: templates
if (typeof templates == 'undefined') { var templates = {}; }
Run Code Online (Sandbox Code Playgroud)
我该如何清除此警告?
一种解决方法是在外部文件中声明变量:
/** @suppress {duplicate} */
var template;
Run Code Online (Sandbox Code Playgroud)
但是应该修复Soy编译器.我希望人们不会看到这个,因为你通常将它与Closure Library一起使用,并且在那种模式下,Soy编译器应该生成:
goog.provide('template.simple')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
565 次 |
| 最近记录: |