Skip to content

Ensure factory symbol remains unused in react-jsx mode when not referenced in user code #41905

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

Merged
merged 1 commit into from
Dec 16, 2020

Conversation

weswigham
Copy link
Member

One of our checks was assuming the old-style jsx emit unconditionally and looking up the jsx factory entity name, which in turn would flag it as referenced.

Fixes #41882

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Dec 9, 2020
@@ -0,0 +1,16 @@
// @esModuleInterop: true
// @noUnusedLocals: true
// @jsx: react-jsx,react-jsxdev
Copy link
Member

Choose a reason for hiding this comment

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

🤯 TIL

@@ -26912,6 +26912,9 @@ namespace ts {
errorOutputContainer);

function checkTagNameDoesNotExpectTooManyArguments(): boolean {
if (getJsxNamespaceContainerForImplicitImport(node)) {
return true; // factory is implicitly jsx/jsxdev - assume it fits the bill, since we don't strongly look for the jsx/jsxs/jsxDEV factory APIs anywhere else (at least not yet)
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense, but it’s unintuitive as to why it fixes this particular bug. Something later in this function marked React as referenced, for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah - looking up it's type to see if it had call signatures.

@weswigham weswigham merged commit 675cd4d into microsoft:master Dec 16, 2020
@weswigham weswigham deleted the react-unused-error branch December 16, 2020 21:11
@atnpcg
Copy link

atnpcg commented Dec 29, 2020

Thanks for fixing this!
waiting for the release 🙏🏼
any estimate?, I guess will go out in 4.1.4?

@andrewbranch
Copy link
Member

andrewbranch commented Dec 29, 2020

So far, it’s slated for 4.2.0. When the rest of the team returns from vacation next week, we could discuss backporting it putting it into a patch release. /cc @DanielRosenwasser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
4 participants