Skip to content

ukari/babel-plugin-proposal-let-decorators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@babel/plugin-proposal-let-decorators

Compile let decorators to ES6

Example

(get more examples from proposal)

Simple let decorator

@annotation
let a = {};

function annotation(target) {
   target.annotated = true;
}

Let decorator

@logger(true)
let a = () => {};

function logger(flag) {
   return function(target) {
       if (flag) {
           return (...x) => (result => (console.log(result), result))(target(...x));
       } else {
           return target;
       }
   };
}

Multi decorators

@double
@inc
let a = 0;

function inc(value) {
  return value + 1;
}

function double(value) {
  return value * 2;
};

Installation

npm install --save-dev github:ukari/babel-plugin-syntax-let-decorators

Usage

Add the following line to your .babelrc file:

{
  "plugins": ["@babel/plugin-proposal-let-decorators"]
}

Via CLI

babel --plugins @babel/plugin-proposal-let-decorators script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-proposal-let-decorators"]
});

References

About

decorators on let

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published