Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect types for custom link components in PrismicRichText #173

Open
thompsongl opened this issue Feb 2, 2023 · 1 comment
Open

Incorrect types for custom link components in PrismicRichText #173

thompsongl opened this issue Feb 2, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@thompsongl
Copy link

thompsongl commented Feb 2, 2023

Versions

  • @prismicio/react: v2.5.1
  • react: v18.2.0
  • node: v16.18.1

Reproduction

https://codesandbox.io/s/modern-shadow-2tqpqb?file=/src/App.tsx

Steps to reproduce

  1. Go to the repro link
  2. See the TypeScript errors
  3. Change the @prismicio/react version to v2.1.2
  4. See the TypeScript errors disappear

What is expected?

@prismicio/[email protected] should not have the type errors

What is actually happening?

Trying to upgrade @prismicio/react to the latest version is blocked on type errors related to internalLinkComponent and externalLinkComponent:

Type '({ href, target, children, rel }: { href: any; target: any; children: any; rel: any; }) => Element' is not assignable to type '"a"'.

I have not been able to find a workaround (aside from type casting) or update to the PrismicLinkProps interface that accommodates custom components and DOM tag names.

@thompsongl thompsongl added the bug Something isn't working label Feb 2, 2023
@lihbr
Copy link
Member

lihbr commented Feb 3, 2023

Hey there, thanks for submitting an issue with a comprehensive reproduction!

I managed to reproduce and narrow the problematic version to version 2.3.0, see: #146

Remarks:
In the reproduction, 2 TypeScript versions are installed: 4.9.5 and 4.1.3, the latter being 2+ years old. However, it looks like it wasn't the one picked up, not impacting the reproduction. I reproduced the issue again with TypeScript 4.8.4 and 4.7.4.

We'll publish a fix soon ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants