Skip to content

JSX support#1052

Merged
Perryvw merged 6 commits intoTypeScriptToLua:masterfrom
GlassBricks:jsx
Jul 31, 2021
Merged

JSX support#1052
Perryvw merged 6 commits intoTypeScriptToLua:masterfrom
GlassBricks:jsx

Conversation

@GlassBricks
Copy link
Copy Markdown
Contributor

@GlassBricks GlassBricks commented Jul 29, 2021

Provides basic JSX support (#597).

  • Only jsx: "react" compiler option is supported.
  • The reactNamespace compiler option is ignored; it is deprecated anyways (use jsxFactory option instead).
  • JSX pragma comments is not (yet) supported. This could be implemented in the future using annotations.
    JSX pragma comments support added in second commit.

This implementation uses typescript's jsx transformation as reference and for tests. This means that this implementation is different from some exisiting jsx efforts for tstl in some areas:

  • The the "children" parameter passed to createElement should be accepted as a rest (...) parameter, not an array.
  • Comments inside jsx elements are omitted, instead of translated to "nil".
  • Text in jsx elements is handled differently: whitespace in multiline strings are trimmed properly, and escaped entities are allowed.

These should probably be documented if released.

Some jsx text processing implementations were copied from sucrase, which is released under the MIT liscence.

Closes #597

Typescript doesn't actually "spread out" jsx spread children, even though the syntax is supported.
@Perryvw Perryvw merged commit 987899c into TypeScriptToLua:master Jul 31, 2021
@GlassBricks GlassBricks deleted the jsx branch August 15, 2021 18:58
GlassBricks added a commit to GlassBricks/TypeScriptToLua that referenced this pull request Sep 5, 2021
GlassBricks added a commit to GlassBricks/TypeScriptToLua that referenced this pull request Sep 5, 2021
GlassBricks added a commit to GlassBricks/TypeScriptToLua that referenced this pull request Sep 5, 2021
Perryvw pushed a commit that referenced this pull request Sep 8, 2021
* Use `ts.transformJsx` instead for jsx. Reverts "JSX support (#1052)".

This reverts commit 987899c.

* Add comment explaining overriding compiler options
sanikoyes pushed a commit to sanikoyes/TypeScriptToLua that referenced this pull request Sep 24, 2021
* JSX support

* Add jsx and jsxFrag pragma support

* Remove unneeded flattenSpreadExpressions call.

Typescript doesn't actually "spread out" jsx spread children, even though the syntax is supported.

* Changes for PR.

* Add license for functions copied from sucrase

* Remove jsx snapshot test

Co-authored-by: Benjamin Ye <24237065+enjoydambience@users.noreply.github.com>
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
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.

JSX support

3 participants