Skip to content

Unable to get typescript typings to work for custom html elements #135

Closed Answered by ChristianMurphy
vritant24 asked this question in Q&A
Discussion options

You must be logged in to vote

Welcome @vritant24! 👋
The React/JSX types allow adding additional elements to JSX.IntrinsicElements
This can look like:

declare global {
    namespace JSX {
        // this merges with the existing intrinsic elements, adding 'my-custom-tag' and its props
        interface IntrinsicElements {
            'my-custom-tag': {'my-custom-attribute': string}
        }
    }
}

source: related discussion over in react-markdown which uses similar typings remarkjs/react-markdown#622 (comment)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vritant24
Comment options

Answer selected by vritant24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
☂️ area/types This affects typings
2 participants