-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support JSX.ElementType #3048
Support JSX.ElementType #3048
Conversation
🦋 Changeset detectedLatest commit: f3c4c64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f3c4c64:
|
@@ -18,7 +18,12 @@ type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes | |||
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T> | |||
type ReactJSXIntrinsicElements = JSX.IntrinsicElements | |||
|
|||
// based on the code from @types/[email protected] | |||
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13 | |||
type ReactJSXElementType = string | React.JSXElementConstructor<any> |
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.
Hm, likely we could do some hacks with @ts-ignore
to "detect" if the type is there in React's JSX
but perhaps it's not worth it and copy-paste is fine. I'll give this a thought.
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.
yeah, I feel like copying it is probably the right approach tbh
Hmm, why is this error happening here?
|
I don't know much about JS and TS, but it is hard to believe that this Pull Request change affects On the other hand, when I updated to the latest 0.0.163, I get the error everywhere. These seemed to be caused by existing type definitions that were now working fine. |
Sorry, I see that it has fallen unchanged in CI... On my local, the problem remains at 0.0.112 and remains resolved at 0.0.115. Do you know anything about this?(why is this error occurring in the first place, Etc.) |
|
@Andarist Wow, I am very happy to see a fairly thorough explanation! Thank you very much! I tried each of the things you taught me, but this time I just decided to delete the test case. Once I updated If the test in the emotion fails, I thought about changing the ElementType as you said, but since that was not the case, I think we should leave it as is for the time being. |
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.
LGTM
Thank you for your kind review, I'm so very happy! is there anything else I need to do to get this PR merged? |
Thanks for the PR, review and merge @naari3, @Andarist, @emmatown ! 🙌 Looking forward to trying this out in |
What:
Support for JSX.ElementType that introduced in TypeScript 5.1
Why:
Until now, JSX type checking was provided by checking as JSX.Element.
From TypeScript 5.1 onward, by declaring JSX.ElementType, it will be possible to more flexibly check elements that can be handled on the jsx runtime side.
In React, this allows ReactNode to be used directly in the return value of function components. We would like to do the same for
@emotion/react/jsx-runtime
.How:
In
@types/react
, JSX.ElementType has been declared since 18.2.8, and I have copied the definition from the 18.2.8. because I don't know how to handle the@types/react
version in emotion.If you don't mind updating
@types/react
, I can change it to useReact.JSX.ElementType
directly after updating!Checklist:
closes #3049