Skip to content

[Bug]: Unexpected token syntax error is thrown with classStaticBlock and typescript. #13234

@sosukesuzuki

Description

@sosukesuzuki

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

class Foo {
  static {}
}

Configuration file name

No response

Configuration

Use classStaticBlock and typescript plugin.

const { parse } = require("@babel/parser");

const code =`class Foo {
  static {}
}`;

const result = parse(code, {
  sourceType: "module",
  errorRecovery: true,
  plugins: ["classStaticBlock", "typescript"],
});

Current and expected behavior

current:

SyntaxError: Unexpected token

expected:

no error

Environment

  • @babel/parser 7.14.0

Possible solution

No response

Additional context

prettier/prettier#10802 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions