Socket
Socket
Sign inDemoInstall

@babel/plugin-proposal-decorators

Package Overview
Dependencies
61
Maintainers
4
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

@babel/plugin-proposal-decorators

Compile class and object decorators to ES5

    7.24.0latest
    GitHub
    npm

Version published
Maintainers
4
Weekly downloads
10,531,422
increased by5.96%

Weekly downloads

Package description

What is @babel/plugin-proposal-decorators?

The @babel/plugin-proposal-decorators package is a Babel plugin that enables the use of decorators, which are a stage 2 proposal for JavaScript. Decorators provide a way to add annotations and a meta-programming syntax for class declarations and members. Decorators can be used to modify classes, properties, methods, and accessors.

What are @babel/plugin-proposal-decorators's main functionalities?

Class Decorators

Class decorators are applied to the class and can be used to observe, modify, or replace a class definition. They can be used for logging, auto-binding, injecting dependencies, etc.

@decorator
class MyClass {}

function decorator(Class) {
  // Modify or wrap the class
  return modifiedClass;
}

Method Decorators

Method decorators are applied to methods of a class and can be used to observe, modify, or replace method definitions. This can be useful for debouncing, throttling, memoization, etc.

class MyClass {
  @decorator
  myMethod() {}
}

function decorator(target, name, descriptor) {
  // Modify or wrap the method
  return modifiedDescriptor;
}

Property Decorators

Property decorators are applied to class properties and can be used to modify the behavior of a property, such as by adding getters and setters, or by initializing with a default value.

class MyClass {
  @decorator
  myProperty;
}

function decorator(target, name) {
  // Modify or define property behavior
}

Accessor Decorators

Accessor decorators are applied to getters and setters and can be used to observe, modify, or replace accessors. This can be useful for validation, logging, etc.

class MyClass {
  _myValue;

  @decorator
  get myValue() {
    return this._myValue;
  }

  set myValue(value) {
    this._myValue = value;
  }
}

function decorator(target, name, descriptor) {
  // Modify or wrap the accessor
  return modifiedDescriptor;
}

Other packages similar to @babel/plugin-proposal-decorators

Changelog

Source

v7.24.0 (2024-02-28)

:rocket: New Feature
  • babel-standalone
    • #11696 Export babel tooling packages in @babel/standalone (@ajihyf)
  • babel-core, babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-transform-class-properties
  • babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-proposal-decorators, babel-plugin-proposal-pipeline-operator, babel-plugin-syntax-decorators, babel-plugin-transform-class-properties, babel-runtime-corejs2, babel-runtime-corejs3, babel-runtime
  • babel-preset-flow
  • babel-helper-import-to-platform-api, babel-plugin-proposal-import-wasm-source, babel-plugin-proposal-json-modules, babel-standalone
  • babel-plugin-transform-runtime
  • babel-parser, babel-types
:bug: Bug Fix
  • babel-plugin-proposal-do-expressions, babel-traverse
  • babel-helper-create-class-features-plugin, babel-plugin-transform-private-methods, babel-plugin-transform-private-property-in-object
  • babel-helper-create-class-features-plugin, babel-plugin-transform-private-methods
  • babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-proposal-decorators
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators, babel-plugin-transform-async-generator-functions, babel-plugin-transform-private-methods, babel-plugin-transform-private-property-in-object, babel-plugin-transform-typescript, babel-preset-env
  • babel-helpers
  • babel-helpers, babel-plugin-proposal-decorators
:nail_care: Polish
  • babel-core, babel-helper-create-class-features-plugin, babel-preset-env
:house: Internal
  • babel-helper-transform-fixture-test-runner
:microscope: Output optimization
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators
  • babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-proposal-decorators, babel-plugin-proposal-pipeline-operator, babel-plugin-transform-class-properties
  • babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-transform-private-methods
  • babel-helper-create-class-features-plugin, babel-helpers, babel-plugin-proposal-decorators
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators, babel-plugin-transform-class-properties
  • babel-helper-create-class-features-plugin, babel-helper-fixtures, babel-helpers, babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining, babel-plugin-proposal-decorators, babel-plugin-proposal-destructuring-private, babel-plugin-proposal-optional-chaining-assign, babel-plugin-transform-class-properties, babel-plugin-transform-class-static-block, babel-plugin-transform-private-methods, babel-plugin-transform-private-property-in-object, babel-preset-env, babel-runtime-corejs2, babel-runtime-corejs3, babel-runtime
  • babel-helpers, babel-plugin-proposal-decorators

Readme

Source

@babel/plugin-proposal-decorators

Compile class and object decorators to ES5

See our website @babel/plugin-proposal-decorators for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-proposal-decorators

or using yarn:

yarn add @babel/plugin-proposal-decorators --dev

Keywords

FAQs

Last updated on 28 Feb 2024

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc