nuxt-modules / sanity

Sanity integration for Nuxt
https://sanity.nuxtjs.org
MIT License
211 stars 35 forks source link

SanityContent type not the same as Sanity CLI output #1001

Closed isakgustavsen closed 2 months ago

isakgustavsen commented 2 months ago

Version

@nuxtjs/sanity": "^1.11.3 @sanity/client": "^6.18.0 nuxt: 3.11.2

Reproduction

Used the new export types cli: Link

Can set up a repo purely for reproduction if necessary

Link: [ ] https://stackblitz.com/edit/nuxt-sanity [ ] GitHub repository

What is expected?

Types should match

What is actually happening?

Type 'BlockContent | undefined' is not assignable to type 'PortableTextBlock<PortableTextMarkDefinition, ArbitraryTypedObject | PortableTextSpan, string, string>[] | undefined'

Steps to reproduce

Export using guide and type query as described in module docs const { data } = await useSanityQuery<Type>(query)

Additional information

Exported type looks like this:

export type BlockContent = Array<{
  children?: Array<{
    marks?: Array<string>
    text?: string
    _type: 'span'
    _key: string
  }>
  style?: 'normal' | 'h1' | 'h2' | 'h3' | 'h4' | 'blockquote'
  listItem?: 'bullet'
  markDefs?: Array<{
    href?: string
    _type: 'link'
    _key: string
  }>
  level?: number
  _type: 'block'
  _key: string
}>

Checklist

isakgustavsen commented 2 months ago

Having looked at the types a bit more, it looks like the type comes from the portable text library. Will close here and move it over there