Fix/create element new jsx transform#41151
Conversation
| } | ||
|
|
||
| export function createExpressionForJsxElement(factory: NodeFactory, jsxFactoryEntity: EntityName | undefined, reactNamespace: string, tagName: Expression, props: Expression | undefined, children: readonly Expression[] | undefined, parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression { | ||
| export function createExpressionForJsxElement(factory: NodeFactory, callee: Expression, tagName: Expression, props: Expression | undefined, children: readonly Expression[] | undefined, location: TextRange): LeftHandSideExpression { |
There was a problem hiding this comment.
the signature differs now from the accompanying createExpressionForJsxFragment but this is just a util file so I don't think it's particularly important but let me know if you'd like this to be refactored somehow.
|
|
||
| function getImplicitImportForName(name: string) { | ||
| const existing = currentFileState.utilizedImplicitRuntimeImports?.get(name); | ||
| const importSource = name === "createElement" |
There was a problem hiding this comment.
this is a special case for the createElement within this "generic" util, but in the name of KISS I think it's perfectly OK here. The transform is tied to the semantics defined by React anyhow, this won't change often and there is near-zero chance that createElement will get reintroduced in the future in some other entrypoint in JSX runtimes
weswigham
left a comment
There was a problem hiding this comment.
I pushed a merge for the conflicts introduced this morning, and plan to merge once CI is green, thanks!
Please verify that:
Backlogmilestone (required)masterbranchgulp runtestslocallyFixes #41146
cc @gaearon @lunaruan @weswigham
I've first added a commit with tests covering the cases around
keyprops and the new JSX transform as those were not covered by any tests I could find (no tests for this were introduced in #39199) and then I've implemented a fix that auto-inserts import forcreateElementfrom thejsxImportSourceitself so it should be nicely visible what actual change this PR brings.