Skip to content

Better representation of JSX in AST #7283

Closed
@cknitt

Description

@cknitt
Member

We should improve the JSX representation in the AST before implementing JSX preserve mode (#6197).

Activity

self-assigned this
on Feb 6, 2025
moved this from Ready to In progress in ReScript developmenton Feb 6, 2025
nojaf

nojaf commented on Feb 6, 2025

@nojaf
Collaborator

So, my initial thoughts on this would be:

  • Extend expression_desc with a new type Pexp_jsx_element.
  • Update the parser to construct these new elements.
  • Map correct to tast. After that happen, nothing should impact I would assume?
  • Deal with tooling
  • Deal with ppx (Would need some pointers here)
cristianoc

cristianoc commented on Feb 6, 2025

@cristianoc
Collaborator

A first step could be to see how a few examples are currently mapped to the AST, and where is the code that deals with the output of this mapping.
Then find a more direct representation of the same information and modify the above code. It might be that a new expression desc, such as Pexp_jsx_element is completely processed by the ppx before it ever reaches the type checker, so is never used by later phased of the compiler (a bunch of places where that expression will never reach).
So I guess the first step is finding out what the current code path are.

zth

zth commented on Feb 6, 2025

@zth
Collaborator

Like @cristianoc says, I would also guess that the type checker won't have to care about JSX given that it's transformed to and type checked as regular function calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @cknitt@zth@nojaf@cristianoc

      Issue actions

        Better representation of JSX in AST · Issue #7283 · rescript-lang/rescript