Skip to content
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 react merged types #1606

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Fix react merged types #1606

merged 1 commit into from
Feb 2, 2023

Conversation

pedrodurek
Copy link
Member

Closes #1543

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin


declare module 'react' {
interface HTMLAttributes<T> {
children?: ReactI18NextChild | Iterable<ReactI18NextChild>;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't remember why and when we did that, but it doesn't make much sense, since ReactNode is already Iterable

Copy link
Member

@adrai adrai Feb 2, 2023

Choose a reason for hiding this comment

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

originally introduced with #1531 by @gshokanov to address #1506

Copy link
Member

Choose a reason for hiding this comment

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

@adrai
Copy link
Member

adrai commented Feb 2, 2023

patch version ok?

btw:
image

@coveralls
Copy link

coveralls commented Feb 2, 2023

Coverage Status

Coverage: 95.883%. Remained the same when pulling c668235 on pedrodurek:fix-react-types into 11bfe43 on i18next:master.

@pedrodurek pedrodurek reopened this Feb 2, 2023
@@ -39,11 +39,12 @@ declare module 'i18next' {
type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true
? Record<string, unknown>
: never;
type ReactI18NextChild = React.ReactNode | ObjectOrNever;

type ReactI18NextChildren = React.ReactNode | ObjectOrNever;
Copy link
Member Author

@pedrodurek pedrodurek Feb 2, 2023

Choose a reason for hiding this comment

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

Now, children will behave exactly like the actual one unless allowObjectInHTMLChildren is true.

@pedrodurek
Copy link
Member Author

@adrai, yes patch version

@adrai adrai merged commit 34d9e60 into i18next:master Feb 2, 2023
adrai added a commit that referenced this pull request Feb 2, 2023
@adrai
Copy link
Member

adrai commented Feb 2, 2023

included in v12.1.5

@YutaMoriJP
Copy link

Was this change overridden in the latest release (13.2.0)?

This JSX tag's 'children' prop expects a single child of type 'ReactI18NextChildren', but multiple children were provided.

@adrai
Copy link
Member

adrai commented Aug 29, 2023

@YutaMoriJP don't think so... correct @nicegamer7 ?

@nicegamer7
Copy link
Contributor

It shouldn't have been affected, no.

Though, at the company I'm working at, we had issues with this option already. I'll create a PR with the fix I implemented. I didn't open this PR previously because I didn't see anyone else complaining about this issue.

@YutaMoriJP
Copy link

@nicegamer7 Oh gosh yes please 🙏
Maybe before you create the PR mind telling me how you fixed it? Kinda stuck with this one... Thanks!

@YutaMoriJP
Copy link

YutaMoriJP commented Aug 29, 2023

@nicegamer7 Never mind you already created a PR and it got merged. You're fast! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants
  翻译: