Skip to content

TypeScript types don't work with React 19 #304

Open
@eramdam

Description

@eramdam

Today I ran into an issue where the types that are shipped with the packages do not work anymore when using React 19 in a TypeScript project. This is because the global JSX namespace has been removed. I managed to fix the issue by making this change using patch-package in my project.

diff --git a/node_modules/@github/relative-time-element/dist/relative-time-element-define.d.ts b/node_modules/@github/relative-time-element/dist/relative-time-element-define.d.ts
index 6465123..58113c8 100644
--- a/node_modules/@github/relative-time-element/dist/relative-time-element-define.d.ts
+++ b/node_modules/@github/relative-time-element/dist/relative-time-element-define.d.ts
@@ -9,6 +9,8 @@ declare global {
     interface HTMLElementTagNameMap {
         'relative-time': RelativeTimeElement;
     }
+}
+declare module 'react' {
     namespace JSX {
         interface IntrinsicElements {
             ['relative-time']: JSXBase['span'] & Partial<Omit<RelativeTimeElement, keyof HTMLElement>>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions