Skip to content

Conversation

@edoardocavazza
Copy link
Contributor

This PR introduces and exports the IntrinsicHTMLElements interface, which is extended by IntrinsicElements. This approach allows you to declare built-in custom elements without running into interface merging issues.

Example:

declare global {
    namespace preact.JSX {
        interface IntrinsicElements {
            'details': preact.JSX.IntrinsicHTMLElements['details'] | {
                is: 'x-details';
                customProp: boolean;
            }
        }
    }
}

@rschristian
Copy link
Member

without running into interface merging issues.

Which issues are those exactly?

Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

I don't see much harm in it, even if it's rather niche & has some footguns for those that choose to use it (HTMLDetailsAttributes, for example, no longer aligns with the JSX type in your example above).

We probably wouldn't document an example like that so IMO it's fine.

@rschristian rschristian merged commit d2c0387 into preactjs:main Aug 14, 2025
4 checks passed
@coveralls
Copy link

Coverage Status

coverage: 99.536%. remained the same
when pulling 1b8488d on edoardocavazza:extensible-intrinsic-elements
into 68b30fe on preactjs:main.

@JoviDeCroock JoviDeCroock mentioned this pull request Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants