【问题标题】:Hide Google Library's warnings隐藏 Google 图书馆的警告
【发布时间】:2012-11-05 16:27:20
【问题描述】:

我在我的项目中使用 Google Closure 和 Google Library,但遇到了警告问题。

我的项目由大约 50 个文件组成,带有一些小的警告(JSDoc 错误)。问题是谷歌图书馆,当我编译我的项目时,大量的警告来自谷歌的图书馆,就像这样:

../Libs/Closure/closure/goog/uri/utils.js:255: WARNING - inconsistent return type
found   : (null|string|undefined)
required: (null|string)
  return uri && decodeURIComponent(uri);
         ^

../Libs/Closure/closure/goog/uri/utils.js:634: WARNING - inconsistent return type
found   : (Array.<(string|undefined)>|undefined)
required: Array.<(string|undefined)>
  return buffer;
         ^

../Libs/Closure/closure/goog/uri/utils.js:671: WARNING - inconsistent return type
found   : (Array.<(string|undefined)>|undefined)
required: Array.<(string|undefined)>
  return buffer;
         ^

../Libs/Closure/third_party/closure/goog/mochikit/async/deferred.js:623: WARNING - assignment to property deferred of goog.async.Deferred.AlreadyCalledError
found   : (goog.async.Deferred|undefined)
required: (goog.async.Deferred|null)
  this.deferred = deferred;
  ^

../Libs/Closure/third_party/closure/goog/mochikit/async/deferred.js:651: WARNING - assignment to property deferred of goog.async.Deferred.CancelledError
found   : (goog.async.Deferred|undefined)
required: (goog.async.Deferred|null)
  this.deferred = deferred;
  ^

我收到了来自 Google 图书馆的 300 多个警告和大约 50 个来自我的项目的警告。那么,如何隐藏 google 的库警告并显示我的项目警告?

我尝试使用稳定的 Google 库和 SVN 存储库中的最后一个来构建我的项目,但我总是收到所有这些警告。

我的编译配置:

../Libs/Closure/closure/bin/build/closurebuilder.py \
--root=../Libs/Closure/ \
--root=../Projects/myProject/ \
--namespace="Project" \
--output_mode=compiled \
--compiler_jar=../Libs/Closure/compiler.jar \
--compiler_flags="--third_party=../Libs/Raphael/raphaeljs_extern.js" \
--compiler_flags="--compilation_level=SIMPLE_OPTIMIZATIONS" \
--compiler_flags="--warning_level=VERBOSE" \
> ../../Projects/js/project_release.js

感谢您的宝贵时间!

【问题讨论】:

    标签: google-closure-compiler google-closure-library


    【解决方案1】:

    要禁止您应该使用的所有警告消息:

    --compiler_flags="--warning_level=QUIET"

    而不是您当前拥有的 verbose 设置。

    您可能还想检查gruntgrunt-closure-tools 插件,该插件使用构建器、编译器和depswritter 等闭包工具自动化。

    【讨论】:

      【解决方案2】:

      您可以在文件概览中使用@suppress 标签。 http://code.google.com/p/closure-compiler/wiki/Warnings#@suppress_Tags

      【讨论】:

        【解决方案3】:

        另一种方法是使用--warnings_whitelist_file。不过,让它按预期工作有点棘手。在此处查看详细信息:Supressing or resolving compiler errors in goog.base

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-07-02
          • 1970-01-01
          • 2016-02-05
          • 2011-09-14
          • 2022-07-20
          • 2012-02-20
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多