Skip to content

Move SyntaxErrors to Babylon from Babel (T7410) #4331

@babel-bot

Description

@babel-bot

Issue originally made by Francisco (tolmasky)

Description

There are a number of SyntaxErrors that are thrown at the transformation phase instead of the parsing stage. A non-exhaustive (I think?) list:

  1. SyntaxError: unknown: super() is only allowed in a derived constructor
  2. SyntaxError: unknown: 'this' is not allowed before super()
  3. SyntaxError: unknown: missing super() call in constructor

etc.

I think moving as many syntax errors as possible to Babylon would be immensely helpful. It would allow editors to use babylon and provide inline warnings, etc (whereas currently they need to additionally run the full transformation solely to get the errors). Additionally, in AST analysis/transformations, you are kind of dealing with illegal syntax trees (in the same way that you wouldn't want super() in a normal method, only to be warned about later in transformation). Currently we run into this issue a lot, as it would be very much more time consuming to be running transformation on every keypress, and so, as we find these, we manually add the syntax checks ourselves.

Metadata

Metadata

Assignees

Labels

outdatedA 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