Repository navigation
feat(compiler-plugins): emit JSX for ReactComponent calls - #724
Open
MangelMaxime wants to merge 2 commits into
Open
MangelMaxime wants to merge 2 commits into
MangelMaxime wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
This only works with Fable 5.24.0. Earlier versions ignore
Tags = [ "jsx-spread" ], so record props would not spread into the JSX element. The PR bumps the Fable tool in.config/dotnet-tools.jsonto 5.24.0.When compiling with
-e .jsx, calls to[<ReactComponent>]functions still came out ascreateElementcalls inside the JSX:Now they come out as elements:
Same for memo and lazy components.
.jsoutput doesn't change.The one thing worth a close look is children. Real JSX children arrive as nothing, one element or a JS array, so this component was silently printing
count=0:The declaration now converts
$props.childrenback to the declared type:Array and seq get the same treatment without the
ofArray. A bareReactElementis left alone.ReactComponentChildren.test.fscovers the three types with two, one, zero and runtime-built children.The lazy-by-reference code only recognised
createElementcalls, so it was taught the new form too.Record props use
JSX.spread, which shipped in Fable 5.24.0 (fable-compiler/Fable#5141). The full suite passes against it, 146 tests.No new attribute flag: if you compile to
.jsxyou get JSX. Can add an opt-out later if anyone needs it.