Skip to content

[Bug]: Invalid static property for StaticBlock #13674

@sosukesuzuki

Description

@sosukesuzuki

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

class Foo {
  static {}
}

Configuration file name

No response

Configuration

const { parse } = require("@babel/parser");
const code = `class Foo {
  static {}
}`;
parse(code, { plugins: ["typescript", "classStaticBlock" ]});

Current and expected behavior

Current:

{
  "type": "Program",
  "sourceType": "script",
  "interpreter": null,
  "body": [
    {
      "type": "ClassDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Foo"
      },
      "superClass": null,
      "body": {
        "type": "ClassBody",
        "body": [
          {
            "type": "StaticBlock",
            "static": true,
            "body": []
          }
        ]
      }
    }
  ]
}

Expected:

{
  "type": "Program",
  "sourceType": "script",
  "interpreter": null,
  "body": [
    {
      "type": "ClassDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Foo"
      },
      "superClass": null,
      "body": {
        "type": "ClassBody",
        "body": [
          {
            "type": "StaticBlock",
-            "static": true,
            "body": []
          }
        ]
      }
    }
  ]
}

Environment

  • Babel version: current main

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions