技术控

    今日:69| 主题:49211
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Tsickle - TypeScript to Closure Annotator

[复制链接]
你们是我最耀眼的星盟 发表于 2016-10-2 07:51:52
85 2

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Tsickle - TypeScript to Closure Annotator      

  Tsickle processes TypeScript and addsClosure Compiler-compatible JSDoc annotations. This allows using TypeScript to transpile your sources, and then Closure Compiler to bundle and optimize them, while taking advantage of type information in Closure Compiler.  
  Installation

  
       
  • Execute      npm ito install the dependencies.  
  Usage

  Project Setup

  Tsickle works by wrapping    tsc. To use it, you must set up your project such that it builds correctly when you run    tscfrom the command line, by configuring the settings in    tsconfig.json.  
  If you have complicated tsc command lines and flags in a build file (like a gulpfile etc.) Tsickle won't know about it. Another reason it's nice to put everything in    tsconfig.jsonis so your editor inherits all these settings as well.  
  Invocation

  Run    tsickle --helpfor the full syntax, but basically you provide any tsickle specific options and use it as a TypeScript compiler.  
  Differences from TypeScript

  Closure and TypeScript are not identical. Tsickle hides most of the differences, but users must still be aware of some differences.
      declare  
  Any declaration in a    .d.tsfile, as well as any declaration tagged with    declare ..., is intepreted by Tsickle as a name that should be preserved through Closure compilation (i.e. not renamed into something shorter). Use it any time the specific string names of your fields are significant. That would most often happen when the object either coming from outside your program, or being passed out of the program.  
  Example:
  1. declare interface JSONResult {
  2.     username: string;
  3. }
  4. let r = JSON.parse(input) as JSONResult;
  5. console.log(r.username);
复制代码
By adding    declareto the interface (or if it were in a    .d.tsfile), Tsickle will inform Closure that it must use exactly the field name    .username(and not e.g.    .a) in the output JS. This matters for this example because the input JSON probably uses the string    'username'and not whatever name Closure would invent for it. (Note:    declareon an interface has no additional meaning in pure TypeScript.)  
  Development

  Gulp tasks

  
       
  •       gulp watchexecutes the unit tests in watch mode (use      gulp test.unitfor a single run),   
  •       gulp test.e2eexecutes the e2e tests,   
  •       gulp test.check-formatchecks the source code formatting using      clang-format,   
  •       gulp testruns unit tests, e2e tests and checks the source code formatting.  
  Export the environment variable    UPDATE_GOLDENS=1to have the test suite rewrite the golden files when you run it.
友荐云推荐




上一篇:史上最清晰的红黑树讲解(上)
下一篇:The Berkeley Document Summarizer: Learning-Based, Single-Document Summarization
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

天巧 发表于 2016-10-6 01:39:59
我承认我是因为标题才进来的
回复 支持 反对

使用道具 举报

念文 发表于 2016-10-6 02:22:52
前排,哇咔咔
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表