Prismicio/helpers asText, asHTML typescript typing error

There is a TS typing error when using asText(), asHTML() on a expected rich text field

prismicH.asText(this._blogPost.title)

Argument of type 'any' is not assignable to parameter of type ' | [RTNode, ...RTNode]'.Type 'any' is not assignable to type '[RTNode, ...RTNode]'.Source provides no match for required element at position 0 in target.

The current workaround is to use "as any" to remove the error:

prismicH.asText(this._blogPost.title as any)

Hello Nicolas,

I'm not sure why you are getting this error. So I'm going to reach out to the team to get more information.

Thanks,
Priyanka

Hello @cptflammin

  1. Can you try updating @prismicio/types within your project and try again?
  2. Can you provide a minimal reproduction?
  3. Can you share with us your dependencies version? (package.json)

Thanks,
Priyanka

Hello, thx for reply, feedback, not running better :confused:

  1. Done: npm install --save-dev @prismicio/types@0.1.25 --color=always

import * as prismicH from '@prismicio/helpers'
`


{ prismicH.asText(this._blogPost.excerpt) }

`

"excerpt": [
{
"type": "paragraph",
"text": "March, April,May, it is time to rediscover these incredible European destinations for a budget. The wait is over !",
"spans":
}
],

Argument of type 'any' is not assignable to parameter of type ' | [RTNode, ...RTNode]'.Type 'any' is not assignable to type '[RTNode, ...RTNode]'.Source provides no match for required element at position 0 in target.

I am using StenciJS (www standard web component compiler) and coding in TS

"prismic-dom": "^2.2.7",
"@prismicio/client": "^6.3.0",
"@prismicio/helpers": "^2.1.1",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-prismic": "^1.0.9",

Hello @cptflammin

Sorry for the delayed response; I was out of the office. I am following up with the team and will come back to you as they reply.

Thanks,
Priyanka

Hello @cptflammin

Our dedicated team member is not sure about your exact context. You might need to type their "excerpt" property as apparently, and Stencil is typing it as any[], which is inaccurate. To do so, you can import { RichTextField } from "@prismicio/types" and use this type to type their excerpt prop/property.

But still, It doesn't solve your issue. It would be great to share proper context to troubleshoot it better.

Thanks,
Priyanka