Skip to content

Commit

Permalink
Declare relative-element under React.JSX to fix React 19 compatibility
Browse files Browse the repository at this point in the history
Fixes github#304

I had to add a `@ts-expect-error` comment since otherwise the typechecker would complain about missing `react` as a dependency.
  • Loading branch information
eramdam committed Jan 16, 2025
1 parent 8d86a67 commit ccd68e0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/relative-time-element-define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ declare global {
interface HTMLElementTagNameMap {
'relative-time': RelativeTimeElement
}
}

// @ts-expect-error This is needed for consumers using React 19 and above but TypeScript complains because `react` isn't a dependency of the project.
declare module 'react' {
namespace JSX {
interface IntrinsicElements {
['relative-time']: JSXBase['span'] & Partial<Omit<RelativeTimeElement, keyof HTMLElement>>
Expand Down

0 comments on commit ccd68e0

Please sign in to comment.