# TS2322 error on \<PrismicRichText\> field parameter

**URL:** <https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901>\
**Category:** Developing with Prismic\
**Tags:** reactjs\
**Created:** [February 2, 2022, 7:20pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901 "2022-02-02T19:20:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thibault.pensec](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/thibault.pensec/32/3822_2.png) [@thibault.pensec](https://community.prismic.io/u/thibault.pensec)\
**Post date:** [February 2, 2022, 7:20pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901/1 "2022-02-02T19:20:05Z")

</div>

Hi guys,

I just started using Prismic with React/Typescript. It might not be related to Prismic at all, but I get a TS2322 error on my `<PrismicRichText>` `field` attribute when passing the document field I want to display.

For instance:

 ![Screen Shot 2022-02-02 at 20.05.33](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/1/100456ddec2b500e8060ef8ed601f9fc1c3e32e8.png)

I managed to workaround using a `// @ts-ignore` comment:

 ![Screen Shot 2022-02-02 at 20.05.43](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/6/6da66b4c9eb80cd2cd1f0403cdb2f975ba597115.png)

But it does not look really good obviously 🙄

Is there a way I can get around this issue?

Thanks

---

<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:** [February 4, 2022, 2:45pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901/2 "2022-02-04T14:45:30Z")

</div>

Hey Thibault,

I'm not sure what the issue is here, so I'm going to reach out to the team to get more info.

Thanks.

---

<div class="post-metadata">

**Author:** ![thibault.pensec](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/thibault.pensec/32/3822_2.png) [@thibault.pensec](https://community.prismic.io/u/thibault.pensec)\
**Post date:** [February 4, 2022, 3:43pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901/4 "2022-02-04T15:43:10Z")

</div>

Thanks @Phil !

FYI :

- Node version ➡ `v16.11.1`
- `package.json` ➡

```auto
{
  "name": "hello-prismic",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@prismicio/client": "^6.1.1",
    "@prismicio/react": "^2.0.5",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^13.2.1",
    "@types/jest": "^27.0.1",
    "@types/node": "^16.7.13",
    "@types/react": "^17.0.20",
    "@types/react-dom": "^17.0.9",
    "@types/react-helmet": "^6.1.5",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-helmet": "^6.1.0",
    "react-router-dom": "^6.2.1",
    "react-scripts": "5.0.0",
    "typescript": "^4.5.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

```

- `ts-config.json` ➡

```auto
{
  "compilerOptions": {
    "target": "es2017",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

```

---

<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:** [February 7, 2022, 2:36pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901/5 "2022-02-07T14:36:48Z")

</div>

Hey @thibault.pensec,

So this is related to the fact you haven't typed your API response, therefore you're dealing with a field which could be any kind field ( `AnyRegularField` )Two solutions:

- Typing your API response using `@prismicio/types` through the generics on client method calls ( `client.getSingle<PrismicDocument<{ description: RichTextField }>>("home")` )
- Using a type assertion ( `<PrismicRichText field="{home.data.description as RichTextField}" />` )

We’d recommend typing the full document (the first solution). Today, that needs to be written by hand which isn’t documented. We only have an example here: [https://github.com/prismicio/prismic-client/tree/master/examples/with-typescript](https://github.com/prismicio/prismic-client/tree/master/examples/with-typescript)

The second solution is the quicker of the two if you want an immediate, low-effort fix. Choosing this route negates the benefits of TypeScript, so we would discourage it, but it’s still a valid choice.

Thanks.

---

<div class="post-metadata">

**Author:** ![thibault.pensec](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/thibault.pensec/32/3822_2.png) [@thibault.pensec](https://community.prismic.io/u/thibault.pensec)\
**Post date:** [February 7, 2022, 7:28pm UTC](https://community.prismic.io/t/ts2322-error-on-prismicrichtext-field-parameter/8901/6 "2022-02-07T19:28:44Z")

</div>

Thanks @Phil it perfectly works!
