0.2.0 • Published 6 years ago

@jakewhelan/babel-plugin-transform-constructor-self-assign v0.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

@jakewhelan/babel-plugin-transform-constructor-self-assign

Babel plugin to automagically assign ES2015 class constructor arguments to this, as seen in Typescript

Usage

$ npm i -D @jakewhelan/babel-plugin-transform-constructor-self-assign
// babelrc.js
module.exports = {
  plugins: [
    require('@jakewhelan/babel-plugin-transform-constructor-self-assign')
  ]
}

Example

Before:

class Sample {
  constructor(a, $scope, bigLongName, SomeOtherWIerDCrAp) {
  }
}

After:

class Sample {
  constructor(a, $scope, bigLongName, SomeOtherWIerDCrAp) {
    this.a = a;
    this.$scope = $scope;
    this.bigLongName = bigLongName;
    this.SomeOtherWIerDCrAp = SomeOtherWIerDCrAp;
  }
}