Skip to content

Commit

Permalink
Global JSX namespace is deprecated (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrginglymus authored Dec 12, 2024
1 parent 69a342c commit eb372c4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,19 @@ declare module 'i18next' {
}
}

declare global {
namespace JSX {
interface IntrinsicAttributes {
i18nIsDynamicList?: boolean;
}
}
}

type ObjectOrNever = TypeOptions['allowObjectInHTMLChildren'] extends true
? Record<string, unknown>
: never;

type ReactI18NextChildren = React.ReactNode | ObjectOrNever;

declare module 'react' {
namespace JSX {
interface IntrinsicAttributes {
i18nIsDynamicList?: boolean;
}
}

interface HTMLAttributes<T> {
// This union is inspired by the typings for React.ReactNode. We do this to fix "This JSX tag's 'children' prop
// expects a single child of type 'ReactI18NextChildren', but multiple children were provided":
Expand Down Expand Up @@ -144,7 +142,7 @@ export function withTranslation<
},
): <
C extends React.ComponentType<React.ComponentProps<any> & WithTranslationProps>,
ResolvedProps = JSX.LibraryManagedAttributes<
ResolvedProps = React.JSX.LibraryManagedAttributes<
C,
$Subtract<React.ComponentProps<C>, WithTranslationProps>
>,
Expand Down

0 comments on commit eb372c4

Please sign in to comment.