There are various tools that allow CoffeeScript to use the Google Closure Tools . I will describe three of them:
Bolinfest CoffeeScript fork
Features:
- Fixed function bindings, loops, alerts, in operator, and various other incompatibilities
- Fixed Class Syntax for Google Closure
- Automatic generation of
@constructor and @extends - Automatically inserts a
goog.provide for each declared class - Python support
include namespace as alias translated to goog.require and goog.scope
Disadvantages:
- The constructor must be the very first in the class
- You cannot use short aliases for classes inside a class (i.e. the class
My.Long.Named.Car cannot be designated as Car in the class definition, as permitted by pure CoffeeScript) - JsDoc custom comments are not combined with compiler generated ones
- Missing
provide equivalent for include - There is no support for type casting, this can only be done by inserting clean javascript code inside the backticks "` "
- Based on Legacy CoffeeScript 1.0
Read more at http://bolinfest.com/coffee/
My CoffeeScript Fork
Disclaimer: I am the author of this solution
This solution is inspired by the work of Bolinfest and extends it in the following ways:
- The constructor can be placed anywhere inside the class
- Short aliases for classes work using
goog.scope - JsDoc custom comments are merged with the compiler, custom
@constructor and @extends are replaced with generated ones - Each namespace is provided or included mostly once, and the namespace that is provided is never included. You can provide a namespace with the
provide keyword - Type casting support using
cast<typeToCastTo>(valueToBeCast) - Based on CoffeeScript 1.6
Read more at https://github.com/hleumas/coffee-script/wiki
Steida coffee2closure
Unlike the two solutions above, Steida Coffee2Closure is a post-processor javascript code created by uncaught CoffeeScript. This approach has one important advantage: it does not need any or only minor updates with the continued development of CoffeeScript and is still relevant. However, by the very nature of this approach, some of the functions cannot be delivered. Currently, it only captures classes and bindings, loops, the in operator, and several other incompatibilities. It does not support automatic generation of annotations, type casting, or custom keywords.
https://github.com/Steida/coffee2closure
Samuel hapak
source share