Skip to content

internalComponent has confusing type errors #218

Description

@AO19

Versions

  • @prismicio/client: 7.16.0,
  • @prismicio/helpers: 2.3.9,
  • @prismicio/next: 2.0.0,
  • @prismicio/react: 3.0.0,
  • @prismicio/slice-simulator-react: 0.2.3,
  • react: 19.0.0
  • next: 15.1.7
  • Node.js: v22.12.0

Reproduction

Additional Details
import {
  PrismicLink as BasePrismicLink,
  LinkProps,
  PrismicLinkProps,
} from '@prismicio/react';
import Link from 'next/link';
import { linkResolver } from 'prismicio';

function InternalLink(props: LinkProps) {
  return <Link {...props} />;
}

export function PrismicLink(props: PrismicLinkProps) {
  return (
    <BasePrismicLink
      linkResolver={linkResolver}
      internalComponent={InternalLink}
      {...props}
    />
  );
}

Steps to reproduce

I followed this guide in my Next.js (Pages Router) app. Very confusing to be honest.

What is expected?

PrismicLink accepts InternalLink (Next Link component).

What is actually happening?

Type '(props: LinkProps) => Element' is not assignable to type 'ElementType<DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>> | undefined'.
  Type '(props: LinkProps) => Element' is not assignable to type 'FunctionComponent<DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>>'.
    Types of parameters 'props' and 'props' are incompatible.
      Type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>' is not assignable to type 'LinkProps'.
        Types of property 'href' are incompatible.
          Type 'string | undefined' is not assignable to type 'string'.
            Type 'undefined' is not assignable to type 'string'.ts(2322)
PrismicLink.d.ts(45, 5): The expected type comes from property 'internalComponent' which is declared here on type 'IntrinsicAttributes & (PrismicLinkProps<DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, DetailedHTMLProps<...>> & { ...; })'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions