Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-class-static-block

Package Overview
Dependencies
61
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/plugin-transform-class-static-block

Transform class static blocks


Version published
Weekly downloads
15M
decreased by-1.04%
Maintainers
4
Install size
5.03 MB
Created
Weekly downloads
 

Package description

What is @babel/plugin-transform-class-static-block?

The @babel/plugin-transform-class-static-block npm package allows developers to use the static class block syntax in JavaScript, enabling the definition of static initialization blocks within classes. This feature is particularly useful for performing tasks or initializing data that is related to the class itself, rather than instances of the class. The plugin transforms this modern syntax into a format that can be understood by JavaScript engines that do not yet support static class blocks.

What are @babel/plugin-transform-class-static-block's main functionalities?

Static Initialization Blocks

This feature allows for the execution of static blocks within a class, enabling complex initialization logic for static properties. The code sample demonstrates how a class can use a static block to fetch and assign data to a static property, with error handling.

class MyClass {
  static x = 0;
  static {
    try {
      const data = fetchData();
      MyClass.x = data;
    } catch (error) {
      MyClass.x = defaultValue;
    }
  }
}

Other packages similar to @babel/plugin-transform-class-static-block

Changelog

Source

v7.24.4 (2024-04-03)

:eyeglasses: Spec Compliance
  • babel-parser
    • #16403 Forbid initializerless using (@JLHwung)
  • babel-helpers, babel-plugin-proposal-decorators, babel-runtime-corejs3
:bug: Bug Fix
  • babel-generator
  • babel-compat-data, babel-plugin-bugfix-firefox-class-in-computed-class-key, babel-preset-env
  • babel-helper-create-class-features-plugin, babel-plugin-proposal-decorators
  • babel-plugin-transform-block-scoping
  • babel-core, babel-plugin-transform-block-scoped-functions, babel-plugin-transform-block-scoping

Readme

Source

@babel/plugin-transform-class-static-block

Transform class static blocks

See our website @babel/plugin-transform-class-static-block for more information.

Install

Using npm:

npm install --save-dev @babel/plugin-transform-class-static-block

or using yarn:

yarn add @babel/plugin-transform-class-static-block --dev

Keywords

FAQs

Last updated on 03 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your 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