# TypeScript errors with Content Relationship fields

**URL:** <https://community.prismic.io/t/typescript-errors-with-content-relationship-fields/20184>\
**Category:** Developing with Prismic\
**Tags:** nextjs, typescript, slice-machine\
**Created:** [May 12, 2026, 7:14am UTC](https://community.prismic.io/t/typescript-errors-with-content-relationship-fields/20184 "2026-05-12T07:14:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Phil](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/phil/32/14_2.png) [@Phil](https://community.prismic.io/u/Phil)\
**Post date:** [May 13, 2026, 4:32pm UTC](https://community.prismic.io/t/typescript-errors-with-content-relationship-fields/20184/2 "2026-05-13T16:32:15Z")

</div>

Hi there,

This is expected TypeScript behavior with Prismic content relationships. By default, TypeScript only knows that a content relationship is a link field, it does not automatically know which linked fields were fetched via `fetchLinks` or `graphQuery`. ([Prismic People](https://community.prismic.io/t/types-for-content-relationship-in-a-slice/12067?utm_source=chatgpt.com "Types for content relationship in a Slice"))

The recommended approach is to use a type predicate/helper function to narrow the type before accessing `.data`. This is especially useful for Slice fields and nested relationships. ([Prismic People](https://community.prismic.io/t/types-for-content-relationship-in-a-slice/12067?utm_source=chatgpt.com "Types for content relationship in a Slice"))

For example:

```auto
import * as prismicH from "@prismicio/helpers";
import * as prismicT from "@prismicio/types";
import { Content } from "@prismicio/client";

const hasParentData = <
  TContentRelationshipField extends prismicT.ContentRelationshipField
>(
  field: TContentRelationshipField
): field is TContentRelationshipField & {
  data: {
    parent: Pick<Content.PageDocument["data"], "title">;
  };
} => {
  return (
    prismicH.isFilled.contentRelationship(field) &&
    typeof field.data === "object" &&
    field.data !== null &&
    "parent" in field.data
  );
};

```

Then:

```auto
if (hasParentData(slice.primary.link)) {
  slice.primary.link.data.parent.title;
}

```

A few important notes:

- `isFilled.contentRelationship()` only checks whether the relationship itself exists.

- It does **not** tell TypeScript which linked fields were fetched.

- The linked fields must also be included in your query via `fetchLinks` or `graphQuery`. ([Prismic People](https://community.prismic.io/t/types-for-content-relationship-in-a-slice/12067?utm_source=chatgpt.com "Types for content relationship in a Slice"))

We have a few community threads covering similar cases here:

- [Types for content relationship in a Slice](https://community.prismic.io/t/types-for-content-relationship-in-a-slice/12067?utm_source=chatgpt.com)

- [Ts issue with contentrelationship fields](https://community.prismic.io/t/ts-issue-with-contentrelationship-fields/18035?utm_source=chatgpt.com)

- [Content relationship types within another content relationship in a Slice](https://community.prismic.io/t/content-relationship-types-within-another-content-relationship-in-a-slice/13866?utm_source=chatgpt.com)

Hope that helps clarify things a bit 🙂

---

_[View the full topic](https://community.prismic.io/t/typescript-errors-with-content-relationship-fields/20184)._
