Skip to content
"Parameter Properties" from TypeScript enabled with this Babel plugin.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.babelrc
.eslintrc.json
.gitignore
README.md
index.js
jsconfig.json
package.json

README.md

babel-plugin-proposal-parameter-properties

The Parameter Properties (from TypeScript) allow automatically assigning constructor parameters as instance properties.

This is especially useful when using dependency injection.

Example

Input:

@paramProperties
class HelloComponent {
    constructor(@pp broadcastService, message, name) {
    }
}

Output:

class HelloComponent {
    constructor(broadcastService, message, name) {
        this.broadcastService = broadcastService;
    }
}

Installation

npm install --save-dev babel-plugin-proposal-parameter-properties

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [
      "babel-plugin-syntax-decorators",
      "babel-plugin-proposal-parameter-properties"
    ]
}

Via CLI

babel script.js --plugins=babel-plugin-syntax-decorators,babel-plugin-proposal-parameter-properties

Via Node API

require("@babel/core").transform("code", {
    plugins: [
        "babel-plugin-syntax-decorators",
        "babel-plugin-proposal-parameter-properties"
    ]
});
You can’t perform that action at this time.