Google Closure Compiler 100%打字 [英] Google Closure Compiler 100% typed

查看:92
本文介绍了Google Closure Compiler 100%打字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让我的应用程序在谷歌闭包编译器方面100%打字?

How can I get my application to be 100% typed in regard to google closure compiler?

我已经使用jsdoc注释标记了所有内容。甚至可以获得100?我是64,6%

I already tagged everything with jsdoc comments. Is it even possible to get 100? I'm at 64,6%

推荐答案

有可能达到100%。我自己的项目是100%打字的。闭包编译器可以输出有关未知类型的表达式的警告。遗憾的是,没有命令行选项来启用此功能。您必须修改源代码才能启用它:

It IS possible to achieve 100%. My own projects are 100% typed. The closure compiler can output warnings about expressions with unknown types. Unfortunately there is no command line option to enable this feature. You have to modify the source code to enable it:


  1. 下载当前来源:

  1. Download the current sources:

git clone https://code.google.com/p/closure-compiler/

编辑src / com / google / javascript / jscomp / CompilerOptions.java并将行 reportUnknownTypes = CheckLevel.OFF 更改为 reportUnknownTypes = CheckLevel.WARNING

Edit src/com/google/javascript/jscomp/CompilerOptions.java and change the line reportUnknownTypes = CheckLevel.OFF to reportUnknownTypes = CheckLevel.WARNING

只需调用 ant 编译闭包编译器在根目录中。修改后的compiler.jar现在位于构建目录中。

Compile the closure-compiler by simply calling ant in the root directory. The modified compiler.jar is now in the build directory.

当您在脚本上使用此修改后的编译器时,它针对编译器无法确定类型的所有表达式吐出大量警告。当您在代码中修复所有这些警告时,它将100%键入。

When you use this modified compiler on your scripts then it spits out lots of warnings about all the expressions for which the compiler couldn't determine the type. When you fix all these warnings in your code then it is 100% typed.

这篇关于Google Closure Compiler 100%打字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆