Skip to content

Babel parser throws unexpected token when a super class is a TSAsExpression #17749

@JLHwung

Description

@JLHwung

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

class C extends (B as D) {}

REPL

Configuration file name

No response

Configuration

REPL

Current and expected behavior

Current: Babel throws expected , on the as token
Expected: Babel should parse it successfully, like what tsc did.

Environment

REPL

Possible solution

No response

Additional context

Other similar cases Babel currently fails but tsc can parse:

class C extends (B satisfies D) {}
class C extends (B as D)<T> {}
class C extends (B<T> as D)<T> {}

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions