Skip to content

Better representation of JSX in AST #7283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cknitt opened this issue Feb 6, 2025 · 3 comments
Closed

Better representation of JSX in AST #7283

cknitt opened this issue Feb 6, 2025 · 3 comments
Assignees

Comments

@cknitt
Copy link
Member

cknitt commented Feb 6, 2025

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

@cknitt cknitt moved this to Ready in ReScript development Feb 6, 2025
@nojaf nojaf self-assigned this Feb 6, 2025
@cknitt cknitt moved this from Ready to In progress in ReScript development Feb 6, 2025
@nojaf
Copy link
Collaborator

nojaf commented Feb 6, 2025

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
Copy link
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
Copy link
Collaborator

zth commented Feb 6, 2025

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.

@nojaf nojaf mentioned this issue Feb 8, 2025
@nojaf nojaf closed this as completed Apr 7, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in ReScript development Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants