googclass-to-es6class
Transform a google closure class defined using goog.defineClass into an es6 class
For example:
const Parent = goog; const FooBar = goog; exports = FooBar;
Will be transformed into:
const Parent = goog; /** * Creates a new instance of... * @param */ { supername; thisname = name; } exports = FooBar;
How to use it
Install from npm
npm i goog-class-to-es6 -g
Transform a file
Provide the name of the file. The transformed class will be written to stdout:
goog-class-to-es6 some_goog_define_class.js
Do inline replacement. The file will be overwritten.
goog-class-to-es6 -i some_goog_define_class.js
Write to another file
goog-class-to-es6 some_goog_define_class.js output_file_es6.js
Testing
# 1. Clone this repo # 2. Install npm i# 3. Test npm test
Changelog
- 1.4.0 Add empty line at the end of file if original file has it.
- 1.5.0 Skip files without goog.defineClass.
- 1.6.0 Add support for functions declared like: foo() {
- 1.7.0 Escape closure type casts because Babel strips them.