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:
|
|
|
||
| // based on the code from @types/react@18.2.8 | ||
| // 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.
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.
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. |
|
Thank you for your kind review, I'm so very happy! is there anything else I need to do to get this PR merged? |
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/reactversion in emotion.If you don't mind updating
@types/react, I can change it to useReact.JSX.ElementTypedirectly after updating!Checklist:
closes #3049