benderTheCrime / babel-plugin-transform-function-parameter-decorators

A plugin to transform decorators on function parameters using BabelJS: http://babeljs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Babel Plugin Transform Function Parameter Decorators

This is a plugin for Babel 6 that is used to transform function parameter decorators into calls to the decorator function within the body of the decorated function:

foo('foo');

function foo(@bar baz) {
    console.log(baz); // 'bar';
}

function bar(@baz qux) {
    console.log(qux); // 'foo';

    return 'bar';
}

NOTE:

This package depends on babel-plugin-transform-decorators-legacy

Installation & Usage

npm install babel-plugin-transform-decorators-legacy babel-plugin-transform-function-parameter-decorators

Add the following line to your .babelrc file:

    {
        "plugins": [
            "transform-decorators-legacy",
            "transform-function-parameter-decorators"
        ]
    }

NOTE: Order of Plugins Matters!

If you are including your plugins manually and using transform-decorators-legacy, make sure that transform-decorators-legacy comes before transform-function-parameter-decorators.

NOTE: This will not work with arrow functions!

Nor will any other decorators for that matter. If you need to use function parameter decorators please consider not using an arrow function.

License

MIT (c) 2016

About

A plugin to transform decorators on function parameters using BabelJS: http://babeljs.io/

License:MIT License


Languages

Language:JavaScript 100.0%