babel/packages/babel-plugin-transform-class-properties
Moti Zilberman f8ddd80f96 Greater spec compliance for class properties (#4544)
* Desugar class properties to Object.defineProperty per spec
* Define uninitialized static class properties with value=undefined
* Make class-properties increased spec compliance opt-in (spec: true)
2016-11-15 16:35:51 -05:00
..

babel-plugin-transform-class-properties

Installation

$ npm install babel-plugin-transform-class-properties

Options: spec

  • Class properties are compiled to use Object.defineProperty
  • Static fields are now defined even if they are not initialized

Usage

.babelrc

// without options
{
  "plugins": ["transform-class-properties"]
}

// with options
{
  "plugins": [
    ["transform-class-properties", { "spec": true }]
  ]
}

Via CLI

$ babel --plugins transform-class-properties script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-class-properties"]
});