Skip to content

Use ts.transformJsx instead for jsx. #1123

Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
GlassBricks:ts-jsx
Sep 8, 2021
Merged

Use ts.transformJsx instead for jsx. #1123
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
GlassBricks:ts-jsx

Conversation

@GlassBricks
Copy link
Copy Markdown
Contributor

@GlassBricks GlassBricks commented Sep 5, 2021

Partially reverts commit 987899c "JSX support (#1052)".

This is an experiment with using typescript's own transformer instead of our own for JSX support. I think this could be better than what we are currently doing.

All JSX tests still pass, however, there is a backwards incompatibility: React.createElement now needs a self parameter, where it didn't previously. I couldn't find a good way to control this.

Advantages:

  • Low maintenance
  • Inherits all features
  • "reactJsx" option might be easy to add in the future
  • Integrates better with rest of features. e.g. this automatically fixes preceding statements (Preceding Statements #1116), which was previously broken with JSX.

Disadvantages:

  • Less control over transformation
  • Slightly hacky

@GlassBricks
Copy link
Copy Markdown
Contributor Author

There are some unnecessary diff due to unnecessary formatting by my IDE, fixing...

Copy link
Copy Markdown
Member

@Perryvw Perryvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, I'll gladly get rid of our custom jsx handling, this seems like the better solution to me.

@Perryvw Perryvw merged commit dc78114 into TypeScriptToLua:master Sep 8, 2021
@GlassBricks
Copy link
Copy Markdown
Contributor Author

Just remember to put the breaking change into the release notes:

React.createElement now should have a self parameter -- remove @noSelf or this: void, or add this: unknown if necessary.

sanikoyes pushed a commit to sanikoyes/TypeScriptToLua that referenced this pull request Sep 24, 2021
* Use `ts.transformJsx` instead for jsx. Reverts "JSX support (TypeScriptToLua#1052)".

This reverts commit 987899c.

* Add comment explaining overriding compiler options
@GlassBricks GlassBricks deleted the ts-jsx branch March 16, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants