【发布时间】:2014-01-10 23:11:11
【问题描述】:
java -jar SoyToJsSrcCompiler.jar --shouldGenerateJsdoc --outputPathFormat
simple.js --srcs simple.soy
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) {
.....
};
我正在使用带有--warning_level=VERBOSE 和--compilation_level ADVANCED_OPTIMIZATIONS 的闭包编译器
我收到了这个警告:
simple.js:1: WARNING - Variable referenced before declaration: templates
if (typeof templates == 'undefined') { var templates = {}; }
如何清除此警告?
【问题讨论】:
-
试试:
var templates=templates||{};templates.simple=templates.simple||{}; -
@elclanrs 此代码由 SoyToJsSrcCompiler 生成。每次模板更改时,我都必须对其进行编辑
标签: javascript google-closure-compiler google-closure-templates