PrismicRichText typescript support is lacking

I use the PrismicRichText component to render my RichText fields. As instructed by your documentation, I am attempting to use my own CustomLink component to handle hyperlinks like so:

<PrismicRichText
    field={article.data.body?.richText}
    components={{
        hyperlink: ({ node, children }) =>
            CustomLink({ node, children }),
    }}
/>

However, in this situation, node is of type RTLinkNode. Unfortunately, this type is not exported by Prismicio and there is no other reference to this type anywhere in the code. This poses a problem with TypeScript as in order to accept that link node in my CustomLink component, I must declare node as any.

This is not ideal for using typescript as using any makes the point of using typescript pointless.

Please provide support for all typescript types that are used.

Hey @tannerjuby1, thanks for reaching out. I'm consulting the team about this. I'll come back as soon as I have more info.

Hello team!

So, the type you need ( RTLinkNode ) is provided by the @prismicio/types package. You can import it like so:

import { RTLinkNode } from '@prismicio/types'

RTLinkNode can then be used in the CustomLink component prop types. We recommend you also explicitly install @prismicio/types so that it is listed in package.json.

npm install --save-dev @prismicio/types