可以通过
@suppress
annotation使用Google的Closure Compiler来抑制每个文件的警告.但是,似乎不可能同时抑制多个警告 – 例如globalThis和checkVars警告.我试过了两个
- /**
- * @fileoverview
- * @suppress {globalThis checkVars}
- */
和
- /**
- * @fileoverview
- * @suppress {globalThis,checkVars}
- */
但两者都会导致@suppress注释被忽略.多个@suppress行也不起作用.
解决方法
使用管道字符分隔类型(例如:’|’).
- /**
- * @fileoverview
- * @suppress {globalThis|checkVars}
- */