-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix/create element new jsx transform #41151
Fix/create element new jsx transform #41151
Conversation
@@ -64,7 +64,7 @@ namespace ts { | |||
); | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -40,17 +40,25 @@ namespace ts { | |||
} | |||
|
|||
function getImplicitImportForName(name: string) { | |||
const existing = currentFileState.utilizedImplicitRuntimeImports?.get(name); | |||
const importSource = name === "createElement" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a merge for the conflicts introduced this morning, and plan to merge once CI is green, thanks!
Please verify that:
Backlog
milestone (required)master
branchgulp runtests
locallyFixes #41146
cc @gaearon @lunaruan @weswigham
I've first added a commit with tests covering the cases around
key
props 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 forcreateElement
from thejsxImportSource
itself so it should be nicely visible what actual change this PR brings.