babel-plugin-transform-class-property-arrow-to-bind
Babel plugin for transform arrow functions in class to bind in constructor, fork of louisscruz's plugin
Example:
{ return 'Hello'; } { return supermethod + ' World'; } test3 = 1337; { return 'Hello'; } method2 = async { const result = await { ; }; return result; } test = 123; test2 = 456; { return supermethod + ' World'; } method2 = async { const result = await super + ' World'; console; } const a = ;const b = ; consoleconsole
transforming to
{ return 'Hello'; } { return supermethod + ' World'; } { thistest3 = 1337; thismethod = thismethod; thismethod2 = thismethod2; } { return 'Hello'; } async { const result = await { ; }; return result; } { super...args; thistest = 123; thistest2 = 456; thismethod = thismethod; thismethod2 = thismethod2; } { return supermethod + ' World'; } async { const result = await super + ' World'; console; } const a = ;const b = ;console;console;
Installation
npm install --save-dev babel-plugin-transform-class-property-arrow-to-bind
yarn add --dev babel-plugin-transform-class-property-arrow-to-bind
Usage
This plugin does not handle the transformation of class properties themselves. For that, you will likely need to use babel-plugin-proposal-class-properties.
.babelrc
(Recommended)
Via
Via CLI
babel --plugins transform-class-property-arrow-to-bind script.js
Via Node API
;