-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Merge PR #65135 [react] Allow returning ReactNode from function com…
…ponents by @eps1lon * [react] Allow returning ReactNode from function components * [react] Ignore statics from element type checking would require a lot of work to fix the issues in the consuming libraries (e.g. rc-easyui, moxy__next-router-scroll etc) .propTypes assignablity is ultimately not important here. * Add JSX.ElementType to scoped namespace * Add JSX.ElementType to automatic runtime
- Loading branch information
Sebastian Silbermann
committed
Jun 1, 2023
1 parent
748cf88
commit 443451c
Showing
6 changed files
with
42 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
443451c
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.
Wow, this broke my entire ts:check step. Is anyone else seeing a spray of errors like this after updating to 18.2.8? This is with the latest TS 5.1.3. These components are declared with the regular React.FC typing.
443451c
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.
Are you seeing these when running
tsc
or in your IDE? Could you share a minimal, cloneable repro to investigate?443451c
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.
After looking more closely, @types/react: "18.2.8" works fine with TS 5.0.4. When you switch to 5.1.3, it throws the error.
18.2.7 works fine with TS 5.1.3. The incompatibility is the combo of 18.2.8 and TS 5.1.3 (both latest).
443451c
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.
When I use 18.2.8 and TS 5.1.3,
When use
StrictModel
, it shows error:'StrictMode' cannot be used as a JSX component.
When use
React.FC
, it shows error:Its return type 'ReactNode' is not a valid JSX element. Type 'undefined' is not assignable to type 'Element | null'
.But when switch to the combo of 18.2.8 and TS 5.0.4, then above error disappears.
443451c
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.
Unfortunately, this change breaks using
renderToString
andrenderToStaticMarkup
, which still expectReactElement
instead ofReactNode
.443451c
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 am seeing this in MikkCZ/pontoon-addon#685, using TypeScript 5.1.3. Seems like rendering a component like this makes
tsc
unhappy.Maybe even simpler example can be made. I haven't actually tried.
443451c
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.
+1 Having same issue after upgrading to 18.2.8 and TS 5.1.3