Skip to content

[Bug]: Babel throws when a decorated class expression contains a static block #15112

@JLHwung

Description

@JLHwung

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

const dec = () => {};
0, @dec class { static {} }

REPL

Configuration file name

No response

Configuration

{
  "plugins": [["@babel/proposal-decorators", { "version": "2022-03" }]]
}

Both the 2022-03 and 2021-12 version are affected. The legacy transform does not throw.

Current and expected behavior

Current: Babel throws "cannot turn ClassExpression to a statement".

Expected: It should be transformed or if not, provide a better error message.

Environment

REPL

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Spec: DecoratorsoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions